fix articleController

main
Revers 10 months ago
parent ee341d4f44
commit 17763e8dfc

@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.time.LocalDateTime;
/**
* @author Revers.
@ -43,6 +44,9 @@ public class CMSArticleController {
public Result add(@ApiParam(value = "文章信息", required = true) @Valid @RequestBody ArticleAddModel articleAddModel, BindingResult bindingResult){
if (bindingResult.hasErrors())
return Result.failed(bindingResult.getFieldError().getDefaultMessage());
if(articleAddModel.getPubTime() == null){
articleAddModel.setPubTime(LocalDateTime.now());
}
return articleService.add(articleAddModel);
}

@ -42,7 +42,7 @@ public class ArticleAddModel {
@ApiModelProperty(value = "定时发布时间")
private LocalDateTime pubTime;
@Pattern(regexp="(^[0-9]{0,20})", message="是否自动推送异常")
@Pattern(regexp="(^[0-9]{0,20})", message="发布人ID")
@ApiModelProperty(value = "发布人ID")
private String userId;

@ -7,6 +7,7 @@ import lombok.Data;
import org.apache.commons.lang.StringUtils;
import java.io.Serializable;
import java.time.format.DateTimeFormatter;
/**
* @author Revers.
@ -38,7 +39,7 @@ public class ArticleRespDTO implements Serializable {
@ApiModelProperty(value = "是否定时发布 否0 是1")
private String isScheduled;
@ApiModelProperty(value = "发布时间,格式为: yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "发布时间,格式为: yyyy-MM-ddTHH:mm:ss.sssZ")
private String pubTime;
@ApiModelProperty(value = "是否允许评论 否0 是1")
@ -67,11 +68,11 @@ public class ArticleRespDTO implements Serializable {
response.setContent(article.getContent());
response.setUserId(article.getUserId());
response.setUserName(article.getUserName());
response.setDate(article.getUpdateTime().format(Constants.formatter));
response.setDate(article.getUpdateTime().format(DateTimeFormatter.ISO_DATE_TIME));
response.setTotalCommentReply(article.getComment());
response.setVistisNum(article.getVisits());
response.setIsScheduled(article.getIsScheduled());
response.setPubTime(article.getPubTime().format(Constants.formatter));
response.setPubTime(article.getPubTime().format(DateTimeFormatter.ISO_DATE_TIME));
response.setAllowCommit(article.getAllowCommit());
response.setAutoPush("1".equals(article.getAutoPush())?true:false);

Loading…
Cancel
Save