From 7d17cc0a4664ffde0231925c915b00739e64a127 Mon Sep 17 00:00:00 2001 From: liuchuang Date: Thu, 7 Nov 2019 17:40:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=AD=E8=AF=9D=E9=A2=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc/controller/ApiTopicController.java | 16 +++ .../esua/epdc/feign/TopicFeignClient.java | 13 +++ .../fallback/TopicFeignClientFallback.java | 6 ++ .../elink/esua/epdc/service/TopicService.java | 14 ++- .../epdc/service/impl/TopicServiceImpl.java | 10 ++ .../dto/constant/GroupNoticeConstant.java | 10 ++ .../dto/topic/TopicAuditRecordDTO.java | 86 +++++++++++++++ .../dto/topic/form/TopicCloseFormDTO.java | 37 +++++++ .../topic/controller/AppTopicController.java | 16 +++ .../topic/controller/TopicController.java | 17 +++ .../topic/dao/TopicAuditRecordDao.java | 33 ++++++ .../topic/entity/TopicAuditRecordEntity.java | 56 ++++++++++ .../service/TopicAuditRecordService.java | 95 +++++++++++++++++ .../modules/topic/service/TopicService.java | 12 +++ .../impl/TopicAuditRecordServiceImpl.java | 100 ++++++++++++++++++ .../topic/service/impl/TopicServiceImpl.java | 72 +++++++++++++ .../mapper/topic/TopicAuditRecordDao.xml | 20 ++++ 17 files changed, 612 insertions(+), 1 deletion(-) create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicAuditRecordDTO.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/form/TopicCloseFormDTO.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/dao/TopicAuditRecordDao.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/entity/TopicAuditRecordEntity.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicAuditRecordService.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicAuditRecordServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/resources/mapper/topic/TopicAuditRecordDao.xml diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTopicController.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTopicController.java index 6c8a4a68b..85e8beafe 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTopicController.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/controller/ApiTopicController.java @@ -4,6 +4,7 @@ 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.commons.tools.validator.ValidatorUtils; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; import com.elink.esua.epdc.service.TopicService; @@ -52,4 +53,19 @@ public class ApiTopicController { public Result detail(@PathVariable("id") String id) { return topicService.getTopicDetailById(id); } + + /** + * + * 关闭话题 + * + * @params [formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/7 16:10 + */ + @PostMapping("close") + public Result close(@LoginUser TokenDto userDetail, @RequestBody TopicCloseFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + return topicService.closeTopic(userDetail, formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/TopicFeignClient.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/TopicFeignClient.java index 095719792..75ad641fd 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/TopicFeignClient.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/TopicFeignClient.java @@ -2,6 +2,7 @@ package com.elink.esua.epdc.feign; import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; import com.elink.esua.epdc.feign.fallback.TopicFeignClientFallback; @@ -44,4 +45,16 @@ public interface TopicFeignClient { */ @GetMapping(value = "group/epdc-app/topic/detail/{id}", consumes = MediaType.APPLICATION_JSON_VALUE) Result detail(@PathVariable("id") String id); + + /** + * + * 关闭话题 + * + * @params [formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/7 16:14 + */ + @PostMapping(value = "group/epdc-app/topic/close", consumes = MediaType.APPLICATION_JSON_VALUE) + Result close(TopicCloseFormDTO formDto); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/TopicFeignClientFallback.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/TopicFeignClientFallback.java index 8e4ce186c..ff9e8532e 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/TopicFeignClientFallback.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/feign/fallback/TopicFeignClientFallback.java @@ -3,6 +3,7 @@ package com.elink.esua.epdc.feign.fallback; import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; import com.elink.esua.epdc.feign.TopicFeignClient; @@ -24,4 +25,9 @@ public class TopicFeignClientFallback implements TopicFeignClient { public Result detail(String id) { return ModuleUtils.feignConError(ServiceConstant.EPDC_GROUP_SERVER, "detail", id); } + + @Override + public Result close(TopicCloseFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_GROUP_SERVER, "close", formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/TopicService.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/TopicService.java index 45a6d6b95..1bc8a3555 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/TopicService.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/TopicService.java @@ -2,6 +2,7 @@ package com.elink.esua.epdc.service; import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; @@ -27,7 +28,7 @@ public interface TopicService { /** * - * 移动端-话题详情 + * 话题详情 * * @params [id] * @return com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO @@ -35,4 +36,15 @@ public interface TopicService { * @since 2019/11/7 15:34 */ Result getTopicDetailById(String id); + + /** + * + * 关闭话题 + * + * @params [userDetail, formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/7 16:11 + */ + Result closeTopic(TokenDto userDetail, TopicCloseFormDTO formDto); } diff --git a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/TopicServiceImpl.java b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/TopicServiceImpl.java index a3e005d0b..ef3960a28 100644 --- a/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/TopicServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/TopicServiceImpl.java @@ -4,6 +4,7 @@ import com.elink.esua.epdc.common.token.dto.TokenDto; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.CompleteDeptDTO; import com.elink.esua.epdc.dto.enums.TopicStateEnum; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; import com.elink.esua.epdc.feign.AdminFeignClient; @@ -59,4 +60,13 @@ public class TopicServiceImpl implements TopicService { public Result getTopicDetailById(String id) { return topicFeignClient.detail(id); } + + @Override + public Result closeTopic(TokenDto userDetail, TopicCloseFormDTO formDto) { + if (null == userDetail) { + return new Result().error("获取用户信息失败"); + } + formDto.setUserId(userDetail.getUserId()); + return topicFeignClient.close(formDto); + } } diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/GroupNoticeConstant.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/GroupNoticeConstant.java index c7915a960..9d7baf898 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/GroupNoticeConstant.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/constant/GroupNoticeConstant.java @@ -64,6 +64,11 @@ public interface GroupNoticeConstant { */ String NOTICE_GROUP_QUIT = "已退出社群"; + /** + * 话题关闭 + */ + String NOTICE_GROUP_TOPIC_CLOSED = "话题关闭"; + /** * 我的消息类型:0审核通知 */ @@ -118,4 +123,9 @@ public interface GroupNoticeConstant { * 入群申请未通过 */ String NOTICE_BUSINESS_TYPE_GROUP_USER_REVIEW_NOT_PASS = "groupUserReviewNotPass"; + + /** + * 话题关闭 + */ + String NOTICE_BUSINESS_TYPE_GROUP_TOPIC_CLOSED = "groupTopicClosed"; } diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicAuditRecordDTO.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicAuditRecordDTO.java new file mode 100644 index 000000000..2ed155f29 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/TopicAuditRecordDTO.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.topic; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 话题审核记录表 话题审核记录表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-11-07 + */ +@Data +public class TopicAuditRecordDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 话题ID + */ + private String topicId; + + /** + * 状态 0:审核不通过,1:审核通过,2:已关闭 + */ + private Integer state; + + /** + * 处理意见 + */ + private String processingOpinions; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 删除标记 + */ + private String delFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/form/TopicCloseFormDTO.java b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/form/TopicCloseFormDTO.java new file mode 100644 index 000000000..18036ceda --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-client/src/main/java/com.elink.esua.epdc/dto/topic/form/TopicCloseFormDTO.java @@ -0,0 +1,37 @@ +package com.elink.esua.epdc.dto.topic.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; + +/** + * + * 关闭话题Form DTO + * + * @Author:liuchuang + * @Date:2019/11/7 16:07 + */ +@Data +public class TopicCloseFormDTO implements Serializable { + private static final long serialVersionUID = -8847567240714882803L; + + /** + * 话题ID + */ + @NotBlank(message = "话题ID不能为空") + private String id; + + /** + * 关闭原因 + */ + @NotBlank(message = "关闭原因不能为空且在50字以内") + @Size(min = 1, max = 50, message = "关闭原因不能为空且在50字以内") + private String processingOpinions; + + /** + * 操作人ID + */ + private String userId; +} diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/AppTopicController.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/AppTopicController.java index 6c885920e..069610938 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/AppTopicController.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/AppTopicController.java @@ -1,7 +1,9 @@ package com.elink.esua.epdc.modules.topic.controller; import com.elink.esua.epdc.commons.tools.constant.Constant; +import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; import com.elink.esua.epdc.modules.topic.service.TopicService; @@ -50,4 +52,18 @@ public class AppTopicController { TopicDetailResultDTO data = topicService.getTopicDetailById(id); return new Result().ok(data); } + + /** + * + * 关闭话题 + * + * @params [formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/7 16:14 + */ + @PostMapping("close") + public Result close(@RequestBody TopicCloseFormDTO formDto) { + return topicService.modifyTopicState(formDto, NumConstant.ZERO_STR); + } } diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/TopicController.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/TopicController.java index 301c7a695..87ff1ce7c 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/TopicController.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/controller/TopicController.java @@ -17,6 +17,7 @@ package com.elink.esua.epdc.modules.topic.controller; +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.ExcelUtils; import com.elink.esua.epdc.commons.tools.utils.Result; @@ -26,6 +27,7 @@ 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.topic.TopicDTO; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.modules.topic.excel.TopicExcel; import com.elink.esua.epdc.modules.topic.service.TopicService; import org.springframework.beans.factory.annotation.Autowired; @@ -91,4 +93,19 @@ public class TopicController { ExcelUtils.exportExcelToTarget(response, null, list, TopicExcel.class); } + /** + * + * 关闭话题 + * + * @params [formDto] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/7 17:39 + */ + @PostMapping("close") + public Result close(@RequestBody TopicCloseFormDTO formDto) { + ValidatorUtils.validateEntity(formDto); + return topicService.modifyTopicState(formDto, NumConstant.ONE_STR); + } + } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/dao/TopicAuditRecordDao.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/dao/TopicAuditRecordDao.java new file mode 100644 index 000000000..05c275999 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/dao/TopicAuditRecordDao.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.modules.topic.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.topic.entity.TopicAuditRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 话题审核记录表 话题审核记录表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-11-07 + */ +@Mapper +public interface TopicAuditRecordDao extends BaseDao { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/entity/TopicAuditRecordEntity.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/entity/TopicAuditRecordEntity.java new file mode 100644 index 000000000..5f0ffae59 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/entity/TopicAuditRecordEntity.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.modules.topic.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 2019-11-07 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_topic_audit_record") +public class TopicAuditRecordEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 话题ID + */ + private String topicId; + + /** + * 状态 0:审核不通过,1:审核通过,2:已关闭 + */ + private Integer state; + + /** + * 处理意见 + */ + private String processingOpinions; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicAuditRecordService.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicAuditRecordService.java new file mode 100644 index 000000000..1a23bbb50 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicAuditRecordService.java @@ -0,0 +1,95 @@ +/** + * 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.modules.topic.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.dto.topic.TopicAuditRecordDTO; +import com.elink.esua.epdc.modules.topic.entity.TopicAuditRecordEntity; + +import java.util.List; +import java.util.Map; + +/** + * 话题审核记录表 话题审核记录表 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-11-07 + */ +public interface TopicAuditRecordService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2019-11-07 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2019-11-07 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return TopicAuditRecordDTO + * @author generator + * @date 2019-11-07 + */ + TopicAuditRecordDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2019-11-07 + */ + void save(TopicAuditRecordDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2019-11-07 + */ + void update(TopicAuditRecordDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2019-11-07 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicService.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicService.java index 9dd9855db..471cf223f 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicService.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/TopicService.java @@ -21,6 +21,7 @@ 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.topic.TopicDTO; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; import com.elink.esua.epdc.modules.topic.entity.TopicEntity; @@ -123,4 +124,15 @@ public interface TopicService extends BaseService { * @since 2019/11/7 15:34 */ TopicDetailResultDTO getTopicDetailById(String id); + + /** + * + * 关闭话题 + * + * @params [formDto, operatorUser(操作人:0-群主,1-网格长)] + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author liuchuang + * @since 2019/11/7 16:50 + */ + Result modifyTopicState(TopicCloseFormDTO formDto, String operatorUser); } diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicAuditRecordServiceImpl.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicAuditRecordServiceImpl.java new file mode 100644 index 000000000..3b40276c0 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicAuditRecordServiceImpl.java @@ -0,0 +1,100 @@ +/** + * 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.modules.topic.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.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.dto.topic.TopicAuditRecordDTO; +import com.elink.esua.epdc.modules.topic.dao.TopicAuditRecordDao; +import com.elink.esua.epdc.modules.topic.entity.TopicAuditRecordEntity; +import com.elink.esua.epdc.modules.topic.service.TopicAuditRecordService; +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 2019-11-07 + */ +@Service +public class TopicAuditRecordServiceImpl extends BaseServiceImpl implements TopicAuditRecordService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, TopicAuditRecordDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, TopicAuditRecordDTO.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 TopicAuditRecordDTO get(String id) { + TopicAuditRecordEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, TopicAuditRecordDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(TopicAuditRecordDTO dto) { + TopicAuditRecordEntity entity = ConvertUtils.sourceToTarget(dto, TopicAuditRecordEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TopicAuditRecordDTO dto) { + TopicAuditRecordEntity entity = ConvertUtils.sourceToTarget(dto, TopicAuditRecordEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicServiceImpl.java b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicServiceImpl.java index 825c8948c..d7d2a546e 100644 --- a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/java/com.elink.esua.epdc/modules/topic/service/impl/TopicServiceImpl.java @@ -21,15 +21,29 @@ 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.FieldConstant; +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.utils.Result; +import com.elink.esua.epdc.dto.constant.GroupNoticeConstant; import com.elink.esua.epdc.dto.constant.TopicImageConstant; +import com.elink.esua.epdc.dto.enums.GroupStateEnum; +import com.elink.esua.epdc.dto.enums.GroupUserStateEnum; +import com.elink.esua.epdc.dto.enums.TopicStateEnum; +import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO; +import com.elink.esua.epdc.dto.group.GroupDTO; +import com.elink.esua.epdc.dto.group.UserGroupDTO; import com.elink.esua.epdc.dto.topic.TopicDTO; +import com.elink.esua.epdc.dto.topic.form.TopicCloseFormDTO; import com.elink.esua.epdc.dto.topic.form.TopicSubmitFormDTO; import com.elink.esua.epdc.dto.topic.result.TopicDetailResultDTO; +import com.elink.esua.epdc.modules.async.NewsTask; +import com.elink.esua.epdc.modules.group.service.GroupService; +import com.elink.esua.epdc.modules.group.service.UserGroupService; import com.elink.esua.epdc.modules.topic.dao.TopicDao; +import com.elink.esua.epdc.modules.topic.entity.TopicAuditRecordEntity; import com.elink.esua.epdc.modules.topic.entity.TopicEntity; +import com.elink.esua.epdc.modules.topic.service.TopicAuditRecordService; import com.elink.esua.epdc.modules.topic.service.TopicImgService; import com.elink.esua.epdc.modules.topic.service.TopicService; import org.apache.commons.lang3.StringUtils; @@ -53,6 +67,18 @@ public class TopicServiceImpl extends BaseServiceImpl imp @Autowired private TopicImgService topicImgService; + @Autowired + private UserGroupService userGroupService; + + @Autowired + private GroupService groupService; + + @Autowired + private TopicAuditRecordService topicAuditRecordService; + + @Autowired + private NewsTask newsTask; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -127,4 +153,50 @@ public class TopicServiceImpl extends BaseServiceImpl imp return baseDao.selectOneOfTopicDetailById(id); } + @Override + @Transactional(rollbackFor = Exception.class) + public Result modifyTopicState(TopicCloseFormDTO formDto, String operatorUser) { + TopicDTO topicDto = get(formDto.getId()); + // 获取社群信息 + GroupDTO groupDto = groupService.get(topicDto.getGroupId()); + if (GroupStateEnum.GROUP_STATE_DISBANDED.getValue().equals(groupDto.getState())) { + return new Result().error("社群已解散,不可以关闭话题"); + } + // 群主关闭话题 + if (NumConstant.ZERO_STR.equals(operatorUser)) { + // 获取用户信息 + UserGroupDTO userDto = userGroupService.getGroupUserInfo(topicDto.getGroupId(), formDto.getUserId(), GroupUserStateEnum.GROUP_USER_STATE_EXAMINATION_PASSED.getValue()); + if (null == userDto || !NumConstant.ONE_STR.equals(userDto.getLordFlag())) { + return new Result().error("您不是群主,不可以关闭话题"); + } + } + + TopicEntity entity = new TopicEntity(); + entity.setId(formDto.getId()); + entity.setState(TopicStateEnum.TOPIC_STATE_CLOSED.getValue()); + if (updateById(entity)) { + // 插入话题操作记录表 + TopicAuditRecordEntity auditRecordEntity = new TopicAuditRecordEntity(); + auditRecordEntity.setTopicId(formDto.getId()); + auditRecordEntity.setState(NumConstant.TWO); + auditRecordEntity.setProcessingOpinions(formDto.getProcessingOpinions()); + topicAuditRecordService.insert(auditRecordEntity); + + // 发送消息通知 + EpdcInformationFormDTO informationFormDTO = new EpdcInformationFormDTO(); + informationFormDTO.setType(GroupNoticeConstant.NOTICE_TYPE_INTERACTIVE_NOTICE); + informationFormDTO.setTitle(GroupNoticeConstant.NOTICE_GROUP_TOPIC_CLOSED); + informationFormDTO.setContent(topicDto.getTopicContent()); + informationFormDTO.setBusinessId(topicDto.getId()); + informationFormDTO.setUserId(topicDto.getUserId()); + informationFormDTO.setBusinessType(GroupNoticeConstant.NOTICE_BUSINESS_TYPE_GROUP_TOPIC_CLOSED); + informationFormDTO.setRelBusinessContent("关闭原因:"+formDto.getProcessingOpinions()); + + // 发送通知 + newsTask.insertUserInformation(informationFormDTO); + return new Result(); + } + return new Result().error(); + } + } diff --git a/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/resources/mapper/topic/TopicAuditRecordDao.xml b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/resources/mapper/topic/TopicAuditRecordDao.xml new file mode 100644 index 000000000..912a5f133 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-group/epdc-group-server/src/main/resources/mapper/topic/TopicAuditRecordDao.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file