Browse Source

8、活动/通知/话题评论允许有图片

master
sunyuchao 4 years ago
parent
commit
05f3762f41
  1. 126
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/ActCommentAttachmentDTO.java
  2. 6
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java
  3. 10
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java
  4. 8
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java
  5. 26
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/CommentFileDTO.java
  6. 126
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/NoticeCommentAttachmentDTO.java
  7. 6
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java
  8. 9
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java
  9. 126
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/ResiTopicCommentAttachmentDTO.java
  10. 7
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java
  11. 85
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentAttachmentController.java
  12. 43
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentAttachmentDao.java
  13. 93
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/ActCommentAttachmentEntity.java
  14. 103
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentAttachmentService.java
  15. 110
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentAttachmentServiceImpl.java
  16. 58
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java
  17. 85
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/controller/NoticeCommentAttachmentController.java
  18. 43
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeCommentAttachmentDao.java
  19. 93
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/entity/NoticeCommentAttachmentEntity.java
  20. 103
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentAttachmentService.java
  21. 7
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java
  22. 110
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentAttachmentServiceImpl.java
  23. 103
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java
  24. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java
  25. 85
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicCommentAttachmentController.java
  26. 43
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentAttachmentDao.java
  27. 93
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicCommentAttachmentEntity.java
  28. 102
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicCommentAttachmentService.java
  29. 110
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentAttachmentServiceImpl.java
  30. 68
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java
  31. 25
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentAttachmentDao.xml
  32. 25
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeCommentAttachmentDao.xml
  33. 25
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentAttachmentDao.xml

126
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
/**
* 文件格式JPGPNGPDFJPEGBMPMP4WMAM4AMP3DOCDOCXXLS
*/
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;
}

6
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<NoticeFileDTO> imageList;
/**
* 当前用户id

10
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<CommentFileDTO> imageList = new ArrayList<>();
}

8
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<CommentFileDTO> imageList = new ArrayList<>();
}

26
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;
}

126
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
/**
* 文件格式JPGPNGPDFJPEGBMPMP4WMAM4AMP3DOCDOCXXLS
*/
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;
}

6
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<NoticeFileDTO> imageList;
public interface Comment{}
public interface UserShow extends CustomerClientShowGroup {}
}

9
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<CommentFileDTO> imageList = new ArrayList<>();
}

126
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
/**
* 文件格式JPGPNGPDFJPEGBMPMP4WMAM4AMP3DOCDOCXXLS
*/
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;
}

7
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<NoticeFileDTO> imageList;
}

85
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<ActCommentAttachmentDTO>> page(@RequestParam Map<String, Object> params){
PageData<ActCommentAttachmentDTO> page = actCommentAttachmentService.page(params);
return new Result<PageData<ActCommentAttachmentDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<ActCommentAttachmentDTO> get(@PathVariable("id") String id){
ActCommentAttachmentDTO data = actCommentAttachmentService.get(id);
return new Result<ActCommentAttachmentDTO>().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();
}
}

43
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ActCommentAttachmentEntity> {
/**
* @Author sun
* @Description 查询通知评论所有人员的附件信息
**/
List<CommentFileDTO> selectActComFile(@Param("groupActId") String groupActId);
}

93
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
/**
* 文件格式JPGPNGPDFJPEGBMPMP4WMAM4AMP3DOCDOCXXLS
*/
private String attachmentFormat;
/**
* 附件类型图片 - image 视频 - video 语音 - voice 文档 - doc
*/
private String attachmentType;
/**
* 附件地址
*/
private String attachmentUrl;
/**
* 排序字段
*/
private Integer sort;
/**
* 语音或视频时长
*/
private Integer duration;
}

103
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ActCommentAttachmentEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<ActCommentAttachmentDTO>
* @author generator
* @date 2021-09-06
*/
PageData<ActCommentAttachmentDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<ActCommentAttachmentDTO>
* @author generator
* @date 2021-09-06
*/
List<ActCommentAttachmentDTO> list(Map<String, Object> 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<CommentFileDTO> getActComFile(String groupActId);
}

110
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ActCommentAttachmentDao, ActCommentAttachmentEntity> implements ActCommentAttachmentService {
@Override
public PageData<ActCommentAttachmentDTO> page(Map<String, Object> params) {
IPage<ActCommentAttachmentEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ActCommentAttachmentDTO.class);
}
@Override
public List<ActCommentAttachmentDTO> list(Map<String, Object> params) {
List<ActCommentAttachmentEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ActCommentAttachmentDTO.class);
}
private QueryWrapper<ActCommentAttachmentEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<ActCommentAttachmentEntity> 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<CommentFileDTO> getActComFile(String groupActId) {
return baseDao.selectActComFile(groupActId);
}
}

58
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<ActCommentDao, ActCom
private GroupActInfoService groupActInfoService;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private NoticeCommentService noticeCommentService;
@Autowired
private ActCommentAttachmentService actCommentAttachmentService;
/**
@ -74,6 +87,7 @@ public class ActCommentServiceImpl extends BaseServiceImpl<ActCommentDao, ActCom
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void submitComment(CommentFormDTO formDTO) {
//1、关闭和已取消不能评论
GroupActInfoDTO groupActInfoDTO = groupActInfoService.getGroupActInfoDTO(formDTO.getGroupActId());
@ -96,6 +110,10 @@ public class ActCommentServiceImpl extends BaseServiceImpl<ActCommentDao, ActCom
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg());
}
}
//图片安全校验
List<String> 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<ActCommentDao, ActCom
actCommentEntity.setCommentUserId(formDTO.getUserId());
actCommentEntity.setGroupActId(formDTO.getGroupActId());
baseDao.insert(actCommentEntity);
//4.保存活动评论附件数据
List<ActCommentAttachmentEntity> 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<ActCommentDao, ActCom
if (!result.success()) {
throw new RenException("调用user服务,获取用户基础数据失败");
}
//3.查询活动评论所有人员的附件信息
List<CommentFileDTO> 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<ActCommentDao, ActCom
l.setCommentUserName(user.getSurname().concat(user.getName()));
}
});
//每一条评论的附件信息
List<CommentFileDTO> imageList = new ArrayList<>();
for (CommentFileDTO f : fileList) {
if (l.getCommentUserId().equals(f.getUserId())) {
imageList.add(f);
}
}
l.setImageList(imageList);
});
}

85
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<NoticeCommentAttachmentDTO>> page(@RequestParam Map<String, Object> params){
PageData<NoticeCommentAttachmentDTO> page = noticeCommentAttachmentService.page(params);
return new Result<PageData<NoticeCommentAttachmentDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<NoticeCommentAttachmentDTO> get(@PathVariable("id") String id){
NoticeCommentAttachmentDTO data = noticeCommentAttachmentService.get(id);
return new Result<NoticeCommentAttachmentDTO>().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();
}
}

43
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<NoticeCommentAttachmentEntity> {
/**
* @Author sun
* @Description 查询通知评论所有人员的附件信息
**/
List<CommentFileDTO> selectNoticeComFile(@Param("noticeId") String noticeId);
}

93
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
/**
* 文件格式JPGPNGPDFJPEGBMPMP4WMAM4AMP3DOCDOCXXLS
*/
private String attachmentFormat;
/**
* 附件类型图片 - image 视频 - video 语音 - voice 文档 - doc
*/
private String attachmentType;
/**
* 附件地址
*/
private String attachmentUrl;
/**
* 排序字段
*/
private Integer sort;
/**
* 语音或视频时长
*/
private Integer duration;
}

103
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<NoticeCommentAttachmentEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<NoticeCommentAttachmentDTO>
* @author generator
* @date 2021-09-06
*/
PageData<NoticeCommentAttachmentDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<NoticeCommentAttachmentDTO>
* @author generator
* @date 2021-09-06
*/
List<NoticeCommentAttachmentDTO> list(Map<String, Object> 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<CommentFileDTO> getNoticeComFile(String noticeId);
}

7
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<NoticeCommentEntity> {
* @Description 通知评论列表查询
**/
List<NoticeCommentListResultDTO> noticeCommentList(NoticeCommentListFormDTO formDTO);
/**
* @Author sun
* @Description 文字图片安全校验
**/
void safetyCheck(List<String> wordList, List<String> imageList);
}

110
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<NoticeCommentAttachmentDao, NoticeCommentAttachmentEntity> implements NoticeCommentAttachmentService {
@Override
public PageData<NoticeCommentAttachmentDTO> page(Map<String, Object> params) {
IPage<NoticeCommentAttachmentEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, NoticeCommentAttachmentDTO.class);
}
@Override
public List<NoticeCommentAttachmentDTO> list(Map<String, Object> params) {
List<NoticeCommentAttachmentEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, NoticeCommentAttachmentDTO.class);
}
private QueryWrapper<NoticeCommentAttachmentEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<NoticeCommentAttachmentEntity> 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<CommentFileDTO> getNoticeComFile(String noticeId) {
return baseDao.selectNoticeComFile(noticeId);
}
}

103
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<NoticeCommentDao,
private String scanApiUrl;
@Value("${openapi.scan.method.textSyncScan}")
private String textSyncScanMethod;
@Value("${openapi.scan.method.imgSyncScan}")
private String imgSyncScanMethod;
@Autowired
private NoticeService noticeService;
@Autowired
private ResiGroupMemberService resiGroupMemberService;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private NoticeCommentAttachmentService noticeCommentAttachmentService;
/**
@ -106,6 +119,9 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl<NoticeCommentDao,
}
}
}
//图片安全校验
List<String> 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<NoticeCommentDao,
entity.setNoticeId(formDTO.getNoticeId());
entity.setCommentContent(formDTO.getCommentContent());
insert(entity);
//4.保存通知评论附件数据
List<NoticeCommentAttachmentEntity> 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<NoticeCommentDao,
}
List<UserBaseInfoResultDTO> resultDTOList = result.getData();
//3.封装数据并返回
//3.查询通知评论所有人员的附件信息
List<CommentFileDTO> 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<NoticeCommentDao,
}
});
l.setCommentUserName(name.toString());
//每一条评论的附件信息
List<CommentFileDTO> 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<String> wordList, List<String> 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<SyncScanResult> 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<SyncScanResult> 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());
}
}
}
}

2
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<NoticeDao, NoticeEntity>
* @Description 文字图片安全校验
**/
private void safetyCheck(List<String> wordList, List<String> imageList) {
if (imageList.size() != NumConstant.ZERO) {
if (wordList.size() != NumConstant.ZERO) {
wordList.forEach(word -> {
//创建话题内容审核
TextScanParamDTO textScanParamDTO = new TextScanParamDTO();

85
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PageData<ResiTopicCommentAttachmentDTO>> page(@RequestParam Map<String, Object> params){
PageData<ResiTopicCommentAttachmentDTO> page = resiTopicCommentAttachmentService.page(params);
return new Result<PageData<ResiTopicCommentAttachmentDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<ResiTopicCommentAttachmentDTO> get(@PathVariable("id") String id){
ResiTopicCommentAttachmentDTO data = resiTopicCommentAttachmentService.get(id);
return new Result<ResiTopicCommentAttachmentDTO>().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();
}
}

43
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ResiTopicCommentAttachmentEntity> {
/**
* @Author sun
* @Description 查询通知评论所有人员的附件信息
**/
List<CommentFileDTO> selectTopicComFile(@Param("topicId") String topicId);
}

93
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
/**
* 文件格式JPGPNGPDFJPEGBMPMP4WMAM4AMP3DOCDOCXXLS
*/
private String attachmentFormat;
/**
* 附件类型图片 - image 视频 - video 语音 - voice 文档 - doc
*/
private String attachmentType;
/**
* 附件地址
*/
private String attachmentUrl;
/**
* 排序字段
*/
private Integer sort;
/**
* 语音或视频时长
*/
private Integer duration;
}

102
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ResiTopicCommentAttachmentEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<ResiTopicCommentAttachmentDTO>
* @author generator
* @date 2021-09-06
*/
PageData<ResiTopicCommentAttachmentDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<ResiTopicCommentAttachmentDTO>
* @author generator
* @date 2021-09-06
*/
List<ResiTopicCommentAttachmentDTO> list(Map<String, Object> 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<CommentFileDTO> getTopicComFile(String topicId);
}

110
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<ResiTopicCommentAttachmentDao, ResiTopicCommentAttachmentEntity> implements ResiTopicCommentAttachmentService {
@Override
public PageData<ResiTopicCommentAttachmentDTO> page(Map<String, Object> params) {
IPage<ResiTopicCommentAttachmentEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, ResiTopicCommentAttachmentDTO.class);
}
@Override
public List<ResiTopicCommentAttachmentDTO> list(Map<String, Object> params) {
List<ResiTopicCommentAttachmentEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, ResiTopicCommentAttachmentDTO.class);
}
private QueryWrapper<ResiTopicCommentAttachmentEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<ResiTopicCommentAttachmentEntity> 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<CommentFileDTO> getTopicComFile(String topicId) {
return baseDao.selectTopicComFile(topicId);
}
}

68
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<ResiTopicCommen
@Autowired
ResiTopicService resiTopicService;
@Autowired
ResiGroupMemberService resiGroupMemberService;
@Autowired
EpmetUserFeignClient epmetUserFeignClient;
@Autowired
ResiGroupMemberRedis resiGroupMemberRedis;
@Autowired
ResiGroupRedis groupRedis;
@Autowired
ResiGroupMemberDao resiGroupMemberDao;
@Autowired
ResiTopicDao resiTopicdDao;
@Autowired
LoginUserUtil loginUserUtil;
@Autowired
private GovOrgFeignClient govOrgFeignClient;
@Autowired
ResiGroupDao resiGroupDao;
@Autowired
private NoticeCommentService noticeCommentService;
@Autowired
private ResiTopicCommentAttachmentService resiTopicCommentAttachmentService;
@Value("${openapi.scan.server.url}")
private String scanApiUrl;
@ -214,6 +216,10 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl<ResiTopicCommen
}
}
}
//图片安全校验
List<String> 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<ResiTopicCommen
}
}
//保存话题评论附件数据
List<ResiTopicCommentAttachmentEntity> 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<ResiTopicCommen
});
}
//查询话题评论所有人员的附件信息
List<CommentFileDTO> fileList = resiTopicCommentAttachmentService.getTopicComFile(commentFormDTO.getTopicId());
//封装数据并返回
comments.forEach(l -> {
//每一条评论的附件信息
List<CommentFileDTO> imageList = new ArrayList<>();
for (CommentFileDTO f : fileList) {
if (l.getUserId().equals(f.getUserId())) {
imageList.add(f);
}
}
l.setImageList(imageList);
});
}
return new Result<List<ResiCommentResultDTO>>().ok(comments);

25
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentAttachmentDao.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.modules.act.dao.ActCommentAttachmentDao">
<select id="selectActComFile" resultType="com.epmet.resi.group.dto.group.result.CommentFileDTO">
SELECT
file_name name,
attachment_size size,
attachment_format format,
attachment_type type,
attachment_url url,
sort sort,
duration duration,
created_by userId
FROM
act_comment_attachment
WHERE
del_flag = '0'
AND group_act_id = #{groupActId}
ORDER BY
created_by, sort ASC
</select>
</mapper>

25
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeCommentAttachmentDao.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.modules.notice.dao.NoticeCommentAttachmentDao">
<select id="selectNoticeComFile" resultType="com.epmet.resi.group.dto.group.result.CommentFileDTO">
SELECT
file_name name,
attachment_size size,
attachment_format format,
attachment_type type,
attachment_url url,
sort sort,
duration duration,
created_by userId
FROM
notice_comment_attachment
WHERE
del_flag = '0'
AND notice_id = #{noticeId}
ORDER BY
created_by, sort ASC<!-- 同一个人各类型文件靠在一起,按sort升序 -->
</select>
</mapper>

25
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentAttachmentDao.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.modules.topic.dao.ResiTopicCommentAttachmentDao">
<select id="selectTopicComFile" resultType="com.epmet.resi.group.dto.group.result.CommentFileDTO">
SELECT
file_name name,
attachment_size size,
attachment_format format,
attachment_type type,
attachment_url url,
sort sort,
duration duration,
created_by userId
FROM
resi_topic_comment_attachment
WHERE
del_flag = '0'
AND topic_id = #{topicId}
ORDER BY
created_by, sort ASC
</select>
</mapper>
Loading…
Cancel
Save