diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiCommentController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiCommentController.java index e2fb757a7..5be97b0d8 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiCommentController.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiCommentController.java @@ -5,12 +5,12 @@ import com.elink.esua.epdc.commons.tools.annotation.LoginUser; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.CommentFormDTO; import com.elink.esua.epdc.dto.comment.CommentStatementFormDTO; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.comment.result.EventCommentsResultDTO; import com.elink.esua.epdc.service.CommentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.List; - /** * 移动端接口-评论模块 * @Author WJP @@ -42,5 +42,16 @@ public class ApiCommentController { public Result statement(@LoginUser TokenDto userDetail, CommentStatementFormDTO commentStatementFormDTO) { return commentService.statement(userDetail,commentStatementFormDTO); } + /** + * 评论列表 + * @Params: [userDetail, formDto] + * @Return: com.elink.esua.epdc.commons.tools.utils.Result + * @Author: liuchuang + * @Date: 2019/9/9 15:54 + */ + @GetMapping("list") + public Result listOfComments(@LoginUser TokenDto userDetail, EventCommentsFormDTO formDto) { + return commentService.listOfComments(userDetail,formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/CommentFeignClient.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/CommentFeignClient.java index f0e7434d8..49d86d790 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/CommentFeignClient.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/CommentFeignClient.java @@ -4,20 +4,16 @@ import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.comment.CommentStatementFormDTO; import com.elink.esua.epdc.dto.comment.EventCommentDTO; -import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO; -import com.elink.esua.epdc.dto.issue.form.IssueFormDTO; -import com.elink.esua.epdc.dto.issue.result.IssueResultDTO; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.comment.result.EventCommentsResultDTO; import com.elink.esua.epdc.feign.fallback.CommentFeignClientFallback; -import com.elink.esua.epdc.feign.fallback.IssueFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; -import java.util.List; - /** - * 议题模块调用 + * 评论模块调用 * @Author LC * @Date 2019/9/7 11:34 */ @@ -28,6 +24,15 @@ public interface CommentFeignClient { @PostMapping(value = "events/epdc-app/comment/submit", consumes = MediaType.APPLICATION_JSON_VALUE) Result submit(EventCommentDTO eventCommentDTO); + /** + * 评论列表 + * @Params: [formDto] + * @Return: com.elink.esua.epdc.commons.tools.utils.Result + * @Author: liuchuang + * @Date: 2019/9/9 15:58 + */ + @GetMapping(value = "events/epdc-app/comment/list", consumes = MediaType.APPLICATION_JSON_VALUE) + Result listOfComments(EventCommentsFormDTO formDto); @PostMapping(value = "events/epdc-app/comment/statement", consumes = MediaType.APPLICATION_JSON_VALUE) Result statement(CommentStatementFormDTO commentStatementFormDTO); diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/CommentFeignClientFallback.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/CommentFeignClientFallback.java index 585d01dee..2df1fba36 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/CommentFeignClientFallback.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/CommentFeignClientFallback.java @@ -5,6 +5,8 @@ import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.comment.CommentStatementFormDTO; import com.elink.esua.epdc.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.comment.result.EventCommentsResultDTO; import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO; import com.elink.esua.epdc.dto.issue.form.IssueFormDTO; import com.elink.esua.epdc.dto.issue.result.IssueResultDTO; @@ -27,4 +29,9 @@ public class CommentFeignClientFallback implements CommentFeignClient { public Result statement(CommentStatementFormDTO commentStatementFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "statement", commentStatementFormDTO); } + @Override + public Result listOfComments(EventCommentsFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "listOfComments", formDto); + } + } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/CommentService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/CommentService.java index 0c209d9b0..9df0794e4 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/CommentService.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/CommentService.java @@ -4,8 +4,9 @@ import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.commons.tools.annotation.LoginUser; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.CommentFormDTO; -import com.elink.esua.epdc.dto.UploadDTO; import com.elink.esua.epdc.dto.comment.CommentStatementFormDTO; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.comment.result.EventCommentsResultDTO; import com.elink.esua.epdc.dto.events.form.EpdcEventSubmitFormDTO; import com.elink.esua.epdc.dto.issue.form.IssueFormDTO; import com.elink.esua.epdc.dto.issue.result.IssueResultDTO; @@ -24,4 +25,13 @@ public interface CommentService { Result statement(@LoginUser TokenDto userDetail, CommentStatementFormDTO commentStatementFormDTO); + + /** + * 评论列表 + * @Params: [userDetail, formDto] + * @Return: com.elink.esua.epdc.commons.tools.utils.Result + * @Author: liuchuang + * @Date: 2019/9/9 15:54 + */ + Result listOfComments(TokenDto userDetail, EventCommentsFormDTO formDto); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/CommentServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/CommentServiceImpl.java index a9d55f3ac..83a1c870f 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/CommentServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/CommentServiceImpl.java @@ -6,6 +6,8 @@ import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.CommentFormDTO; import com.elink.esua.epdc.dto.comment.CommentStatementFormDTO; import com.elink.esua.epdc.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.comment.result.EventCommentsResultDTO; import com.elink.esua.epdc.feign.CommentFeignClient; import com.elink.esua.epdc.service.CommentService; import org.springframework.beans.factory.annotation.Autowired; @@ -41,4 +43,10 @@ public class CommentServiceImpl implements CommentService { public Result statement(TokenDto userDetail, CommentStatementFormDTO commentStatementFormDTO) { return commentFeignClient.statement(commentStatementFormDTO); } + + @Override + public Result listOfComments(TokenDto userDetail, EventCommentsFormDTO formDto) { + formDto.setUserId(userDetail.getUserId()); + return commentFeignClient.listOfComments(formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/form/EventCommentsFormDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/form/EventCommentsFormDTO.java new file mode 100644 index 000000000..76e299b39 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/form/EventCommentsFormDTO.java @@ -0,0 +1,49 @@ +package com.elink.esua.epdc.dto.comment.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 移动端评论表单DTO + * @Author LC + * @Date 2019/9/9 15:09 + */ +@Data +public class EventCommentsFormDTO implements Serializable { + private static final long serialVersionUID = -3804142943077174555L; + + /** + * 页码 + */ + @NotBlank(message = "页码不能为空") + private Integer pageIndex; + /** + * 页容量 + */ + @NotBlank(message = "分页数量不能为空") + private Integer pageSize; + /** + * 列表类型 0最新;1最热 + */ + @NotBlank(message = "列表类型不能为空") + private String orderType; + /** + * 时间戳(yyyy-MM-dd HH:mm:ss) + */ + private String timestamp; + /** + * 议题ID + */ + @NotBlank(message = "议题ID不能为空") + private String issueId; + /** + * 事件ID + */ + private String eventId; + /** + * 用户ID + */ + private String userId; +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/result/EventCommentsResultDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/result/EventCommentsResultDTO.java new file mode 100644 index 000000000..6b5b70503 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/comment/result/EventCommentsResultDTO.java @@ -0,0 +1,27 @@ +package com.elink.esua.epdc.dto.comment.result; + +import com.elink.esua.epdc.dto.events.EpdcEventsCommentsDTO; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 移动端评论列表DTO + * @Author LC + * @Date 2019/9/9 14:46 + */ +@Data +public class EventCommentsResultDTO implements Serializable { + private static final long serialVersionUID = -5087234859322214256L; + + /** + * 表态数 + */ + private long statementNum; + + /** + * 评论 + */ + List commentsList; +} diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsCommentsDTO.java b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsCommentsDTO.java index ca0bd82b7..8a804b845 100644 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsCommentsDTO.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/events/EpdcEventsCommentsDTO.java @@ -22,10 +22,26 @@ public class EpdcEventsCommentsDTO implements Serializable { * 内容 */ private String content; + /** + * 用户是否赞过,false未赞 + */ + private boolean userLike; + /** + * 用户是否踩过,true踩 + */ + private boolean userDislike; /** * 评论时间 */ private Date commentTime; + /** + * 赞数 + */ + private Integer approveNum; + /** + * 踩数 + */ + private Integer opposeNum; /** * 用户信息 */ diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java index 20cb70aab..d00f8a438 100755 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/controller/AppEventCommentController.java @@ -19,8 +19,11 @@ package com.elink.esua.epdc.modules.comment.controller; import com.elink.esua.epdc.commons.tools.constant.Constant; import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; import com.elink.esua.epdc.dto.comment.CommentStatementFormDTO; import com.elink.esua.epdc.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.comment.result.EventCommentsResultDTO; import com.elink.esua.epdc.modules.comment.service.EventCommentService; import com.elink.esua.epdc.modules.comment.service.EventCommentUserAttitudeService; import org.springframework.beans.factory.annotation.Autowired; @@ -49,5 +52,18 @@ public class AppEventCommentController { eventCommentUserAttitudeService.statement(formDto); return new Result(); } + /** + * 移动端-议题评论 + * @Params: [formDTO] + * @Return: com.elink.esua.epdc.commons.tools.utils.Result + * @Author: liuchuang + * @Date: 2019/9/9 15:38 + */ + @GetMapping("list") + public Result listOfComments(@RequestBody EventCommentsFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + return eventCommentService.listOfComments(formDTO); + } + } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/dao/EventCommentDao.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/dao/EventCommentDao.java index 9e819acb7..1710816f1 100755 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/dao/EventCommentDao.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/dao/EventCommentDao.java @@ -18,9 +18,13 @@ package com.elink.esua.epdc.modules.comment.dao; import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.events.EpdcEventsCommentsDTO; import com.elink.esua.epdc.modules.comment.entity.EventCommentEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 事件评论表 事件评论表 * @@ -34,4 +38,22 @@ public interface EventCommentDao extends BaseDao { void updateReplyCount(String commentId); + /** + * 移动端评论列表 + * @Params: [formDTO] + * @Return: java.util.List + * @Author: liuchuang + * @Date: 2019/9/9 15:13 + */ + List selectListOfComments(EventCommentsFormDTO formDTO); + + /** + * 移动端议题评论表态次数 + * @Params: [eventId] + * @Return: long + * @Author: liuchuang + * @Date: 2019/9/9 15:31 + */ + long selectCountOfStatementNum(String eventId); + } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java index f2a3ec530..034f76e33 100755 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/EventCommentService.java @@ -19,7 +19,10 @@ package com.elink.esua.epdc.modules.comment.service; import com.elink.esua.epdc.commons.mybatis.service.BaseService; import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.comment.result.EventCommentsResultDTO; import com.elink.esua.epdc.modules.comment.entity.EventCommentEntity; import java.util.List; @@ -102,4 +105,13 @@ public interface EventCommentService extends BaseService { void updateApproveNumOrOpposeNum(String commentId, String attitudeFlag); + + /** + * 移动端评论列表 + * @Params: [formDTO] + * @Return: java.util.List + * @Author: liuchuang + * @Date: 2019/9/9 15:21 + */ + Result listOfComments(EventCommentsFormDTO formDTO); } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java index 52fecf01b..db7beb1f2 100755 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/comment/service/impl/EventCommentServiceImpl.java @@ -23,12 +23,18 @@ import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.comment.EventCommentDTO; +import com.elink.esua.epdc.dto.comment.form.EventCommentsFormDTO; +import com.elink.esua.epdc.dto.comment.result.EventCommentsResultDTO; +import com.elink.esua.epdc.dto.events.EpdcEventsCommentsDTO; import com.elink.esua.epdc.modules.comment.dao.EventCommentDao; import com.elink.esua.epdc.modules.comment.entity.EventCommentEntity; import com.elink.esua.epdc.modules.comment.redis.EventCommentRedis; import com.elink.esua.epdc.modules.comment.service.EventCommentService; import com.elink.esua.epdc.modules.events.service.EpdcEventsService; +import com.elink.esua.epdc.modules.issue.entity.IssueEntity; +import com.elink.esua.epdc.modules.issue.service.IssueService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -53,6 +59,9 @@ public class EventCommentServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -122,4 +131,18 @@ public class EventCommentServiceImpl extends BaseServiceImpl listOfComments(EventCommentsFormDTO formDTO) { + IssueEntity issueEntity = issueService.selectById(formDTO.getIssueId()); + formDTO.setEventId(issueEntity.getEventId()); + // 表态数 + long statementNum = baseDao.selectCountOfStatementNum(issueEntity.getEventId()); + // 评论 + List list = baseDao.selectListOfComments(formDTO); + EventCommentsResultDTO data = new EventCommentsResultDTO(); + data.setStatementNum(statementNum); + data.setCommentsList(list); + return new Result().ok(data); + } } diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/comment/EventCommentDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/comment/EventCommentDao.xml index 64be95bb2..ea021d027 100755 --- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/comment/EventCommentDao.xml +++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/comment/EventCommentDao.xml @@ -26,6 +26,94 @@ + + + + + + + + + + + + + + + + +