diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/ActCommentAttachmentDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/ActCommentAttachmentDTO.java new file mode 100644 index 0000000000..5326d3783d --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/ActCommentAttachmentDTO.java @@ -0,0 +1,126 @@ +/** + * 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.act; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +public class ActCommentAttachmentDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 活动Id[group_act_info.id] + */ + private String groupActId; + + /** + * 评论Id + */ + private String actCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + + /** + * 删除标记 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/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java index 92fce732ae..8d3cbbcbe1 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java @@ -1,11 +1,13 @@ package com.epmet.resi.group.dto.act.form; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.List; /** * 005、评论活动 @@ -27,6 +29,10 @@ public class CommentFormDTO implements Serializable { @NotBlank(message = "评论内容不能为空", groups = AddUserShowGroup.class) @Length(max = 500, message = "评论内容最多输入500字", groups = AddUserShowGroup.class) private String commentContent; + /** + * 图片附件集合 + */ + private List imageList; /** * 当前用户id diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java index efb8066f28..a6053ffc39 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java @@ -1,10 +1,13 @@ package com.epmet.resi.group.dto.act.result; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * 006、活动评论列表查询 @@ -27,4 +30,11 @@ public class CommentResultDTO implements Serializable { private Date commentTime; private String commentUserId; + + /** + * 图片附件集合 + */ + private List imageList = new ArrayList<>(); + + } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java index c28985e054..57ae73c471 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java @@ -1,11 +1,14 @@ package com.epmet.resi.group.dto.comment.result; import com.alibaba.fastjson.annotation.JSONField; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * @Description @@ -54,4 +57,9 @@ public class ResiCommentResultDTO implements Serializable { * 评论状态 * */ private String commentStatus; + + /** + * 图片附件集合 + */ + private List imageList = new ArrayList<>(); } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/CommentFileDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/CommentFileDTO.java new file mode 100644 index 0000000000..f101a0a657 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/CommentFileDTO.java @@ -0,0 +1,26 @@ +package com.epmet.resi.group.dto.group.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 话题、通知、活动评论附件 + */ +@NoArgsConstructor +@Data +public class CommentFileDTO implements Serializable { + + private static final long serialVersionUID = -3930520724652521552L; + private String name; + private String url; + private String type; + private String format; + private Integer size; + private Integer duration; + @JsonIgnore + private String userId; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/NoticeCommentAttachmentDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/NoticeCommentAttachmentDTO.java new file mode 100644 index 0000000000..6e7c7e336f --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/NoticeCommentAttachmentDTO.java @@ -0,0 +1,126 @@ +/** + * 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.notice; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +public class NoticeCommentAttachmentDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 通知Id + */ + private String noticeId; + + /** + * 评论Id + */ + private String noticeCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + + /** + * 删除标记 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/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java index c543bf7222..1044128fcf 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java @@ -5,6 +5,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; +import java.util.List; /** * @Author sun @@ -30,6 +31,11 @@ public class NoticeCommentFormDTO { */ private String userId; + /** + * 图片附件集合 + */ + private List imageList; + public interface Comment{} public interface UserShow extends CustomerClientShowGroup {} } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java index 726289e144..45a9c9f694 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java @@ -1,11 +1,13 @@ package com.epmet.resi.group.dto.notice.result; -import com.alibaba.fastjson.annotation.JSONField; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * @Author sun @@ -42,4 +44,9 @@ public class NoticeCommentListResultDTO implements Serializable { * */ private String userId; + /** + * 图片附件集合 + */ + private List imageList = new ArrayList<>(); + } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/ResiTopicCommentAttachmentDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/ResiTopicCommentAttachmentDTO.java new file mode 100644 index 0000000000..acd1c4e381 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/ResiTopicCommentAttachmentDTO.java @@ -0,0 +1,126 @@ +/** + * 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 2021-09-06 + */ +@Data +public class ResiTopicCommentAttachmentDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 话题Id + */ + private String topicId; + + /** + * 评论Id + */ + private String topicCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + + /** + * 删除标记 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/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java index 894364fe16..9e8b7338cd 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java @@ -1,9 +1,11 @@ package com.epmet.resi.group.dto.topic.form; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import lombok.Data; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.List; /** * @Description @@ -21,4 +23,9 @@ public class ResiPublishCommentFormDTO implements Serializable { @NotBlank(message = "评论内容不能为空") private String commentContent; + + /** + * 图片附件集合 + */ + private List imageList; } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentAttachmentController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentAttachmentController.java new file mode 100644 index 0000000000..e84a321e4b --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentAttachmentController.java @@ -0,0 +1,85 @@ +/** + * 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.act.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.modules.act.service.ActCommentAttachmentService; +import com.epmet.resi.group.dto.act.ActCommentAttachmentDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@RestController +@RequestMapping("actcommentattachment") +public class ActCommentAttachmentController { + + @Autowired + private ActCommentAttachmentService actCommentAttachmentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = actCommentAttachmentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + ActCommentAttachmentDTO data = actCommentAttachmentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody ActCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + actCommentAttachmentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody ActCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + actCommentAttachmentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + actCommentAttachmentService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentAttachmentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentAttachmentDao.java new file mode 100644 index 0000000000..07f076a6f5 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentAttachmentDao.java @@ -0,0 +1,43 @@ +/** + * 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.act.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.act.entity.ActCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Mapper +public interface ActCommentAttachmentDao extends BaseDao { + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + List selectActComFile(@Param("groupActId") String groupActId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/ActCommentAttachmentEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/ActCommentAttachmentEntity.java new file mode 100644 index 0000000000..1e290165ee --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/ActCommentAttachmentEntity.java @@ -0,0 +1,93 @@ +/** + * 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.act.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("act_comment_attachment") +public class ActCommentAttachmentEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 活动Id[group_act_info.id] + */ + private String groupActId; + + /** + * 评论Id + */ + private String actCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentAttachmentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentAttachmentService.java new file mode 100644 index 0000000000..c1faff4a04 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentAttachmentService.java @@ -0,0 +1,103 @@ +/** + * 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.act.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.modules.act.entity.ActCommentAttachmentEntity; +import com.epmet.resi.group.dto.act.ActCommentAttachmentDTO; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; + +import java.util.List; +import java.util.Map; + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +public interface ActCommentAttachmentService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-09-06 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-09-06 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return ActCommentAttachmentDTO + * @author generator + * @date 2021-09-06 + */ + ActCommentAttachmentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void save(ActCommentAttachmentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void update(ActCommentAttachmentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-09-06 + */ + void delete(String[] ids); + + /** + * @Author sun + * @Description 查询活动评论所有人员的附件信息 + **/ + List getActComFile(String groupActId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentAttachmentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentAttachmentServiceImpl.java new file mode 100644 index 0000000000..916cf5bdda --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentAttachmentServiceImpl.java @@ -0,0 +1,110 @@ +/** + * 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.act.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.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.modules.act.dao.ActCommentAttachmentDao; +import com.epmet.modules.act.entity.ActCommentAttachmentEntity; +import com.epmet.modules.act.service.ActCommentAttachmentService; +import com.epmet.resi.group.dto.act.ActCommentAttachmentDTO; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +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 2021-09-06 + */ +@Service +public class ActCommentAttachmentServiceImpl extends BaseServiceImpl implements ActCommentAttachmentService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ActCommentAttachmentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ActCommentAttachmentDTO.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 ActCommentAttachmentDTO get(String id) { + ActCommentAttachmentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ActCommentAttachmentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ActCommentAttachmentDTO dto) { + ActCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, ActCommentAttachmentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ActCommentAttachmentDTO dto) { + ActCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, ActCommentAttachmentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + @Override + public List getActComFile(String groupActId) { + return baseDao.selectActComFile(groupActId); + } + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java index c249c4ec28..98890462ca 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java @@ -18,6 +18,7 @@ package com.epmet.modules.act.service.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +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.scan.param.TextScanParamDTO; @@ -28,23 +29,31 @@ import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.act.dao.ActCommentDao; +import com.epmet.modules.act.entity.ActCommentAttachmentEntity; import com.epmet.modules.act.entity.ActCommentEntity; +import com.epmet.modules.act.service.ActCommentAttachmentService; import com.epmet.modules.act.service.ActCommentService; import com.epmet.modules.act.service.GroupActInfoService; import com.epmet.modules.constant.GroupActConstant; +import com.epmet.modules.notice.service.NoticeCommentService; import com.epmet.resi.group.dto.act.GroupActInfoDTO; import com.epmet.resi.group.dto.act.form.CommentFormDTO; import com.epmet.resi.group.dto.act.form.CommentQueryFormDTO; import com.epmet.resi.group.dto.act.result.CommentResultDTO; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import com.github.pagehelper.PageHelper; 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 org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -65,6 +74,10 @@ public class ActCommentServiceImpl extends BaseServiceImpl imageList = formDTO.getImageList().stream().map(NoticeFileDTO::getUrl).collect(Collectors.toList()); + noticeCommentService.safetyCheck(new ArrayList<>(), imageList); + //3、插入记录 ActCommentEntity actCommentEntity = new ActCommentEntity(); actCommentEntity.setCustomerId(formDTO.getCustomerId()); @@ -103,6 +121,33 @@ public class ActCommentServiceImpl extends BaseServiceImpl AttachmentEntityList = new ArrayList<>(); + //图片 + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(formDTO.getImageList())) { + AtomicInteger sort = new AtomicInteger(); + formDTO.getImageList().forEach(img -> { + ActCommentAttachmentEntity attachment = new ActCommentAttachmentEntity(); + attachment.setCustomerId(formDTO.getCustomerId()); + attachment.setGroupActId(formDTO.getGroupActId()); + attachment.setActCommentId(actCommentEntity.getId()); + attachment.setFileName(img.getName()); + attachment.setAttachmentName(""); + attachment.setAttachmentSize(img.getSize()); + attachment.setAttachmentFormat(img.getFormat()); + attachment.setAttachmentType(img.getType()); + attachment.setAttachmentUrl(img.getUrl()); + attachment.setSort(sort.get()); + attachment.setDuration(img.getDuration()); + sort.getAndIncrement(); + AttachmentEntityList.add(attachment); + }); + } + if (AttachmentEntityList.size() > NumConstant.ZERO) { + actCommentAttachmentService.insertBatch(AttachmentEntityList); + } + } /** @@ -124,8 +169,11 @@ public class ActCommentServiceImpl extends BaseServiceImpl fileList = actCommentAttachmentService.getActComFile(formDTO.getGroupActId()); + if (!CollectionUtils.isEmpty(result.getData())) { - //3.遍历封装数据并返回 + //4.遍历封装数据并返回 list.forEach(l -> { result.getData().forEach(user -> { if (l.getCommentUserId().equals(user.getUserId())) { @@ -133,6 +181,14 @@ public class ActCommentServiceImpl extends BaseServiceImpl imageList = new ArrayList<>(); + for (CommentFileDTO f : fileList) { + if (l.getCommentUserId().equals(f.getUserId())) { + imageList.add(f); + } + } + l.setImageList(imageList); }); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeCommentAttachmentController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeCommentAttachmentController.java new file mode 100644 index 0000000000..baaf689e54 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeCommentAttachmentController.java @@ -0,0 +1,85 @@ +/** + * 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.notice.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.modules.notice.service.NoticeCommentAttachmentService; +import com.epmet.resi.group.dto.notice.NoticeCommentAttachmentDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@RestController +@RequestMapping("noticecommentattachment") +public class NoticeCommentAttachmentController { + + @Autowired + private NoticeCommentAttachmentService noticeCommentAttachmentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = noticeCommentAttachmentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + NoticeCommentAttachmentDTO data = noticeCommentAttachmentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody NoticeCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + noticeCommentAttachmentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody NoticeCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + noticeCommentAttachmentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + noticeCommentAttachmentService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeCommentAttachmentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeCommentAttachmentDao.java new file mode 100644 index 0000000000..2ad57a60cd --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeCommentAttachmentDao.java @@ -0,0 +1,43 @@ +/** + * 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.notice.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.notice.entity.NoticeCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Mapper +public interface NoticeCommentAttachmentDao extends BaseDao { + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + List selectNoticeComFile(@Param("noticeId") String noticeId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/entity/NoticeCommentAttachmentEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/entity/NoticeCommentAttachmentEntity.java new file mode 100644 index 0000000000..7ab97e6634 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/entity/NoticeCommentAttachmentEntity.java @@ -0,0 +1,93 @@ +/** + * 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.notice.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("notice_comment_attachment") +public class NoticeCommentAttachmentEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 通知Id + */ + private String noticeId; + + /** + * 评论Id + */ + private String noticeCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentAttachmentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentAttachmentService.java new file mode 100644 index 0000000000..5baa7d553d --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentAttachmentService.java @@ -0,0 +1,103 @@ +/** + * 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.notice.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.modules.notice.entity.NoticeCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.notice.NoticeCommentAttachmentDTO; + +import java.util.List; +import java.util.Map; + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +public interface NoticeCommentAttachmentService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-09-06 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-09-06 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return NoticeCommentAttachmentDTO + * @author generator + * @date 2021-09-06 + */ + NoticeCommentAttachmentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void save(NoticeCommentAttachmentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void update(NoticeCommentAttachmentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-09-06 + */ + void delete(String[] ids); + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + List getNoticeComFile(String noticeId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java index 0ac50c21e7..6684e61d80 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java @@ -48,4 +48,11 @@ public interface NoticeCommentService extends BaseService { * @Description 通知评论列表查询 **/ List noticeCommentList(NoticeCommentListFormDTO formDTO); + + /** + * @Author sun + * @Description 文字、图片安全校验 + **/ + void safetyCheck(List wordList, List imageList); + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentAttachmentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentAttachmentServiceImpl.java new file mode 100644 index 0000000000..10c3710894 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentAttachmentServiceImpl.java @@ -0,0 +1,110 @@ +/** + * 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.notice.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.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.modules.notice.dao.NoticeCommentAttachmentDao; +import com.epmet.modules.notice.entity.NoticeCommentAttachmentEntity; +import com.epmet.modules.notice.service.NoticeCommentAttachmentService; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.notice.NoticeCommentAttachmentDTO; +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 2021-09-06 + */ +@Service +public class NoticeCommentAttachmentServiceImpl extends BaseServiceImpl implements NoticeCommentAttachmentService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, NoticeCommentAttachmentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, NoticeCommentAttachmentDTO.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 NoticeCommentAttachmentDTO get(String id) { + NoticeCommentAttachmentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, NoticeCommentAttachmentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(NoticeCommentAttachmentDTO dto) { + NoticeCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, NoticeCommentAttachmentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(NoticeCommentAttachmentDTO dto) { + NoticeCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, NoticeCommentAttachmentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + @Override + public List getNoticeComFile(String noticeId) { + return baseDao.selectNoticeComFile(noticeId); + } + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java index 2ab3994891..a66e3869a5 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java @@ -17,10 +17,13 @@ package com.epmet.modules.notice.service.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; 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.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; @@ -30,18 +33,23 @@ import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.member.service.ResiGroupMemberService; import com.epmet.modules.notice.dao.NoticeCommentDao; +import com.epmet.modules.notice.entity.NoticeCommentAttachmentEntity; import com.epmet.modules.notice.entity.NoticeCommentEntity; import com.epmet.modules.notice.redis.NoticeCommentRedis; +import com.epmet.modules.notice.service.NoticeCommentAttachmentService; import com.epmet.modules.notice.service.NoticeCommentService; import com.epmet.modules.notice.service.NoticeService; 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.result.CommentFileDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; import com.epmet.resi.group.dto.notice.NoticeDTO; import com.epmet.resi.group.dto.notice.form.NoticeCommentFormDTO; import com.epmet.resi.group.dto.notice.form.NoticeCommentListFormDTO; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import com.epmet.resi.group.dto.notice.result.NoticeCommentListResultDTO; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,6 +61,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -70,12 +79,16 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl imageList = formDTO.getImageList().stream().map(NoticeFileDTO::getUrl).collect(Collectors.toList()); + safetyCheck(new ArrayList<>(), imageList); //2.判断当前用户是否被禁言、移除、非本组成员 NoticeDTO notice = noticeService.get(formDTO.getNoticeId()); @@ -139,6 +155,33 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl AttachmentEntityList = new ArrayList<>(); + //图片 + if (CollectionUtils.isNotEmpty(formDTO.getImageList())) { + AtomicInteger sort = new AtomicInteger(); + formDTO.getImageList().forEach(img -> { + NoticeCommentAttachmentEntity attachment = new NoticeCommentAttachmentEntity(); + attachment.setCustomerId(notice.getCustomerId()); + attachment.setNoticeId(formDTO.getNoticeId()); + attachment.setNoticeCommentId(entity.getId()); + attachment.setFileName(img.getName()); + attachment.setAttachmentName(""); + attachment.setAttachmentSize(img.getSize()); + attachment.setAttachmentFormat(img.getFormat()); + attachment.setAttachmentType(img.getType()); + attachment.setAttachmentUrl(img.getUrl()); + attachment.setSort(sort.get()); + attachment.setDuration(img.getDuration()); + sort.getAndIncrement(); + AttachmentEntityList.add(attachment); + }); + } + if (AttachmentEntityList.size() > NumConstant.ZERO) { + noticeCommentAttachmentService.insertBatch(AttachmentEntityList); + } + } /** @@ -165,7 +208,10 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl resultDTOList = result.getData(); - //3.封装数据并返回 + //3.查询通知评论所有人员的附件信息 + List fileList = noticeCommentAttachmentService.getNoticeComFile(formDTO.getNoticeId()); + + //4.封装数据并返回 resultList.forEach(l -> { StringBuffer name = new StringBuffer(); resultDTOList.forEach(user -> { @@ -175,9 +221,64 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl imageList = new ArrayList<>(); + for (CommentFileDTO f : fileList) { + if (l.getUserId().equals(f.getUserId())) { + imageList.add(f); + } + } + l.setImageList(imageList); }); return resultList; } + /** + * @Author sun + * @Description 文字、图片安全校验 + **/ + public void safetyCheck(List wordList, List imageList) { + if (imageList.size() != NumConstant.ZERO) { + wordList.forEach(word -> { + //创建话题内容审核 + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(word); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + logger.error("safetyCheck textScan return failed,result:"+ JSON.toJSONString(textSyncScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + logger.warn(EpmetErrorCode.TEXT_SCAN_FAILED.getMsg().concat(String.format(TopicConstant.CREATE_TOPIC, word))); + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + } + } + }); + } + //创建话题图片审核 + if (imageList.size() != NumConstant.ZERO) { + ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); + imageList.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()) { + logger.error("safetyCheck imgScan return failed,result:"+ JSON.toJSONString(imgScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + if (!imgScanResult.getData().isAllPass()) { + logger.warn(EpmetErrorCode.IMG_SCAN_FAILED.getMsg()); + throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); + } + + } + } + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java index b21c69a4ae..49f240ca3c 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java @@ -503,7 +503,7 @@ public class NoticeServiceImpl extends BaseServiceImpl * @Description 文字、图片安全校验 **/ private void safetyCheck(List wordList, List imageList) { - if (imageList.size() != NumConstant.ZERO) { + if (wordList.size() != NumConstant.ZERO) { wordList.forEach(word -> { //创建话题内容审核 TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicCommentAttachmentController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicCommentAttachmentController.java new file mode 100644 index 0000000000..9c5dd8f841 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicCommentAttachmentController.java @@ -0,0 +1,85 @@ +/** + * 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.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.modules.topic.service.ResiTopicCommentAttachmentService; +import com.epmet.resi.group.dto.topic.ResiTopicCommentAttachmentDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@RestController +@RequestMapping("resitopiccommentattachment") +public class ResiTopicCommentAttachmentController { + + @Autowired + private ResiTopicCommentAttachmentService resiTopicCommentAttachmentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = resiTopicCommentAttachmentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + ResiTopicCommentAttachmentDTO data = resiTopicCommentAttachmentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody ResiTopicCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + resiTopicCommentAttachmentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody ResiTopicCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + resiTopicCommentAttachmentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + resiTopicCommentAttachmentService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentAttachmentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentAttachmentDao.java new file mode 100644 index 0000000000..ab917a7ba5 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentAttachmentDao.java @@ -0,0 +1,43 @@ +/** + * 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.ResiTopicCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Mapper +public interface ResiTopicCommentAttachmentDao extends BaseDao { + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + List selectTopicComFile(@Param("topicId") String topicId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicCommentAttachmentEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicCommentAttachmentEntity.java new file mode 100644 index 0000000000..d4400a14df --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicCommentAttachmentEntity.java @@ -0,0 +1,93 @@ +/** + * 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; + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("resi_topic_comment_attachment") +public class ResiTopicCommentAttachmentEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 话题Id + */ + private String topicId; + + /** + * 评论Id + */ + private String topicCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicCommentAttachmentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicCommentAttachmentService.java new file mode 100644 index 0000000000..d29f410d33 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicCommentAttachmentService.java @@ -0,0 +1,102 @@ +/** + * 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.ResiTopicCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.topic.ResiTopicCommentAttachmentDTO; + +import java.util.List; +import java.util.Map; + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +public interface ResiTopicCommentAttachmentService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-09-06 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-09-06 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return ResiTopicCommentAttachmentDTO + * @author generator + * @date 2021-09-06 + */ + ResiTopicCommentAttachmentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void save(ResiTopicCommentAttachmentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void update(ResiTopicCommentAttachmentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-09-06 + */ + void delete(String[] ids); + + /** + * @Author sun + * @Description 查询话题评论所有人员的附件信息 + **/ + List getTopicComFile(String topicId); +} \ 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/ResiTopicCommentAttachmentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentAttachmentServiceImpl.java new file mode 100644 index 0000000000..e44dd792da --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentAttachmentServiceImpl.java @@ -0,0 +1,110 @@ +/** + * 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.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.modules.topic.dao.ResiTopicCommentAttachmentDao; +import com.epmet.modules.topic.entity.ResiTopicCommentAttachmentEntity; +import com.epmet.modules.topic.service.ResiTopicCommentAttachmentService; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.topic.ResiTopicCommentAttachmentDTO; +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 2021-09-06 + */ +@Service +public class ResiTopicCommentAttachmentServiceImpl extends BaseServiceImpl implements ResiTopicCommentAttachmentService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ResiTopicCommentAttachmentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ResiTopicCommentAttachmentDTO.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 ResiTopicCommentAttachmentDTO get(String id) { + ResiTopicCommentAttachmentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ResiTopicCommentAttachmentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ResiTopicCommentAttachmentDTO dto) { + ResiTopicCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, ResiTopicCommentAttachmentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ResiTopicCommentAttachmentDTO dto) { + ResiTopicCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, ResiTopicCommentAttachmentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + @Override + public List getTopicComFile(String topicId) { + return baseDao.selectTopicComFile(topicId); + } + +} \ 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/ResiTopicCommentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java index dd02ae9142..623338a5ec 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java @@ -41,22 +41,25 @@ import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.commons.tools.utils.SendMqMsgUtils; import com.epmet.dto.form.CommonGridIdFormDTO; import com.epmet.dto.form.UserResiInfoListFormDTO; -import com.epmet.dto.result.UserInfoResultDTO; import com.epmet.dto.result.CommonDataFilterResultDTO; +import com.epmet.dto.result.UserInfoResultDTO; import com.epmet.dto.result.UserResiInfoResultDTO; import com.epmet.modules.comment.entity.ResiTopicCommentEntity; import com.epmet.modules.constant.ResiGroupRedisKeys; import com.epmet.modules.constant.WxmpSubscribeConstant; import com.epmet.modules.feign.EpmetUserFeignClient; +import com.epmet.modules.feign.GovOrgFeignClient; import com.epmet.modules.group.dao.ResiGroupDao; import com.epmet.modules.group.entity.ResiGroupEntity; -import com.epmet.modules.feign.GovOrgFeignClient; 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.notice.service.NoticeCommentService; import com.epmet.modules.topic.dao.ResiTopicCommentDao; import com.epmet.modules.topic.dao.ResiTopicDao; +import com.epmet.modules.topic.entity.ResiTopicCommentAttachmentEntity; +import com.epmet.modules.topic.service.ResiTopicCommentAttachmentService; import com.epmet.modules.topic.service.ResiTopicCommentService; import com.epmet.modules.topic.service.ResiTopicService; import com.epmet.modules.utils.ModuleConstant; @@ -64,11 +67,12 @@ import com.epmet.resi.group.constant.MemberStateConstant; import com.epmet.resi.group.constant.TopicConstant; import com.epmet.resi.group.dto.comment.form.ResiQueryCommentFormDTO; import com.epmet.resi.group.dto.comment.result.ResiCommentResultDTO; -import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.ResiGroupInfoRedisDTO; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; import com.epmet.resi.group.dto.member.result.ResiGroupMemberInfoRedisResultDTO; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import com.epmet.resi.group.dto.topic.ResiTopicCommentDTO; import com.epmet.resi.group.dto.topic.ResiTopicDTO; import com.epmet.resi.group.dto.topic.form.ResiPublishCommentFormDTO; @@ -76,6 +80,7 @@ import com.epmet.resi.group.dto.topic.result.IssueGridResultDTO; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import com.google.common.base.CharMatcher; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -85,6 +90,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -99,32 +105,28 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl imageList = resiCommentFormDTO.getImageList().stream().map(NoticeFileDTO::getUrl).collect(Collectors.toList()); + noticeCommentService.safetyCheck(new ArrayList<>(), imageList); + //1.判断当前用户是否被禁言 ResiTopicDTO topic = resiTopicService.get(resiCommentFormDTO.getTopicId()); if(null == topic){ @@ -314,6 +320,32 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl AttachmentEntityList = new ArrayList<>(); + //图片 + if (CollectionUtils.isNotEmpty(resiCommentFormDTO.getImageList())) { + AtomicInteger sort = new AtomicInteger(); + resiCommentFormDTO.getImageList().forEach(img -> { + ResiTopicCommentAttachmentEntity attachment = new ResiTopicCommentAttachmentEntity(); + attachment.setCustomerId(comment.getCustomerId()); + attachment.setTopicId(resiCommentFormDTO.getTopicId()); + attachment.setTopicCommentId(comment.getId()); + attachment.setFileName(img.getName()); + attachment.setAttachmentName(""); + attachment.setAttachmentSize(img.getSize()); + attachment.setAttachmentFormat(img.getFormat()); + attachment.setAttachmentType(img.getType()); + attachment.setAttachmentUrl(img.getUrl()); + attachment.setSort(sort.get()); + attachment.setDuration(img.getDuration()); + sort.getAndIncrement(); + AttachmentEntityList.add(attachment); + }); + } + if (AttachmentEntityList.size() > NumConstant.ZERO) { + resiTopicCommentAttachmentService.insertBatch(AttachmentEntityList); + } + //对所有关注这个话题的人发送微信订阅 resiTopicService.sendWxmpUpdateSubscribe(tokenDto,topic.getId(), WxmpSubscribeConstant.TYPE_COMMENT); return new Result(); @@ -372,6 +404,20 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl fileList = resiTopicCommentAttachmentService.getTopicComFile(commentFormDTO.getTopicId()); + //封装数据并返回 + comments.forEach(l -> { + //每一条评论的附件信息 + List imageList = new ArrayList<>(); + for (CommentFileDTO f : fileList) { + if (l.getUserId().equals(f.getUserId())) { + imageList.add(f); + } + } + l.setImageList(imageList); + }); + } return new Result>().ok(comments); diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentAttachmentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentAttachmentDao.xml new file mode 100644 index 0000000000..88a1997484 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentAttachmentDao.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeCommentAttachmentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeCommentAttachmentDao.xml new file mode 100644 index 0000000000..027cf9b729 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeCommentAttachmentDao.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentAttachmentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentAttachmentDao.xml new file mode 100644 index 0000000000..ff7fcc59e9 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentAttachmentDao.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file