diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/TopicConstant.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/TopicConstant.java index 3ae0ec6aa0..5c4d550dfd 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/TopicConstant.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/TopicConstant.java @@ -87,4 +87,16 @@ public interface TopicConstant { String FILE_DOC = "doc"; String FILE_VOICE = "voice"; String FILE_VIDEO = "video"; + + String AUDITING = "auditing"; + String AUTO_PASSED = "auto_passed"; + String REVIEW = "review"; + String BLOCK = "block"; + String REJECTED = "rejected"; + String APPROVED = "approved"; + String SUBMIT = "submit"; + String IMAGE = " image"; + String VIDEO = " video"; + String VOICE = " voice"; + String DOC = " doc"; } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/TopicDraftScanTaskDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/TopicDraftScanTaskDTO.java new file mode 100644 index 0000000000..620f56d7ec --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/TopicDraftScanTaskDTO.java @@ -0,0 +1,104 @@ +/** + * 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.epmet.resi.group.dto.topic; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 话题附件检测任务表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-12-18 + */ +@Data +public class TopicDraftScanTaskDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户id + */ + private String customerId; + + /** + * 话题草稿Id + */ + private String topicDraftId; + + /** + * 话题草稿附件表Id,对应dataId + */ + private String topicDraftAttachmentId; + + /** + * 阿里云审核任务Id + */ + private String taskId; + + /** + * 审核状态【auditing: 审核中; +auto_passed: 自动通过; +review:结果不确定,需要人工审核; +block: 结果违规;】 + */ + private String status; + + /** + * 附件类型(视频 - video、 语音 - voice) + */ + private String attachmentType; + + /** + * 删除标记 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 操作人,API审核结果,存储为SCAN_USER或者APP_USER + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/AuditDraftTopicFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/AuditDraftTopicFormDTO.java new file mode 100644 index 0000000000..0605d39acb --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/AuditDraftTopicFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.resi.group.dto.topic.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/12/18 15:03 + */ +@NoArgsConstructor +@Data +public class AuditDraftTopicFormDTO implements Serializable { + + private static final long serialVersionUID = -4766725540339231386L; + /** + * 草稿话题Id + */ + @NotBlank(message = "话题id不能为空") + private String topicDraftId; + /** + * 审核状态(通过:approved 驳回:rejected) + */ + @NotBlank(message = "审核状态不能为空") + private String auditType; + /** + * 审核原因 + */ + private String reason; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/CreateTopicFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/CreateTopicFormDTO.java new file mode 100644 index 0000000000..a53a8f36db --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/CreateTopicFormDTO.java @@ -0,0 +1,78 @@ +package com.epmet.resi.group.dto.topic.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/12/17 15:08 + */ +@Data +public class CreateTopicFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String customerId; + + private String gridId; + /** + * 小组Id + * */ + @NotBlank(message = "小组Id不能为空") + private String groupId; + + private String topicDraftId; + + private String topicContent; + + /** + * 经度 + * */ + private String longitude; + + /** + * 纬度 + * */ + private String dimension; + + /** + * 地址 + * */ + @NotBlank(message = "地址信息不能为空") + private String address; + + /** + * 省份 + * */ + private String province; + + /** + * 城市 + * */ + private String city; + + /** + * 地区 + * */ + private String area; + + /** + * 图片附件 + */ + private List imageList; + /** + * 文件附件 + */ + private List docList; + /** + * 语音附件 + */ + private List voiceList; + /** + * 视频附件 + */ + private List videoList; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/DraftDetailFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/DraftDetailFormDTO.java new file mode 100644 index 0000000000..e57f420d19 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/DraftDetailFormDTO.java @@ -0,0 +1,18 @@ +package com.epmet.resi.group.dto.topic.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/12/18 14:53 + */ +@Data +public class DraftDetailFormDTO implements Serializable { + private static final long serialVersionUID = -240658534604688292L; + @NotBlank(message = "话题id不能为空") + private String topicDraftId; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/MyAuditingTopicFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/MyAuditingTopicFormDTO.java new file mode 100644 index 0000000000..47f2d7dd83 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/MyAuditingTopicFormDTO.java @@ -0,0 +1,22 @@ +package com.epmet.resi.group.dto.topic.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/12/18 14:44 + */ +@NoArgsConstructor +@Data +public class MyAuditingTopicFormDTO implements Serializable { + + private static final long serialVersionUID = 9154103669944393282L; + private String customerId; + private String userId; + private Integer pageNo = 1; + private Integer pageSize = 20; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/TopicAuditFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/TopicAuditFormDTO.java new file mode 100644 index 0000000000..ba57670521 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/TopicAuditFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.resi.group.dto.topic.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/12/18 14:22 + */ +@NoArgsConstructor +@Data +public class TopicAuditFormDTO extends PageFormDTO implements Serializable { + + private static final long serialVersionUID = 2013373278734345918L; + /** + * 小组ID + */ + @NotBlank(message = "小组id不能为空") + private String groupId; + /** + * 审核状态(待审核:review 已驳回:rejected) + */ + @NotBlank(message = "审核状态不能为空") + private String status; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/DraftDetailResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/DraftDetailResultDTO.java new file mode 100644 index 0000000000..f6373df659 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/DraftDetailResultDTO.java @@ -0,0 +1,57 @@ +package com.epmet.resi.group.dto.topic.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/12/18 14:50 + */ +@NoArgsConstructor +@Data +public class DraftDetailResultDTO implements Serializable { + + private static final long serialVersionUID = -7445417689558651158L; + /** + * 话题草稿id + */ + private String topicDraftId; + /** + * 话题内容 + */ + private String topicContent; + /** + * 发布时间yyyy-MM-dd HH:mm + */ + private String releaseTime; + /** + * 发布人头像 + */ + private String releaseUserHeadPhoto; + /** + * 发布人名称 + */ + private String releaseUserName; + /** + * 发布地址 + */ + private String releaseAddress; + /** + * 驳回理由 + */ + private String reason; + /** + * 图片附件集合 + */ + private List imageList; + private List docList; + /** + * 音频附件集合 + */ + private List voiceList; + private List videoList; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/MyAuditingTopicResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/MyAuditingTopicResultDTO.java new file mode 100644 index 0000000000..efdb157adf --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/MyAuditingTopicResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.resi.group.dto.topic.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/12/18 14:41 + */ +@Data +public class MyAuditingTopicResultDTO implements Serializable { + private static final long serialVersionUID = -2876904175308968430L; + private String topicDraftId; + private String groupId; + private Long releaseTime; + private String topicContent; + private String releaseGroupName; + private String releaseGridId; + private String releaseGridName; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/TopicAuditResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/TopicAuditResultDTO.java new file mode 100644 index 0000000000..d18a8ab0d5 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/result/TopicAuditResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.resi.group.dto.topic.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/12/18 14:28 + */ +@NoArgsConstructor +@Data +public class TopicAuditResultDTO { + + /** + * 话题草稿id + */ + private String topicDraftId; + /** + * 话题内容 + */ + private String topicContent; + /** + * 组成员显示名称 + */ + private String userName; + /** + * 话题草稿的发布时间戳 + */ + private Long releaseTime; +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/TopicDraftController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/TopicDraftController.java index ca60f2e453..1e01ad76a5 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/TopicDraftController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/TopicDraftController.java @@ -30,8 +30,10 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.modules.topic.excel.TopicDraftExcel; import com.epmet.modules.topic.service.TopicDraftService; import com.epmet.resi.group.dto.topic.TopicDraftDTO; -import com.epmet.resi.group.dto.topic.form.MyAuditingListFormDTO; +import com.epmet.resi.group.dto.topic.form.*; +import com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO; import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; +import com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -95,6 +97,77 @@ public class TopicDraftController { ExcelUtils.exportExcelToTarget(response, null, list, TopicDraftExcel.class); } + /** + * 发布话题 + * @author zhaoqifeng + * @date 2020/12/17 15:49 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("createtopic") + public Result createTopic(@LoginUser TokenDto tokenDto, @RequestBody CreateTopicFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + topicDraftService.createTopic(tokenDto, formDTO); + return new Result(); + } + + /** + * 组管理界面-待审核/已驳回列表 + * @author zhaoqifeng + * @date 2020/12/18 14:32 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("auditlist") + public Result> auditList(@RequestBody TopicAuditFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + List result = topicDraftService.auditList(formDTO); + return new Result>().ok(result); + } + + /** + * 话题草稿详情 + * @author zhaoqifeng + * @date 2020/12/18 14:55 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("detail") + public Result detail(@RequestBody DraftDetailFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + DraftDetailResultDTO result = topicDraftService.detail(formDTO); + return new Result().ok(result); + } + + /** + * 删除已驳回话题 + * @author zhaoqifeng + * @date 2020/12/18 14:57 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("del") + public Result deleteDraft(@RequestBody DraftDetailFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + topicDraftService.deleteDraft(formDTO); + return new Result(); + } + + /** + * 组长审核 + * @author zhaoqifeng + * @date 2020/12/18 15:06 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("audit") + public Result audit(@RequestBody AuditDraftTopicFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + topicDraftService.audit(formDTO); + return new Result(); + } + /** * @param formDTO * @return diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftAttachmentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftAttachmentDao.java index a41c95d420..0f0340e86d 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftAttachmentDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftAttachmentDao.java @@ -20,6 +20,9 @@ package com.epmet.modules.topic.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.modules.topic.entity.TopicDraftAttachmentEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 话题草稿附件表 @@ -29,5 +32,13 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface TopicDraftAttachmentDao extends BaseDao { - + /** + * 获取附件列表 + * @author zhaoqifeng + * @date 2020/12/18 16:44 + * @param topicDraftId + * @param type + * @return java.util.List + */ + List selectFileUrls(@Param("topicDraftId") String topicDraftId, @Param("type") String type); } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftDao.java index 0ccebb0a33..099a93ffe7 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftDao.java @@ -19,9 +19,15 @@ package com.epmet.modules.topic.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.modules.topic.entity.TopicDraftEntity; +import com.epmet.resi.group.dto.topic.TopicDraftDTO; +import com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO; +import com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO; import com.epmet.resi.group.dto.topic.form.MyAuditingListFormDTO; import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; import java.util.List; @@ -33,6 +39,24 @@ import java.util.List; */ @Mapper public interface TopicDraftDao extends BaseDao { + /** + * 获取小组待审核/已驳回列表 + * @author zhaoqifeng + * @date 2020/12/18 15:47 + * @param groupId + * @param status + * @return com.epmet.resi.group.dto.topic.TopicDraftDTO + */ + List selectTopicDraftByGroup(@Param("groupId") String groupId, @Param("status") String status); + + /** + * 话题草稿详情 + * @author zhaoqifeng + * @date 2020/12/18 16:19 + * @param topicDraftId + * @return com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO + */ + DraftDetailResultDTO selectTopicDraftDetail(@Param("topicDraftId") String topicDraftId); /** * @param formDTO diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftScanTaskDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftScanTaskDao.java new file mode 100644 index 0000000000..7181ae4308 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/TopicDraftScanTaskDao.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.epmet.modules.topic.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.topic.entity.TopicDraftScanTaskEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 话题附件检测任务表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-12-18 + */ +@Mapper +public interface TopicDraftScanTaskDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/TopicDraftScanTaskEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/TopicDraftScanTaskEntity.java new file mode 100644 index 0000000000..9e0cdbbaea --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/TopicDraftScanTaskEntity.java @@ -0,0 +1,74 @@ +/** + * 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.epmet.modules.topic.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 话题附件检测任务表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-12-18 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("topic_draft_scan_task") +public class TopicDraftScanTaskEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * 话题草稿Id + */ + private String topicDraftId; + + /** + * 话题草稿附件表Id,对应dataId + */ + private String topicDraftAttachmentId; + + /** + * 阿里云审核任务Id + */ + private String taskId; + + /** + * 审核状态【auditing: 审核中; +auto_passed: 自动通过; +review:结果不确定,需要人工审核; +block: 结果违规;】 + */ + private String status; + + /** + * 附件类型(视频 - video、 语音 - voice) + */ + private String attachmentType; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftAttachmentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftAttachmentService.java index 6a40eb8236..182d330f42 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftAttachmentService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftAttachmentService.java @@ -92,4 +92,14 @@ public interface TopicDraftAttachmentService extends BaseService + */ + List getFileList(String topicDraftId, String type); } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftScanTaskService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftScanTaskService.java new file mode 100644 index 0000000000..795b939b90 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftScanTaskService.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.epmet.modules.topic.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.modules.topic.entity.TopicDraftScanTaskEntity; +import com.epmet.resi.group.dto.topic.TopicDraftScanTaskDTO; + +import java.util.List; +import java.util.Map; + +/** + * 话题附件检测任务表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-12-18 + */ +public interface TopicDraftScanTaskService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-12-18 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-12-18 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return TopicDraftScanTaskDTO + * @author generator + * @date 2020-12-18 + */ + TopicDraftScanTaskDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-12-18 + */ + void save(TopicDraftScanTaskDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-12-18 + */ + void update(TopicDraftScanTaskDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-12-18 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftService.java index 467553bb0c..fbf72c76f5 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftService.java @@ -19,8 +19,13 @@ package com.epmet.modules.topic.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.modules.topic.entity.TopicDraftEntity; import com.epmet.resi.group.dto.topic.TopicDraftDTO; +import com.epmet.resi.group.dto.topic.form.*; +import com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO; +import com.epmet.resi.group.dto.topic.result.MyAuditingTopicResultDTO; +import com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO; import com.epmet.resi.group.dto.topic.form.MyAuditingListFormDTO; import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; @@ -95,6 +100,52 @@ public interface TopicDraftService extends BaseService { */ void delete(String[] ids); + /** + * 发布话题 + * @author zhaoqifeng + * @date 2020/12/17 15:49 + * @param tokenDto + * @param formDTO + * @return void + */ + void createTopic(TokenDto tokenDto, CreateTopicFormDTO formDTO); + + /** + * 组管理界面-待审核/已驳回列表 + * @author zhaoqifeng + * @date 2020/12/18 14:34 + * @param formDTO + * @return java.util.List + */ + List auditList(TopicAuditFormDTO formDTO); + + /** + * 话题草稿详情 + * @author zhaoqifeng + * @date 2020/12/18 14:55 + * @param formDTO + * @return com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO + */ + DraftDetailResultDTO detail(DraftDetailFormDTO formDTO); + + /** + * 删除已驳回话题 + * @author zhaoqifeng + * @date 2020/12/18 14:58 + * @param formDTO + * @return void + */ + void deleteDraft(DraftDetailFormDTO formDTO); + + /** + * 组长审核 + * @author zhaoqifeng + * @date 2020/12/18 15:06 + * @param formDTO + * @return void + */ + void audit(AuditDraftTopicFormDTO formDTO); + /** * @param formDTO * @return diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftAttachmentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftAttachmentServiceImpl.java index d34c50fe70..e1ad2d3b4e 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftAttachmentServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftAttachmentServiceImpl.java @@ -27,11 +27,13 @@ import com.epmet.modules.topic.dao.TopicDraftAttachmentDao; import com.epmet.modules.topic.entity.TopicDraftAttachmentEntity; import com.epmet.modules.topic.service.TopicDraftAttachmentService; import com.epmet.resi.group.dto.topic.TopicDraftAttachmentDTO; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -96,4 +98,22 @@ public class TopicDraftAttachmentServiceImpl extends BaseServiceImpl + * @author zhaoqifeng + * @date 2020/12/18 16:42 + */ + @Override + public List getFileList(String topicDraftId, String type) { + List list = baseDao.selectFileUrls(topicDraftId, type); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list; + } + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftScanTaskServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftScanTaskServiceImpl.java new file mode 100644 index 0000000000..8fbe37abcb --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftScanTaskServiceImpl.java @@ -0,0 +1,99 @@ +/** + * 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.epmet.modules.topic.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.modules.topic.dao.TopicDraftScanTaskDao; +import com.epmet.modules.topic.entity.TopicDraftScanTaskEntity; +import com.epmet.modules.topic.service.TopicDraftScanTaskService; +import com.epmet.resi.group.dto.topic.TopicDraftScanTaskDTO; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 话题附件检测任务表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-12-18 + */ +@Service +public class TopicDraftScanTaskServiceImpl extends BaseServiceImpl implements TopicDraftScanTaskService { + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, TopicDraftScanTaskDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, TopicDraftScanTaskDTO.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 TopicDraftScanTaskDTO get(String id) { + TopicDraftScanTaskEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, TopicDraftScanTaskDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(TopicDraftScanTaskDTO dto) { + TopicDraftScanTaskEntity entity = ConvertUtils.sourceToTarget(dto, TopicDraftScanTaskEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TopicDraftScanTaskDTO dto) { + TopicDraftScanTaskEntity entity = ConvertUtils.sourceToTarget(dto, TopicDraftScanTaskEntity.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/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java index b216097a86..b3bcca8b1e 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java @@ -22,27 +22,69 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.scan.param.ImgScanParamDTO; +import com.epmet.commons.tools.scan.param.ImgTaskDTO; +import com.epmet.commons.tools.scan.param.TextScanParamDTO; +import com.epmet.commons.tools.scan.param.TextTaskDTO; +import com.epmet.commons.tools.scan.result.SyncScanResult; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.dto.result.AllGridsByUserIdResultDTO; import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.modules.feign.EpmetUserFeignClient; +import com.epmet.modules.group.dao.ResiGroupDao; +import com.epmet.modules.group.dao.ResiGroupStatisticalDao; +import com.epmet.modules.group.entity.ResiGroupEntity; +import com.epmet.modules.group.entity.ResiGroupStatisticalEntity; +import com.epmet.modules.group.redis.ResiGroupRedis; +import com.epmet.modules.member.dao.ResiGroupMemberDao; +import com.epmet.modules.member.redis.ResiGroupMemberRedis; +import com.epmet.modules.member.service.ResiGroupMemberService; +import com.epmet.modules.topic.dao.ResiTopicAttachmentDao; +import com.epmet.modules.topic.dao.ResiTopicDao; +import com.epmet.modules.topic.dao.ResiTopicOperationDao; import com.epmet.modules.topic.dao.TopicDraftDao; +import com.epmet.modules.topic.entity.ResiTopicAttachmentEntity; +import com.epmet.modules.topic.entity.ResiTopicEntity; +import com.epmet.modules.topic.entity.ResiTopicOperationEntity; import com.epmet.modules.topic.entity.TopicDraftEntity; +import com.epmet.modules.topic.service.TopicDraftAttachmentService; +import com.epmet.modules.topic.service.TopicDraftOperationService; import com.epmet.modules.topic.service.TopicDraftService; +import com.epmet.modules.utils.ModuleConstant; +import com.epmet.resi.group.constant.MemberStateConstant; +import com.epmet.resi.group.constant.TopicConstant; +import com.epmet.resi.group.dto.group.ResiGroupInfoRedisDTO; +import com.epmet.resi.group.dto.group.ResiGroupStatisticalInfoRedisDTO; +import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; +import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; +import com.epmet.resi.group.dto.topic.TopicDraftAttachmentDTO; import com.epmet.resi.group.dto.topic.TopicDraftDTO; -import com.epmet.resi.group.dto.topic.form.MyAuditingListFormDTO; +import com.epmet.resi.group.dto.topic.TopicDraftOperationDTO; +import com.epmet.resi.group.dto.topic.form.*; +import com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO; import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; -import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; +import com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.*; import java.util.stream.Collectors; /** @@ -52,12 +94,54 @@ import java.util.stream.Collectors; * @since v1.0.0 2020-12-17 */ @Service +@Slf4j public class TopicDraftServiceImpl extends BaseServiceImpl implements TopicDraftService { private static Logger logger = LoggerFactory.getLogger(TopicDraftServiceImpl.class); @Autowired private GovOrgOpenFeignClient govOrgOpenFeignClient; + @Autowired + private ResiGroupMemberService resiGroupMemberService; + + @Autowired + private ResiTopicAttachmentDao resiTopicAttachmentDao; + + @Autowired + private ResiTopicOperationDao resiTopicOperationDao; + + @Autowired + private EpmetUserFeignClient epmetUserFeignClient; + + @Autowired + private ResiGroupDao resiGroupDao; + + @Autowired + private ResiGroupMemberDao resiGroupMemberDao; + + @Autowired + private ResiGroupStatisticalDao resiGroupStatisticalDao; + + @Autowired + private ResiTopicDao resiTopicDao; + + @Autowired + private ResiGroupRedis resiGroupRedis; + + @Autowired + private TopicDraftAttachmentService topicDraftAttachmentService; + @Autowired + private TopicDraftOperationService topicDraftOperationService; + @Autowired + private ResiGroupMemberRedis resiGroupMemberRedis; + + @Value("${openapi.scan.server.url}") + private String scanApiUrl; + @Value("${openapi.scan.method.textSyncScan}") + private String textSyncScanMethod; + @Value("${openapi.scan.method.imgSyncScan}") + private String imgSyncScanMethod; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -142,4 +226,414 @@ public class TopicDraftServiceImpl extends BaseServiceImpl TopicConstant.MAX_NUMBER_OF_CONTENT){ + //内容超过最大限制 + log.error(ModuleConstant.TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED); + throw new RenException(ModuleConstant.TOPIC_CONTENT_NUMBER_OF_WORDS_EXCEEDED); + } + + TopicDraftEntity topic = ConvertUtils.sourceToTarget(formDTO,TopicDraftEntity.class); + topic.setCreatedBy(tokenDto.getUserId()); + topic.setDraftStatus(TopicConstant.AUDITING); + baseDao.insert(topic); + if (StringUtils.isNotEmpty(formDTO.getTopicDraftId())) { + //隐藏旧话题草稿 + TopicDraftEntity old = new TopicDraftEntity(); + old.setId(formDTO.getTopicDraftId()); + old.setIsSee(NumConstant.ONE_STR); + baseDao.updateById(old); + } + + if(CollectionUtils.isNotEmpty(formDTO.getImageList())){ + TopicDraftAttachmentDTO attachment = new TopicDraftAttachmentDTO(); + int sort = 0; + for(String url : formDTO.getImageList()){ + attachment.setAttachmentUrl(url); + attachment.setTopicDraftId(topic.getId()); + attachment.setCreatedBy(tokenDto.getUserId()); + attachment.setAttachmentFormat(url.substring(url.lastIndexOf(".") + NumConstant.ONE).toLowerCase()); + attachment.setSort(sort++); + attachment.setAttachmentType("image"); + topicDraftAttachmentService.save(attachment); + } + } + + if(CollectionUtils.isNotEmpty(formDTO.getVideoList())){ + TopicDraftAttachmentDTO attachment = new TopicDraftAttachmentDTO(); + int sort = 0; + for(String url : formDTO.getVideoList()){ + attachment.setAttachmentUrl(url); + attachment.setTopicDraftId(topic.getId()); + attachment.setCreatedBy(tokenDto.getUserId()); + attachment.setAttachmentFormat(url.substring(url.lastIndexOf(".") + NumConstant.ONE).toLowerCase()); + attachment.setSort(sort++); + attachment.setAttachmentType("image"); + topicDraftAttachmentService.save(attachment); + } + } + + //话题操作记录 + TopicDraftOperationDTO operation = new TopicDraftOperationDTO(); + operation.setTopicDraftId(topic.getId()); + operation.setOperateType(TopicConstant.SUBMIT); + operation.setCreatedBy(tokenDto.getUserId()); + topicDraftOperationService.save(operation); + + //2.话题内容审核 + String topicContent = formDTO.getTopicContent(); + if (StringUtils.isNotBlank(topicContent)) { + //创建话题内容审核 + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(topicContent); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + //更新话题状态block + TopicDraftEntity draftEntity = new TopicDraftEntity(); + draftEntity.setId(topic.getId()); + draftEntity.setDraftStatus(TopicConstant.BLOCK); + draftEntity.setDraftReason("内容审核失败"); + baseDao.updateById(draftEntity); + //话题操作记录 + TopicDraftOperationDTO operationDTO = new TopicDraftOperationDTO(); + operationDTO.setTopicDraftId(topic.getId()); + operationDTO.setOperateType(TopicConstant.BLOCK); + operationDTO.setCreatedBy(tokenDto.getUserId()); + topicDraftOperationService.save(operationDTO); + + log.error(String.format(TopicConstant.CREATE_TOPIC, topicContent)); + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + } + } + } + //创建话题图片审核 + if (CollectionUtils.isNotEmpty(formDTO.getImageList())){ + ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); + formDTO.getImageList().forEach(url -> { + ImgTaskDTO task = new ImgTaskDTO(); + task.setDataId(UUID.randomUUID().toString().replace("-", "")); + task.setUrl(url); + imgScanParamDTO.getTasks().add(task); + }); + Result imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); + if (!imgScanResult.success()){ + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!imgScanResult.getData().isAllPass()) { + //更新话题状态block + TopicDraftEntity draftEntity = new TopicDraftEntity(); + draftEntity.setId(topic.getId()); + draftEntity.setDraftStatus(TopicConstant.BLOCK); + draftEntity.setDraftReason("图片审核失败"); + baseDao.updateById(draftEntity); + //话题操作记录 + TopicDraftOperationDTO operationDTO = new TopicDraftOperationDTO(); + operationDTO.setTopicDraftId(topic.getId()); + operationDTO.setOperateType(TopicConstant.BLOCK); + operationDTO.setCreatedBy(tokenDto.getUserId()); + topicDraftOperationService.save(operationDTO); + throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); + } + } + } + + //TODO 创建话题语音审核 + if (CollectionUtils.isNotEmpty(formDTO.getVideoList())){ + ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); + formDTO.getVideoList().forEach(url -> { + ImgTaskDTO task = new ImgTaskDTO(); + task.setDataId(UUID.randomUUID().toString().replace("-", "")); + task.setUrl(url); + imgScanParamDTO.getTasks().add(task); + //TODO 根据返回值, + }); + } else { + //TODO 话题草稿状态为 auto_passed: 自动通过 + //更新话题状态block + TopicDraftEntity draftEntity = new TopicDraftEntity(); + draftEntity.setId(topic.getId()); + draftEntity.setDraftStatus(TopicConstant.AUTO_PASSED); + baseDao.updateById(draftEntity); + //话题操作记录 + TopicDraftOperationDTO operationDTO = new TopicDraftOperationDTO(); + operationDTO.setTopicDraftId(topic.getId()); + operationDTO.setOperateType(TopicConstant.AUTO_PASSED); + operationDTO.setCreatedBy(tokenDto.getUserId()); + topicDraftOperationService.save(operationDTO); + //3.保存话题 + saveTopic(tokenDto, formDTO, topic.getId()); + } + + } + + /** + * 组管理界面-待审核/已驳回列表 + * + * @param formDTO + * @return java.util.List + * @author zhaoqifeng + * @date 2020/12/18 14:34 + */ + @Override + public List auditList(TopicAuditFormDTO formDTO) { + List result; + + if (TopicConstant.REVIEW.equals(formDTO.getStatus())) { + result = baseDao.selectTopicDraftByGroup(formDTO.getGroupId(), formDTO.getStatus()); + } else { + result = baseDao.selectTopicDraftByGroup(formDTO.getGroupId(), formDTO.getStatus()); + } + result.forEach(item -> { + ResiGroupMemberInfoRedisDTO memberRedis = + resiGroupMemberRedis.get(formDTO.getGroupId(),item.getUserName()); + if(null != memberRedis && StringUtils.isNotBlank(memberRedis.getUserId())){ + item.setUserName(StringUtils.isBlank(memberRedis.getUserShowName()) ? "" : memberRedis.getUserShowName()); + } + }); + return result; + } + + /** + * 话题草稿详情 + * + * @param formDTO + * @return com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO + * @author zhaoqifeng + * @date 2020/12/18 14:55 + */ + @Override + public DraftDetailResultDTO detail(DraftDetailFormDTO formDTO) { + TopicDraftEntity entity = baseDao.selectById(formDTO.getTopicDraftId()); + + if(null == entity){ + log.error(ModuleConstant.NO_SUCH_TOPIC); + throw new RenException(ModuleConstant.NO_SUCH_TOPIC); + } + DraftDetailResultDTO result = ConvertUtils.sourceToTarget(entity,DraftDetailResultDTO.class); + result.setTopicDraftId(formDTO.getTopicDraftId()); + result.setReleaseTime(new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE).format(entity.getCreatedTime())); + result.setTopicContent(entity.getTopicContent()); + result.setReleaseAddress(entity.getAddress()); + //2.查询话题图片附件 + List imageUrls = topicDraftAttachmentService.getFileList(formDTO.getTopicDraftId(), TopicConstant.IMAGE); + result.setImageList(imageUrls); + + //3.查询话题音频附件 + List voiceUrls = topicDraftAttachmentService.getFileList(formDTO.getTopicDraftId(), TopicConstant.VOICE); + result.setVoiceList(voiceUrls); + + //3.拿取用户信息 + ResiGroupMemberInfoRedisDTO memberRedis = + resiGroupMemberRedis.get(entity.getGroupId(),entity.getCreatedBy()); + if(null != memberRedis && StringUtils.isNotBlank(memberRedis.getUserId())){ + result.setReleaseUserName(StringUtils.isBlank(memberRedis.getUserShowName()) ? "" : memberRedis.getUserShowName()); + result.setReleaseUserHeadPhoto(StringUtils.isBlank(memberRedis.getUserHeadPhoto()) ? "" : memberRedis.getUserHeadPhoto()); + } + + return result; + } + + /** + * 删除已驳回话题 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/12/18 14:58 + */ + @Override + public void deleteDraft(DraftDetailFormDTO formDTO) { + TopicDraftEntity entity = new TopicDraftEntity(); + entity.setId(formDTO.getTopicDraftId()); + entity.setIsSee(NumConstant.ONE_STR); + baseDao.updateById(entity); + } + + /** + * 组长审核 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/12/18 15:06 + */ + @Override + public void audit(AuditDraftTopicFormDTO formDTO) { + + } + + /** + * 保存话题 + * @author zhaoqifeng + * @date 2020/12/18 10:38 + * @param tokenDto + * @param formDTO + * @return void + */ + private void saveTopic(TokenDto tokenDto, CreateTopicFormDTO formDTO, String draftId) { + //1.身份校验,查看当前用户是否是组内成员,当前用户是否被禁言 + ResiGroupMemberDTO resiGroupMemberDTO = + resiGroupMemberService.getResiGroupMember(formDTO.getGroupId(),tokenDto.getUserId() ); + + Result result = verifySilentOrRemoved(resiGroupMemberDTO); + if(!result.success()){ + throw new RenException(result.getCode(), result.getMsg()); + } + + Date currentTime = new Date(); + //2.创建话题 + ResiTopicEntity topic = ConvertUtils.sourceToTarget(formDTO,ResiTopicEntity.class); + topic.setCreatedBy(tokenDto.getUserId()); + topic.setStatus(TopicConstant.PUBLISHMENT); + resiTopicDao.insertOne(topic); + if(StringUtils.isBlank(topic.getId())){ + //没有返回主键 + log.error(ModuleConstant.NO_PRIMARY_KEY_RETURNED); + throw new RenException(ModuleConstant.NO_PRIMARY_KEY_RETURNED); + } + if(CollectionUtils.isNotEmpty(formDTO.getImageList())){ + ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); + int sort = 0; + for(String url : formDTO.getImageList()){ + attachment.setAttachmentUrl(url); + attachment.setTopicId(topic.getId()); + attachment.setCreatedBy(tokenDto.getUserId()); + attachment.setAttachmentFormat(url.substring(url.lastIndexOf(".") + NumConstant.ONE).toLowerCase()); + attachment.setSort(sort++); + attachment.setAttachmentType("image"); + resiTopicAttachmentDao.insertOne(attachment); + } + } + + //3.话题操作记录 + ResiTopicOperationEntity operation = new ResiTopicOperationEntity(); + operation.setTopicId(topic.getId()); + operation.setOperationType(TopicConstant.PUBLISHMENT); + operation.setCreatedBy(tokenDto.getUserId()); + resiTopicOperationDao.insertOne(operation); + + //4.小组统计信息,话题数+1 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(FieldConstant.DEL_FLAG, NumConstant.ZERO_STR); + wrapper.eq(TopicConstant.RESI_GROUP_ID,formDTO.getGroupId()); + List statistical = resiGroupStatisticalDao.selectList(wrapper); + if(null != statistical && statistical.size() >= NumConstant.ONE){ + if(statistical.size() != NumConstant.ONE){ + log.error(ModuleConstant.GROUP_STASTICAL_NOT_SINGLE); + throw new RenException(ModuleConstant.GROUP_STASTICAL_NOT_SINGLE); + }else{ + ResiGroupStatisticalEntity statistical2Update = new ResiGroupStatisticalEntity(); + statistical2Update.setId(statistical.get(NumConstant.ZERO).getId()); + statistical2Update.setTotalTopics(null == statistical.get(NumConstant.ZERO).getTotalTopics() ? NumConstant.ONE : statistical.get(NumConstant.ZERO).getTotalTopics() + NumConstant.ONE); + statistical2Update.setUpdatedBy(tokenDto.getUserId()); + statistical2Update.setUpdatedTime(currentTime); + resiGroupStatisticalDao.updateById(statistical2Update); + } + }else{ + log.error(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); + throw new RenException(ModuleConstant.NO_SUCH_GROUP_STASTICAL_INFO); + } + //5.更新群缓存信息,话题数量+1 + updCacheGroupStatisticalInfo(formDTO.getGroupId(),ModuleConstant.PLUS_OPERATION,NumConstant.ONE); + + //6.群组信息,更新latestTopicPublishDate字段 + ResiGroupEntity group2Update = new ResiGroupEntity(); + group2Update.setId(formDTO.getGroupId()); + group2Update.setLatestTopicPublishDate(currentTime); + resiGroupDao.updateById(group2Update); + + TopicDraftEntity draftEntity = new TopicDraftEntity(); + draftEntity.setId(draftId); + draftEntity.setTopicId(topic.getId()); + baseDao.updateById(draftEntity); + } + + + /** + * 查询当前组员在组内是否被禁言或已被移除 + * @Param resiGroupMemberDTO + * @return Result.class + * @Author zhaoqf + * @Date 2020.04.01 15:00 + **/ + private Result verifySilentOrRemoved(ResiGroupMemberDTO resiGroupMemberDTO){ + if(null != resiGroupMemberDTO){ + if(MemberStateConstant.SILENT.equals(resiGroupMemberDTO.getStatus())){ + //当前用户被禁言 + log.error(ModuleConstant.SLIENT_MEMBER); + throw new RenException(ModuleConstant.SLIENT_MEMBER); + }else if(MemberStateConstant.REMOVED.equals(resiGroupMemberDTO.getStatus())){ + //当前用户已被移出群 + log.error(ModuleConstant.REMOVED_MEMBER); + throw new RenException(ModuleConstant.REMOVED_MEMBER); + }else{ + return new Result(); + } + }else{ + //当前用户非组内成员 + log.error(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); + throw new RenException(ModuleConstant.NOT_BELONG_TO_CURRENT_GROUP); + } + } + + /** + * 更新组统计缓存信息 + * @Param groupId + * @Param operation "+":plus "-":minus + * @return + * @Author zhaoqf + * @Date 2020.04.14 23:31 + **/ + private void updCacheGroupStatisticalInfo(String groupId,String operation,Integer quantity){ + + //ResiGroupRedis在get()时已经校验缓存中是否有数据,如果没有数据则从数据库中拉取并重新放入缓存 + ResiGroupInfoRedisDTO groupCache = + resiGroupRedis.get(groupId); + if(groupCache != null && StringUtils.isNotBlank(groupCache.getGroupId())){ + ResiGroupStatisticalInfoRedisDTO statisticalCache = groupCache.getGroupStatisticalInfo(); + if(null != statisticalCache){ + if(StringUtils.equals(ModuleConstant.PLUS_OPERATION,operation)){ + statisticalCache.setTotalTopics( + null == statisticalCache.getTotalTopics() ? quantity : statisticalCache.getTotalTopics() + quantity + ); + }else if(StringUtils.equals(ModuleConstant.MINUS_OPERATION,operation)){ + statisticalCache.setTotalTopics( + null == statisticalCache.getTotalTopics() ? quantity : statisticalCache.getTotalTopics() - quantity + ); + } + + groupCache.setGroupStatisticalInfo(statisticalCache); + }else{ + //没有相应的群组统计缓存信息 + } + resiGroupRedis.set(groupCache); + }else{ + //没有相应的群组缓存信息 + } + + } + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java index 118ed1f5a7..bf0c3a741e 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java @@ -368,4 +368,6 @@ public interface ModuleConstant extends Constant { * 群邀请二维码跳转页面 */ String CODE_INVITE_PAGE = "pages/group/group/invitation/invitation"; + + String TOPIC_CONTENT_AND_VOICE_IS_NULL = "请输入话题内容或语音"; } diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml b/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml index 717cff838d..68482e2f61 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml @@ -126,6 +126,8 @@ openapi: method: imgSyncScan: /imgSyncScan textSyncScan: /textSyncScan + voiceAsyncScan: /voiceAsyncScan + voiceResults: /voiceResults thread: # 线程池配置 diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftAttachmentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftAttachmentDao.xml index 107d7bdee0..1f7154b80c 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftAttachmentDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftAttachmentDao.xml @@ -4,5 +4,11 @@ - + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftDao.xml index 96213c43aa..a956df46d7 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftDao.xml @@ -25,4 +25,24 @@ LIMIT #{pageNo}, #{pageSize} + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftScanTaskDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftScanTaskDao.xml new file mode 100644 index 0000000000..1623b9f5a1 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/TopicDraftScanTaskDao.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file