diff --git a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/BehaviorEnum.java b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/BehaviorEnum.java index 0c4158b8..c047767b 100644 --- a/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/BehaviorEnum.java +++ b/esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/enums/BehaviorEnum.java @@ -290,7 +290,27 @@ public enum BehaviorEnum { /** * 内容浏览 */ - CONTENT_BROWSE("content_browse"); + CONTENT_BROWSE("content_browse"), + + /** + * 评论内容 + */ + NOTICE_COMMENT_SUBMIT("notice_comment_submit"), + + /** + * 回复内容的评论 + */ + NOTICE_COMMENT_REPLY_SUBMIT("notice_comment_reply_submit"), + + /** + * 内容评论的点赞 + */ + NOTICE_COMMENT_SUPPORT("notice_comment_support"), + + /** + * 内容评论的点踩 + */ + NOTICE_COMMENT_OPPOSITION("notice_comment_opposition"); private String value; diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java index 256b54cf..8450218e 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiNewsController.java @@ -238,4 +238,88 @@ public class ApiNewsController { } return newsService.getModuleCategory(dto); } + + /** + * 内容评论提交 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 11:14 + */ + @PostMapping("notice/comment/submit") + @RecordUserBehavior(behavior = BehaviorEnum.NOTICE_COMMENT_SUBMIT,referenceId = "#{fromDTO.getNoticeId}",userId = "#{userDetail.getUserId}") + public Result noticeCommentSubmit(@LoginUser TokenDto userDetail, @RequestBody EpdcNoticeCommentSubmitFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return newsService.saveNoticeComment(userDetail, formDto); + } + + /** + * 内容评论的回复提交 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 11:14 + */ + @PostMapping("notice/comment/reply/submit") + @RecordUserBehavior(behavior = BehaviorEnum.NOTICE_COMMENT_REPLY_SUBMIT,referenceId = "#{fromDTO.getNoticeId}",userId = "#{userDetail.getUserId}") + public Result noticeCommentReplySubmit(@LoginUser TokenDto userDetail, @RequestBody EpdcNoticeCommentSubmitFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return newsService.saveNoticeComment(userDetail, formDto); + } + + /** + * 内容评论表态-支持 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:32 + */ + @PostMapping("notice/comment/statement/support") + @RecordUserBehavior(behavior = BehaviorEnum.NOTICE_COMMENT_SUPPORT,referenceId = "#{fromDTO.getNoticeId}",userId = "#{userDetail.getUserId}") + public Result noticeCommentStatementSupport(@LoginUser TokenDto userDetail, @RequestBody EpdcNoticeCommentStatementFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return newsService.noticeCommentStatement(userDetail, formDto); + } + + /** + * 内容评论表态-反对 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:33 + */ + @PostMapping("notice/comment/statement/opposition") + @RecordUserBehavior(behavior = BehaviorEnum.NOTICE_COMMENT_OPPOSITION,referenceId = "#{fromDTO.getNoticeId}",userId = "#{userDetail.getUserId}") + public Result noticeCommentStatementOpposition(@LoginUser TokenDto userDetail, @RequestBody EpdcNoticeCommentStatementFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return newsService.noticeCommentStatement(userDetail, formDto); + } + + /** + * 内容评论列表 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:43 + */ + @GetMapping("notice/comment/list") + public Result noticeCommentList(@LoginUser TokenDto userDetail, @RequestBody EpdcNoticeCommentListFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return newsService.listNoticeComments(userDetail, formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java index 9f1fad37..a985935f 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/NewsFeignClient.java @@ -157,10 +157,9 @@ public interface NewsFeignClient { @PostMapping(value = "news/epdc-app/information/first/{userId}", consumes = MediaType.APPLICATION_JSON_VALUE) Result selectOneFristByUserId(@PathVariable String userId); - /* + /** * 移动端通知列表接口 - v2 * - * @param userDetail * @param formDto * @return com.elink.esua.epdc.commons.tools.utils.Result> * @Author zhangyong @@ -178,4 +177,37 @@ public interface NewsFeignClient { **/ @GetMapping("news/modulecategory/moduleCategory") Result> getModuleCategory(@RequestBody ModuleCategoryFormDTO dto); + + /** + * 内容评论、回复提交 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:50 + */ + @PostMapping(value = "news/epdc-app/notice/comment/submit", consumes = MediaType.APPLICATION_JSON_VALUE) + Result noticeCommentSubmit(EpdcNoticeCommentSubmitFormDTO formDto); + + /** + * 内容评论表态 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:55 + */ + @PostMapping(value = "news/epdc-app/notice/comment/statement", consumes = MediaType.APPLICATION_JSON_VALUE) + Result noticeCommentStatement(EpdcNoticeCommentStatementFormDTO formDto); + + /** + * 内容评论列表 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:57 + */ + @GetMapping(value = "news/epdc-app/notice/comment/list", consumes = MediaType.APPLICATION_JSON_VALUE) + Result listNoticeComments(EpdcNoticeCommentListFormDTO formDto); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java index fc41c4dc..4aba4676 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/NewsFeignClientFallback.java @@ -86,6 +86,21 @@ public class NewsFeignClientFallback implements NewsFeignClient { @Override public Result> getModuleCategory(ModuleCategoryFormDTO dto) { - return ModuleUtils.feignConError(ServiceConstant.EPDC_CUSTOM_SERVER, "ModuleCategoryFormDTO", dto); + return ModuleUtils.feignConError(ServiceConstant.EPDC_NEWS_SERVER, "ModuleCategoryFormDTO", dto); + } + + @Override + public Result noticeCommentSubmit(EpdcNoticeCommentSubmitFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_NEWS_SERVER, "noticeCommentSubmit", formDto); + } + + @Override + public Result noticeCommentStatement(EpdcNoticeCommentStatementFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_NEWS_SERVER, "noticeCommentStatement", formDto); + } + + @Override + public Result listNoticeComments(EpdcNoticeCommentListFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_NEWS_SERVER, "listNoticeComments", formDto); } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java index 509f3bb5..023c6b5b 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/NewsService.java @@ -148,7 +148,7 @@ public interface NewsService { **/ Result> listV2Notice(TokenDto userDetail, EpdcNoticeListV2FormDTO formDto); /** - * @Description 新闻浏览有效时间内加积分接口 + * @Description 新闻浏览有效时间内加积分接口 * @Author songyunpeng * @Date 2020/6/9 * @Param [userDetail, newsBrowseFromDTO] @@ -182,4 +182,37 @@ public interface NewsService { * @return void **/ void addContentPoints(TokenDto userDetail, ModuleCategoryFormDTO dto); + + /** + * 内容评论、回复提交 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 11:18 + */ + Result saveNoticeComment(TokenDto userDetail, EpdcNoticeCommentSubmitFormDTO formDto); + + /** + * 内容评论表态 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:33 + */ + Result noticeCommentStatement(TokenDto userDetail, EpdcNoticeCommentStatementFormDTO formDto); + + /** + * 内容评论列表 + * + * @param userDetail + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:43 + */ + Result listNoticeComments(TokenDto userDetail, EpdcNoticeCommentListFormDTO formDto); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java index e6535e5a..e3781601 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java @@ -3,6 +3,7 @@ package com.elink.esua.epdc.service.impl; import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.enums.BehaviorEnum; +import com.elink.esua.epdc.commons.tools.enums.UserTagEnum; import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; import com.elink.esua.epdc.commons.tools.redis.RedisUtils; import com.elink.esua.epdc.commons.tools.utils.Result; @@ -15,6 +16,7 @@ import com.elink.esua.epdc.feign.ActInfoFeignClient; import com.elink.esua.epdc.feign.NewsFeignClient; import com.elink.esua.epdc.pointcommons.tools.annotation.RecordUserBehavior; import com.elink.esua.epdc.service.NewsService; +import com.elink.esua.epdc.utils.UserTagUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -165,4 +167,31 @@ public class NewsServiceImpl implements NewsService { public void addContentPoints(TokenDto userDetail, ModuleCategoryFormDTO dto) { } + + @Override + public Result saveNoticeComment(TokenDto userDetail, EpdcNoticeCommentSubmitFormDTO formDto) { + formDto.setUserId(userDetail.getUserId()); + formDto.setUserName(userDetail.getNickname()); + formDto.setUserFace(userDetail.getFaceImg()); + formDto.setDeptId(userDetail.getGridId()); + + if (UserTagUtils.containIdentity(userDetail.getUserTagInfos(), UserTagEnum.PARTY_MEMBER)) { + formDto.setPartyFlag(YesOrNoEnum.YES.value()); + } else { + formDto.setPartyFlag(YesOrNoEnum.NO.value()); + } + return newsFeignClient.noticeCommentSubmit(formDto); + } + + @Override + public Result noticeCommentStatement(TokenDto userDetail, EpdcNoticeCommentStatementFormDTO formDto) { + formDto.setUserId(userDetail.getUserId()); + return newsFeignClient.noticeCommentStatement(formDto); + } + + @Override + public Result listNoticeComments(TokenDto userDetail, EpdcNoticeCommentListFormDTO formDto) { + formDto.setUserId(userDetail.getUserId()); + return newsFeignClient.listNoticeComments(formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/ModuleCategoryDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/ModuleCategoryDTO.java index 85ea6f35..fee214ab 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/ModuleCategoryDTO.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/ModuleCategoryDTO.java @@ -105,10 +105,15 @@ public class ModuleCategoryDTO extends TreeNode implements Serializable { */ private String enableFlag; + /** + * 内容评论标识 0-否,1-是 + */ + private String commentFlag; + private String parentName; private String value; private String label; -} \ No newline at end of file +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeCommentDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeCommentDTO.java new file mode 100644 index 00000000..ffbeb607 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeCommentDTO.java @@ -0,0 +1,151 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 内容评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@Data +public class NoticeCommentDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 内容ID + */ + private String noticeId; + + /** + * 评论人ID + */ + private String userId; + + /** + * 评论人昵称 + */ + private String userName; + + /** + * 评论人头像 + */ + private String userFace; + + /** + * 评论内容 + */ + private String content; + + /** + * 评论类型 0:评论,1:回复,2:回复的回复 + */ + private String commentType; + + /** + * 回复的评论ID + */ + private String commentId; + + /** + * 被回复数 + */ + private Integer replyCount; + + /** + * 被回复人ID + */ + private String replyUserId; + + /** + * 被回复人名称 + */ + private String replyUserName; + + /** + * 被回复人头像 + */ + private String replyUserFace; + + /** + * 点赞数 + */ + private Integer likeCount; + + /** + * 点踩数 + */ + private Integer unLikeCount; + + /** + * 屏蔽标识 0:未屏蔽,1:已屏蔽 + */ + private String shieldFlag; + + /** + * 删除标识 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 0 未进行校验;1 微信校验通过;2 微信校验不通过;3 管理员校验通过;4 管理员校验不通过 + */ + private String sensitiveFlag; + + /** + * 党员标识(0-否,1-是) + */ + private String partyFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeCommentUserAttitudeDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeCommentUserAttitudeDTO.java new file mode 100644 index 00000000..ef1b44ce --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/NoticeCommentUserAttitudeDTO.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 内容评论点赞点踩表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@Data +public class NoticeCommentUserAttitudeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 内容评论ID + */ + private String noticeCommentId; + + /** + * 用户ID + */ + private String userId; + + /** + * 用户点赞点踩标识 0:点赞,1:点踩 + */ + private String attitudeFlag; + + /** + * 删除标识 0:未删除,1:删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentListFormDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentListFormDTO.java new file mode 100644 index 00000000..2fa3a171 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentListFormDTO.java @@ -0,0 +1,50 @@ +package com.elink.esua.epdc.dto.epdc.form; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 移动端-内容最新最热列表 + * @Author zy + * @Date 2020/3/26 + */ +@Data +public class EpdcNoticeCommentListFormDTO implements Serializable { + private static final long serialVersionUID = -8864248267171206774L; + + /** + * 页码,从1开始 + */ + @Min(value = 1, message = "页码必须大于0") + private int pageIndex; + /** + * 页容量,默认20页 + */ + @Min(value = 1, message = "每页条数必须大于必须大于0") + private int pageSize = 10; + + /** + * 第一页查询发起时的时间 + */ + private String timestamp; + + /** + * 列表类型 0最新;1最热 + */ + @NotBlank(message = "列表类型不能为空") + private String orderType; + + /** + * 内容ID + */ + @NotBlank(message = "内容ID不能为空") + private String noticeId; + + /** + * 用户ID + */ + private String userId; +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentStatementFormDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentStatementFormDTO.java new file mode 100644 index 00000000..37d5884d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentStatementFormDTO.java @@ -0,0 +1,40 @@ +package com.elink.esua.epdc.dto.epdc.form; + + +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * @author: zhangyong + * @Date: 2020/3/25 + * @Description: 表态评论(赞/踩) + */ +@Data +public class EpdcNoticeCommentStatementFormDTO implements Serializable { + private static final long serialVersionUID = -2046090814527654468L; + + /** + * 表态 0赞;1踩;2取消点赞;3取消点踩 + */ + @NotNull(message = "态度不能为空") + private String attitude; + + /** + * 评论ID + */ + @NotNull(message = "评论ID不能为空") + private String commentId; + + /** + * 新闻ID + */ + @NotNull(message = "内容ID不能为空") + private String noticeId; + + /** + * 用户ID + */ + private String userId; +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentSubmitFormDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentSubmitFormDTO.java new file mode 100644 index 00000000..d8ea3ad9 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcNoticeCommentSubmitFormDTO.java @@ -0,0 +1,67 @@ +package com.elink.esua.epdc.dto.epdc.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * 移动端-评论内容、提交评论 + * @Author zy + * @Date 2020/3/26 + */ +@Data +public class EpdcNoticeCommentSubmitFormDTO implements Serializable { + private static final long serialVersionUID = -8864248267071206774L; + + /** + * 被评论的内容ID + */ + @NotBlank(message = "被评论的内容ID不能为空") + private String noticeId; + + /** + * 父评论(被评论)ID + */ + private String faCommentId; + + /** + * 评论内容 + */ + @Size(min = 1, max = 500, message = "评论内容不能超过500字") + private String content; + + /** + * 评论人ID + */ + @NotNull(message = "评论人ID不能为空") + private String userId; + + /** + * 评论人昵称 + */ + private String userName; + + /** + * 评论人头像 + */ + private String userFace; + + /** + * 党员标识(0-否,1-是) + */ + private String partyFlag; + + + /** + *是否提交为内容待审核状态 + */ + private Boolean isConReview; + + /** + * 部门id + */ + private Long deptId; +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentListResultDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentListResultDTO.java new file mode 100644 index 00000000..b9701c6a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentListResultDTO.java @@ -0,0 +1,28 @@ +package com.elink.esua.epdc.dto.epdc.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + + +/** + * 移动端-新闻最新最热列表 + * @Author zy + * @Date 2020/3/26 + */ +@Data +public class EpdcNoticeCommentListResultDTO implements Serializable { + private static final long serialVersionUID = 6087794316919494277L; + + /** + * 表态数 + */ + private long statementNum; + + /** + * 最新最热 评论列表 + */ + private List commentsListResultDTO; + +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentUserInfoResultDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentUserInfoResultDTO.java new file mode 100644 index 00000000..04cdf3b0 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentUserInfoResultDTO.java @@ -0,0 +1,35 @@ +package com.elink.esua.epdc.dto.epdc.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 移动端-内容评论用户信息 + * @Author zy + * @Date 2020/3/26 + */ +@Data +public class EpdcNoticeCommentUserInfoResultDTO implements Serializable { + private static final long serialVersionUID = 6087794316919494277L; + + /** + * 用户ID + */ + private String userId; + + /** + * 用户名 + */ + private String userName; + + /** + * 用户头像 + */ + private String userFace; + + /** + * 党员标识(0-否,1-是) + */ + private String partyFlag; +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentsResultDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentsResultDTO.java new file mode 100644 index 00000000..3d981048 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeCommentsResultDTO.java @@ -0,0 +1,57 @@ +package com.elink.esua.epdc.dto.epdc.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 移动端-内容最新最热 评论列表 + * @Author zy + * @Date 2020/3/26 + */ +@Data +public class EpdcNoticeCommentsResultDTO implements Serializable { + private static final long serialVersionUID = 6087794316919494277L; + + /** + * 评论ID + */ + private String commentId; + /** + * 评论内容 + */ + private String content; + /** + * 时间 + */ + private String commentTime; + + /** + * 赞数 + */ + private Integer approveNum; + + /** + * 踩数 + */ + private Integer opposeNum; + + /** + * 用户信息 + */ + private EpdcNoticeCommentUserInfoResultDTO user; + + /** + * 回复评论信息 + */ + private EpdcNoticeReplyCommentResultDTO replyComment; + + /** + * 用户是否赞过,false未赞 + */ + private Boolean userLike; + /** + * 用户是否踩过,true踩 + */ + private Boolean userDislike; +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeReplyCommentResultDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeReplyCommentResultDTO.java new file mode 100644 index 00000000..2a61664a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcNoticeReplyCommentResultDTO.java @@ -0,0 +1,24 @@ +package com.elink.esua.epdc.dto.epdc.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 移动端-内容回复评论信息 + * @Author zy + * @Date 2020/3/26 + */ +@Data +public class EpdcNoticeReplyCommentResultDTO implements Serializable { + private static final long serialVersionUID = 6087794316919494277L; + + /** + * 用户名 + */ + private String userName; + /** + * 内容 + */ + private String content; +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/ModuleCategoryResultDTO.java b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/ModuleCategoryResultDTO.java index d49545dd..0bf3748f 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/ModuleCategoryResultDTO.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/ModuleCategoryResultDTO.java @@ -54,6 +54,11 @@ public class ModuleCategoryResultDTO implements Serializable { */ private String bannerFlag; + /** + * 内容评论标识 0-否,1-是 + */ + private String commentFlag; + /** * 备注 */ diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppNoticeController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppNoticeController.java index 49726fcc..016ab993 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppNoticeController.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/EpdcAppNoticeController.java @@ -20,13 +20,15 @@ package com.elink.esua.epdc.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.epdc.form.EpdcNoticeBrowseFormDTO; -import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeListFormDTO; +import com.elink.esua.epdc.dto.epdc.form.*; import com.elink.esua.epdc.dto.epdc.form.v2.EpdcNoticeListV2FormDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeCommentListResultDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeDetailResultDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeListResultDTO; +import com.elink.esua.epdc.service.NoticeCommentService; import com.elink.esua.epdc.service.NoticeService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -45,6 +47,9 @@ public class EpdcAppNoticeController { @Autowired private NoticeService noticeService; + @Autowired + private NoticeCommentService noticeCommentService; + /** * 移动端通知列表 * @@ -86,10 +91,9 @@ public class EpdcAppNoticeController { return this.noticeService.updateReadingAmount(formDto); } - /* + /** * 移动端通知列表接口 - v2 * - * @param userDetail * @param formDto * @return com.elink.esua.epdc.commons.tools.utils.Result> * @Author zhangyong @@ -99,4 +103,49 @@ public class EpdcAppNoticeController { public Result> listNotice(@RequestBody EpdcNoticeListV2FormDTO formDto) { return noticeService.listV2Notice(formDto); } + + /** + * 内容评论、回复提交 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:50 + */ + @PostMapping("comment/submit") + public Result noticeCommentSubmit(@RequestBody EpdcNoticeCommentSubmitFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return noticeCommentService.saveNoticeComment(formDto); + } + + /** + * 内容评论表态 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:55 + */ + @PostMapping("comment/statement") + public Result noticeCommentStatement(@RequestBody EpdcNoticeCommentStatementFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return noticeCommentService.noticeCommentStatement(formDto); + } + + /** + * 内容评论列表 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:57 + */ + @GetMapping("comment/list") + public Result listNoticeComments(@RequestBody EpdcNoticeCommentListFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + + return noticeCommentService.listNoticeComments(formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeCommentController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeCommentController.java new file mode 100644 index 00000000..379d0f59 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeCommentController.java @@ -0,0 +1,87 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.dto.NoticeCommentDTO; +import com.elink.esua.epdc.service.NoticeCommentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 内容评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@RestController +@RequestMapping("noticecomment") +public class NoticeCommentController { + + @Autowired + private NoticeCommentService noticeCommentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = noticeCommentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + NoticeCommentDTO data = noticeCommentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody NoticeCommentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + noticeCommentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody NoticeCommentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + noticeCommentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + noticeCommentService.delete(ids); + return new Result(); + } + +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeCommentUserAttitudeController.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeCommentUserAttitudeController.java new file mode 100644 index 00000000..aec367c5 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/controller/NoticeCommentUserAttitudeController.java @@ -0,0 +1,87 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.controller; + +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.commons.tools.validator.AssertUtils; +import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; +import com.elink.esua.epdc.dto.NoticeCommentUserAttitudeDTO; +import com.elink.esua.epdc.service.NoticeCommentUserAttitudeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 内容评论点赞点踩表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@RestController +@RequestMapping("noticecommentuserattitude") +public class NoticeCommentUserAttitudeController { + + @Autowired + private NoticeCommentUserAttitudeService noticeCommentUserAttitudeService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = noticeCommentUserAttitudeService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + NoticeCommentUserAttitudeDTO data = noticeCommentUserAttitudeService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody NoticeCommentUserAttitudeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + noticeCommentUserAttitudeService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody NoticeCommentUserAttitudeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + noticeCommentUserAttitudeService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + noticeCommentUserAttitudeService.delete(ids); + return new Result(); + } + +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeCommentDao.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeCommentDao.java new file mode 100644 index 00000000..a92b7a70 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeCommentDao.java @@ -0,0 +1,107 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentListFormDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeCommentsResultDTO; +import com.elink.esua.epdc.entity.NoticeCommentEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 内容评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@Mapper +public interface NoticeCommentDao extends BaseDao { + + /** + * 评论回复数加1 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 14:19 + */ + void updateReplyCount(String commentId); + + /** + * 更新内容评论支持数 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 14:52 + */ + void updateNoticeCommentApproveNum(String commentId); + + /** + * 更新内容评论反对数 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 14:52 + */ + void updateNoticeCommentOpposeNum(String commentId); + + /** + * 评论 赞数-1 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 15:02 + */ + void updateNoticeCommentApproveNumSubtract(String commentId); + + /** + * 评论 踩数-1 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 15:02 + */ + void updateNoticeCommentOpposeNumSubtract(String commentId); + + /** + * 内容评论的表态数 + * + * @param noticeId 内容ID + * @return long + * @author Liuchuang + * @since 2021/3/16 15:11 + */ + long selectCountOfNoticeCommentStatementNum(String noticeId); + + /** + * 内容评论列表 + * + * @param formDto 参数 + * @return java.util.List + * @author Liuchuang + * @since 2021/3/16 15:14 + */ + List selectListNoticeComments(EpdcNoticeCommentListFormDTO formDto); + +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeCommentUserAttitudeDao.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeCommentUserAttitudeDao.java new file mode 100644 index 00000000..818ad898 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeCommentUserAttitudeDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.entity.NoticeCommentUserAttitudeEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 内容评论点赞点踩表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@Mapper +public interface NoticeCommentUserAttitudeDao extends BaseDao { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDao.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDao.java index d7a6988a..b95c01da 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDao.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/NoticeDao.java @@ -138,4 +138,6 @@ public interface NoticeDao extends BaseDao { * @return java.util.List **/ List selectListOfNoticeDTO(Map params); + + void updateNoticeCommentNum(String id); } diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/ModuleCategoryEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/ModuleCategoryEntity.java index 673cadb5..521c7983 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/ModuleCategoryEntity.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/ModuleCategoryEntity.java @@ -91,6 +91,11 @@ public class ModuleCategoryEntity extends BaseEpdcEntity { */ private String enableFlag; + /** + * 内容评论标识 0-否,1-是 + */ + private String commentFlag; + /** * 上级部门名称 */ @@ -103,4 +108,4 @@ public class ModuleCategoryEntity extends BaseEpdcEntity { @TableField(exist = false) private String label; -} \ No newline at end of file +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeCommentEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeCommentEntity.java new file mode 100644 index 00000000..ccdb939d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeCommentEntity.java @@ -0,0 +1,121 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 内容评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_notice_comment") +public class NoticeCommentEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 内容ID + */ + private String noticeId; + + /** + * 评论人ID + */ + private String userId; + + /** + * 评论人昵称 + */ + private String userName; + + /** + * 评论人头像 + */ + private String userFace; + + /** + * 评论内容 + */ + private String content; + + /** + * 评论类型 0:评论,1:回复,2:回复的回复 + */ + private String commentType; + + /** + * 回复的评论ID + */ + private String commentId; + + /** + * 被回复数 + */ + private Integer replyCount; + + /** + * 被回复人ID + */ + private String replyUserId; + + /** + * 被回复人名称 + */ + private String replyUserName; + + /** + * 被回复人头像 + */ + private String replyUserFace; + + /** + * 点赞数 + */ + private Integer likeCount; + + /** + * 点踩数 + */ + private Integer unLikeCount; + + /** + * 屏蔽标识 0:未屏蔽,1:已屏蔽 + */ + private String shieldFlag; + + /** + * 0 未进行校验;1 微信校验通过;2 微信校验不通过;3 管理员校验通过;4 管理员校验不通过 + */ + private String sensitiveFlag; + + /** + * 党员标识(0-否,1-是) + */ + private String partyFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeCommentUserAttitudeEntity.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeCommentUserAttitudeEntity.java new file mode 100644 index 00000000..d91482e2 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/entity/NoticeCommentUserAttitudeEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 内容评论点赞点踩表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_notice_comment_user_attitude") +public class NoticeCommentUserAttitudeEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 内容评论ID + */ + private String noticeCommentId; + + /** + * 用户ID + */ + private String userId; + + /** + * 用户点赞点踩标识 0:点赞,1:点踩 + */ + private String attitudeFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeCommentService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeCommentService.java new file mode 100644 index 00000000..c8be9b65 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeCommentService.java @@ -0,0 +1,170 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.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.NoticeCommentDTO; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentListFormDTO; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentStatementFormDTO; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentSubmitFormDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeCommentListResultDTO; +import com.elink.esua.epdc.entity.NoticeCommentEntity; + +import java.util.List; +import java.util.Map; + +/** + * 内容评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +public interface NoticeCommentService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-03-16 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-03-16 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return NoticeCommentDTO + * @author generator + * @date 2021-03-16 + */ + NoticeCommentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-03-16 + */ + void save(NoticeCommentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-03-16 + */ + void update(NoticeCommentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-03-16 + */ + void delete(String[] ids); + + /** + * 内容评论、回复提交 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 11:18 + */ + Result saveNoticeComment(EpdcNoticeCommentSubmitFormDTO formDto); + + /** + * 内容评论表态 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:33 + */ + Result noticeCommentStatement(EpdcNoticeCommentStatementFormDTO formDto); + + /** + * 内容评论列表 + * + * @param formDto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author Liuchuang + * @since 2021/3/16 13:43 + */ + Result listNoticeComments(EpdcNoticeCommentListFormDTO formDto); + + /** + * 更新内容评论支持数 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 14:52 + */ + void updateNoticeCommentApproveNum(String commentId); + + /** + * 更新内容评论反对数 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 14:52 + */ + void updateNoticeCommentOpposeNum(String commentId); + + /** + * 评论 赞数-1 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 14:59 + */ + void updateNoticeCommentApproveNumSubtract(String commentId); + + /** + * 评论 踩数-1 + * + * @param commentId 评论ID + * @return void + * @author Liuchuang + * @since 2021/3/16 14:59 + */ + void updateNoticeCommentOpposeNumSubtract(String commentId); +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeCommentUserAttitudeService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeCommentUserAttitudeService.java new file mode 100644 index 00000000..3f73eabf --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeCommentUserAttitudeService.java @@ -0,0 +1,107 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.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.NoticeCommentUserAttitudeDTO; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentStatementFormDTO; +import com.elink.esua.epdc.entity.NoticeCommentUserAttitudeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 内容评论点赞点踩表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +public interface NoticeCommentUserAttitudeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-03-16 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-03-16 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return NoticeCommentUserAttitudeDTO + * @author generator + * @date 2021-03-16 + */ + NoticeCommentUserAttitudeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-03-16 + */ + void save(NoticeCommentUserAttitudeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-03-16 + */ + void update(NoticeCommentUserAttitudeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-03-16 + */ + void delete(String[] ids); + + /** + * 内容评论表态 + * + * @param formDto + * @return com.elink.esua.epdc.dto.NoticeCommentUserAttitudeDTO + * @author Liuchuang + * @since 2021/3/16 14:45 + */ + Result noticeCommentStatement(EpdcNoticeCommentStatementFormDTO formDto); +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java index 174f9535..b2008291 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/NoticeService.java @@ -22,9 +22,9 @@ import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.NoticeDTO; import com.elink.esua.epdc.dto.SysSimpleDictDTO; -import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeBrowseFormDTO; -import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeListFormDTO; +import com.elink.esua.epdc.dto.epdc.form.*; import com.elink.esua.epdc.dto.epdc.form.v2.EpdcNoticeListV2FormDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeCommentListResultDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeDetailResultDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeListResultDTO; import com.elink.esua.epdc.entity.NoticeEntity; @@ -171,10 +171,9 @@ public interface NoticeService extends BaseService { **/ Result> getListSimpleByDictType(String dictType); - /* + /** * 移动端通知列表接口 - v2 * - * @param userDetail * @param formDto * @return com.elink.esua.epdc.commons.tools.utils.Result> * @Author zhangyong @@ -189,4 +188,15 @@ public interface NoticeService extends BaseService { * @return com.elink.esua.epdc.commons.tools.page.PageData **/ PageData listPage(Map params); + + /** + * 内容评论数+1 + * + * @param id 内容ID + * @return void + * @author Liuchuang + * @since 2021/3/16 14:23 + */ + void updateNoticeCommentNum(String id); + } diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeCommentServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeCommentServiceImpl.java new file mode 100644 index 00000000..6e69490e --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeCommentServiceImpl.java @@ -0,0 +1,201 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.constant.NumConstant; +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.dao.NoticeCommentDao; +import com.elink.esua.epdc.dto.NoticeCommentDTO; +import com.elink.esua.epdc.dto.NoticeCommentUserAttitudeDTO; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentListFormDTO; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentStatementFormDTO; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentSubmitFormDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeCommentListResultDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeCommentsResultDTO; +import com.elink.esua.epdc.entity.NoticeCommentEntity; +import com.elink.esua.epdc.entity.NoticeCommentUserAttitudeEntity; +import com.elink.esua.epdc.service.NoticeCommentService; +import com.elink.esua.epdc.service.NoticeCommentUserAttitudeService; +import com.elink.esua.epdc.service.NoticeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 内容评论表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@Service +public class NoticeCommentServiceImpl extends BaseServiceImpl implements NoticeCommentService { + + @Autowired + private NoticeService noticeService; + + @Autowired + private NoticeCommentUserAttitudeService noticeCommentUserAttitudeService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, NoticeCommentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, NoticeCommentDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public NoticeCommentDTO get(String id) { + NoticeCommentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, NoticeCommentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(NoticeCommentDTO dto) { + NoticeCommentEntity entity = ConvertUtils.sourceToTarget(dto, NoticeCommentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(NoticeCommentDTO dto) { + NoticeCommentEntity entity = ConvertUtils.sourceToTarget(dto, NoticeCommentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result saveNoticeComment(EpdcNoticeCommentSubmitFormDTO formDto) { + NoticeCommentEntity commentEntity = new NoticeCommentEntity(); + commentEntity.setContent(formDto.getContent()); + commentEntity.setUserId(formDto.getUserId()); + commentEntity.setUserName(formDto.getUserName()); + commentEntity.setUserFace(formDto.getUserFace()); + commentEntity.setPartyFlag(formDto.getPartyFlag()); + commentEntity.setNoticeId(formDto.getNoticeId()); + + // 评论类型 0-评论 + String commentType = NumConstant.ZERO_STR; + // 父评论:用户回复的那条评论 + NoticeCommentEntity parentComment = null; + if (!StringUtils.isEmpty(formDto.getFaCommentId())) { + parentComment = baseDao.selectById(formDto.getFaCommentId()); + if (null == parentComment || null == parentComment.getId()) { + return new Result().error("您要回复的评论不存在"); + } + + commentType = NumConstant.ONE_STR; + commentEntity.setCommentId(formDto.getFaCommentId()); + commentEntity.setReplyUserId(parentComment.getUserId()); + commentEntity.setReplyUserName(parentComment.getUserName()); + commentEntity.setReplyUserFace(parentComment.getUserFace()); + } + commentEntity.setCommentType(commentType); + if (NumConstant.ONE != baseDao.insert(commentEntity)) { + return new Result().error("评论失败"); + } + // 回复加1 + if (NumConstant.ONE_STR.equals(commentType)) { + baseDao.updateReplyCount(formDto.getFaCommentId()); + } + // 内容评论数加1 + noticeService.updateNoticeCommentNum(commentEntity.getNoticeId()); + + return new Result(); + } + + @Override + public Result noticeCommentStatement(EpdcNoticeCommentStatementFormDTO formDto) { + return noticeCommentUserAttitudeService.noticeCommentStatement(formDto); + } + + @Override + public Result listNoticeComments(EpdcNoticeCommentListFormDTO formDto) { + // 表态数 + long statementNum = baseDao.selectCountOfNoticeCommentStatementNum(formDto.getNoticeId()); + int pageIndex = (formDto.getPageIndex() - NumConstant.ONE) * formDto.getPageSize(); + formDto.setPageIndex(pageIndex); + // 评论 + List list = baseDao.selectListNoticeComments(formDto); + EpdcNoticeCommentListResultDTO data = new EpdcNoticeCommentListResultDTO(); + data.setStatementNum(statementNum); + data.setCommentsListResultDTO(list); + return new Result().ok(data); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateNoticeCommentApproveNum(String commentId) { + baseDao.updateNoticeCommentApproveNum(commentId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateNoticeCommentOpposeNum(String commentId) { + baseDao.updateNoticeCommentOpposeNum(commentId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateNoticeCommentApproveNumSubtract(String commentId) { + baseDao.updateNoticeCommentApproveNumSubtract(commentId); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateNoticeCommentOpposeNumSubtract(String commentId) { + baseDao.updateNoticeCommentOpposeNumSubtract(commentId); + } + +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeCommentUserAttitudeServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeCommentUserAttitudeServiceImpl.java new file mode 100644 index 00000000..72b12eac --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeCommentUserAttitudeServiceImpl.java @@ -0,0 +1,163 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.constant.NumConstant; +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.dao.NoticeCommentUserAttitudeDao; +import com.elink.esua.epdc.dto.NoticeCommentUserAttitudeDTO; +import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeCommentStatementFormDTO; +import com.elink.esua.epdc.entity.NoticeCommentUserAttitudeEntity; +import com.elink.esua.epdc.service.NoticeCommentService; +import com.elink.esua.epdc.service.NoticeCommentUserAttitudeService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 内容评论点赞点踩表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-03-16 + */ +@Service +public class NoticeCommentUserAttitudeServiceImpl extends BaseServiceImpl implements NoticeCommentUserAttitudeService { + + @Autowired + private NoticeCommentService noticeCommentService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, NoticeCommentUserAttitudeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, NoticeCommentUserAttitudeDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public NoticeCommentUserAttitudeDTO get(String id) { + NoticeCommentUserAttitudeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, NoticeCommentUserAttitudeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(NoticeCommentUserAttitudeDTO dto) { + NoticeCommentUserAttitudeEntity entity = ConvertUtils.sourceToTarget(dto, NoticeCommentUserAttitudeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(NoticeCommentUserAttitudeDTO dto) { + NoticeCommentUserAttitudeEntity entity = ConvertUtils.sourceToTarget(dto, NoticeCommentUserAttitudeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result noticeCommentStatement(EpdcNoticeCommentStatementFormDTO formDto) { + // 获取用户表态记录 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(formDto.getUserId()), "USER_ID", formDto.getUserId()); + wrapper.eq(StringUtils.isNotBlank(formDto.getCommentId()), "NOTICE_COMMENT_ID", formDto.getCommentId()); + NoticeCommentUserAttitudeEntity attitudeEntity = baseDao.selectOne(wrapper); + if (NumConstant.ZERO_STR.equals(formDto.getAttitude()) || NumConstant.ONE_STR.equals(formDto.getAttitude())){ + if (attitudeEntity == null){ + //没有点赞或者点踩,直接插入数据 + NoticeCommentUserAttitudeDTO noticeCommentUserAttitudeDto = new NoticeCommentUserAttitudeDTO(); + noticeCommentUserAttitudeDto.setNoticeCommentId(formDto.getCommentId()); + noticeCommentUserAttitudeDto.setUserId(formDto.getUserId()); + noticeCommentUserAttitudeDto.setAttitudeFlag(formDto.getAttitude()); + this.save(noticeCommentUserAttitudeDto); + + if (NumConstant.ZERO_STR.equals(formDto.getAttitude())){ + noticeCommentService.updateNoticeCommentApproveNum(formDto.getCommentId()); + } + if (NumConstant.ONE_STR.equals(formDto.getAttitude())){ + noticeCommentService.updateNoticeCommentOpposeNum(formDto.getCommentId()); + } + + }else { + if (!formDto.getAttitude().equals(attitudeEntity.getAttitudeFlag())){ + attitudeEntity.setAttitudeFlag(formDto.getAttitude()); + this.updateById(attitudeEntity); + + if (NumConstant.ZERO_STR.equals(formDto.getAttitude())){ + //赞数加1 踩数减一 + noticeCommentService.updateNoticeCommentApproveNum(formDto.getCommentId()); + noticeCommentService.updateNoticeCommentOpposeNumSubtract(formDto.getCommentId()); + }else { + //踩数加一 赞数减一 + noticeCommentService.updateNoticeCommentOpposeNum(formDto.getCommentId()); + noticeCommentService.updateNoticeCommentApproveNumSubtract(formDto.getCommentId()); + } + } + } + }else { + //删除点赞或踩的记录,如果重新点赞或踩则重新插入 + this.deleteById(attitudeEntity.getId()); + if (NumConstant.TWO_STR.equals(formDto.getAttitude())){ + //取消赞 + noticeCommentService.updateNoticeCommentApproveNumSubtract(formDto.getCommentId()); + } + if (NumConstant.THREE_STR.equals(formDto.getAttitude())){ + //取消踩 + noticeCommentService.updateNoticeCommentOpposeNumSubtract(formDto.getCommentId()); + } + } + + return new Result(); + } + +} diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java index 4dcd7618..41cb8a80 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/NoticeServiceImpl.java @@ -34,9 +34,9 @@ import com.elink.esua.epdc.dao.NoticeDao; import com.elink.esua.epdc.dto.NoticeDTO; import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; import com.elink.esua.epdc.dto.SysSimpleDictDTO; -import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeBrowseFormDTO; -import com.elink.esua.epdc.dto.epdc.form.EpdcNoticeListFormDTO; +import com.elink.esua.epdc.dto.epdc.form.*; import com.elink.esua.epdc.dto.epdc.form.v2.EpdcNoticeListV2FormDTO; +import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeCommentListResultDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeDetailResultDTO; import com.elink.esua.epdc.dto.epdc.result.EpdcNoticeListResultDTO; import com.elink.esua.epdc.entity.ModuleCategoryEntity; @@ -397,4 +397,10 @@ public class NoticeServiceImpl extends BaseServiceImpl List list = baseDao.selectListOfNoticeDTO(params); return new PageData<>(list, page.getTotal()); } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateNoticeCommentNum(String id) { + baseDao.updateNoticeCommentNum(id); + } } diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/ModuleCategoryDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/ModuleCategoryDao.xml index d8108840..10181991 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/ModuleCategoryDao.xml +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/ModuleCategoryDao.xml @@ -61,6 +61,7 @@ IMG_URL, MODULE_STYLE, BANNER_FLAG, + COMMENT_FLAG, REMARK, SORT from epdc_module_category diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeCommentDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeCommentDao.xml new file mode 100644 index 00000000..467372d4 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeCommentDao.xml @@ -0,0 +1,124 @@ + + + + + + + UPDATE epdc_notice_comment + SET REPLY_COUNT = REPLY_COUNT + 1 + WHERE ID = #{commentId} + + + + UPDATE epdc_notice_comment + SET LIKE_COUNT = LIKE_COUNT + 1 + WHERE ID = #{commentId} + + + + + UPDATE epdc_notice_comment + SET UN_LIKE_COUNT = UN_LIKE_COUNT + 1 + WHERE ID = #{commentId} + + + + UPDATE epdc_notice_comment + SET LIKE_COUNT = LIKE_COUNT - 1 + WHERE ID = #{commentId} + + + + + UPDATE epdc_notice_comment + SET UN_LIKE_COUNT = UN_LIKE_COUNT - 1 + WHERE ID = #{commentId} + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeCommentUserAttitudeDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeCommentUserAttitudeDao.xml new file mode 100644 index 00000000..131af34b --- /dev/null +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeCommentUserAttitudeDao.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDao.xml b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDao.xml index 70cd7389..199128fa 100644 --- a/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDao.xml +++ b/esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/NoticeDao.xml @@ -182,4 +182,8 @@ order by t1.SORT, t1.RELEASE_TIME desc + + + UPDATE epdc_notice SET COMMENT_NUM = COMMENT_NUM + 1 WHERE ID = #{id} +