Browse Source

发布评论或回复添加数据校验

dev
liuchuang 6 years ago
parent
commit
a2c1ee33a4
  1. 4
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/form/CommentFormDTO.java
  2. 3
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java
  3. 2
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java
  4. 6
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java

4
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/form/CommentFormDTO.java

@ -11,6 +11,7 @@ package com.elink.esua.epdc.dto.comment.form;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/** /**
* 评论议题提交评论 * 评论议题提交评论
@ -28,12 +29,13 @@ public class CommentFormDTO {
//父评论(被评论)ID //父评论(被评论)ID
private String faCommentId; private String faCommentId;
@NotBlank(message = "评论内容不能为空") @Size(min = 1, max = 500, message = "评论内容不能超过500字")
private String content; private String content;
/** /**
* 评论人ID * 评论人ID
*/ */
@NotBlank(message = "评论人ID不能为空")
private String userId; private String userId;
/** /**

3
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java

@ -42,11 +42,12 @@ public class AppEventCommentController {
/** /**
* 提交评论或回复接口 * 提交评论或回复接口
* @param dto * @param commentFormDTO
* @return * @return
*/ */
@PostMapping("submit") @PostMapping("submit")
public Result submit(@RequestBody CommentFormDTO commentFormDTO){ public Result submit(@RequestBody CommentFormDTO commentFormDTO){
ValidatorUtils.validateEntity(commentFormDTO);
return eventCommentService.submit(commentFormDTO); return eventCommentService.submit(commentFormDTO);
} }

2
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java

@ -100,7 +100,7 @@ public interface EventCommentService extends BaseService<EventCommentEntity> {
/** /**
* 提交评论或回复接口 * 提交评论或回复接口
* @param dto * @param commentFormDTO
*/ */
Result submit(CommentFormDTO commentFormDTO); Result submit(CommentFormDTO commentFormDTO);

6
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java

@ -145,10 +145,16 @@ public class EventCommentServiceImpl extends BaseServiceImpl<EventCommentDao, Ev
// 判断评论或回复的是议题还是项目 // 判断评论或回复的是议题还是项目
if (StringUtils.isNotEmpty(commentFormDTO.getIssueId())) { if (StringUtils.isNotEmpty(commentFormDTO.getIssueId())) {
issueEntity = issueService.selectById(commentFormDTO.getIssueId()); issueEntity = issueService.selectById(commentFormDTO.getIssueId());
if (null == issueEntity || StringUtils.isEmpty(issueEntity.getEventId())) {
return new Result().error("获取事件信息失败");
}
commentEntity.setEventId(issueEntity.getEventId()); commentEntity.setEventId(issueEntity.getEventId());
} else { } else {
isIssue = false; isIssue = false;
itemEntity = itemService.selectById(commentFormDTO.getItemId()); itemEntity = itemService.selectById(commentFormDTO.getItemId());
if (null == itemEntity || StringUtils.isEmpty(itemEntity.getEventId())) {
return new Result().error("获取事件信息失败");
}
commentEntity.setEventId(itemEntity.getEventId()); commentEntity.setEventId(itemEntity.getEventId());
} }

Loading…
Cancel
Save