Commit 653f3196 by liangkaiping

copy

parent 2d2954d1
# comment-project
评论
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yizhi</groupId>
<artifactId>comment</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.yizhi</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>cloud-comment-api</artifactId>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-common-api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-system-api</artifactId>
<scope>provided</scope>
</dependency>-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.yizhi.comment.application.constans;
public interface Constant {
public final Integer STATE_DELETED = 0;
public final Integer NOT_DELETED = 0;
public final Integer DELETED = 1;
public final Integer UP = 1;
public final Integer DOWN = 2;
/**
* 对于举报,业务类型是帖子
*/
public final Integer TASK_TYPE_POSTS = 2;
/**
* 对于举报,业务类型是评论回复
*/
public final Integer TASK_TYPE_COMMENT_REPLY = 1;
/**
* 类型是评论
*/
public final Integer TYPE_COMMENT = 1;
/**
* 类型是回复
*/
public final Integer TYPE_REPLY = 2;
/**
* 类型是举报
*/
public final Integer TYPE_INFORM = 3;
/**
* 排序类型是最新回复
*/
public final Integer ORDER_BY_NEW_REPLY = 1;
/**
* 排序类型是最早回复
*/
public final Integer ORDER_BY_OLD_REPLY = 2;
public final Integer ZERO = 0;
/**
* 该回复已被删除
*
*/
public static final String COMMENT_HAS_DELETED = "该回复已被删除";
}
package com.yizhi.comment.application.feign;
import com.yizhi.comment.application.vo.StatisticsForumAccountVo;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map;
@FeignClient(name = "comment", contextId = "AdmireClient")
public interface AdmireClient {
@GetMapping("/remote/commentAdmire/up")
public boolean up(@ApiParam(name = "commentId",value = "评论或帖子id")@RequestParam(name = "commentId") Long commentId,@ApiParam(name = "bizType",value = "业务类型 1评论 2帖子") @RequestParam("bizType") Integer bizType);
@GetMapping("/remote/commentAdmire/down")
public boolean down(@ApiParam(name = "commentId",value = "评论或帖子id")@RequestParam(name = "commentId")Long commentId,@ApiParam(name = "bizType",value = "业务类型 1评论 2帖子") @RequestParam("bizType") Integer bizType);
@GetMapping("/remote/commentAdmire/getNum")
public Integer getNum(@RequestParam("bizType") Integer bizType,
@RequestParam(name = "taskId") Long taskId,
@RequestParam(name = "accountId",required = false) Long accountId);
/**
* 获取用户的相关数据Map
* @param bizType
* @return
*/
@GetMapping("/remote/commentAdmire/getPersonalDataMap")
public Map<Long, StatisticsForumAccountVo> getPersonalDataMap(@RequestParam("bizType") Integer bizType);
}
package com.yizhi.comment.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.comment.application.vo.InformRecordVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@FeignClient(name = "comment", contextId = "InformRecordClient")
public interface InformRecordClient {
@PostMapping("/remote/informRecord/save")
public Integer save(@RequestBody InformRecordVo informRecordVo);
@GetMapping("/remote/informRecord/getPage")
public Page<InformRecordVo> getPage(@RequestParam("taskType") Integer taskType,
@RequestParam("taskId") Long taskId,
@RequestParam("type") Integer type,
@RequestParam("terminalType") Integer terminalType,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize);
@GetMapping("/remote/informRecord/cancel")
public Integer cancel(@RequestParam("id") Long id);
@GetMapping("informRecord/cancelByCommentId")
public Integer cancelByCommentId(@RequestParam("taskType") Integer taskType,
@RequestParam("taskId") Long taskId,
@RequestParam("type") Integer type,
@RequestParam(value = "commentId",required = false) Long commentId);
// @GetMapping("/remote/informRecord/getPersonalDataMap")
// public Map<Long, Integer> getPersonalDataMap(@RequestParam("bizType") Integer bizType);
}
package com.yizhi.comment.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.comment.application.vo.*;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@FeignClient(name = "comment", contextId = "ManageCommentClient")
public interface ManageCommentClient {
@PostMapping("/remote/manage/comment/delete")
public String delateComment(@RequestBody CommentDelVO vo);
@PostMapping("/remote/manage/comment/save")
public NewCommentVo saveComment(@RequestBody NewCommentVo comment);
@GetMapping("/remote/manage/comment/list")
public Page<CommentVo> list(@RequestParam(name = "bizId") Long bizId, @RequestParam("bizType") Integer bizType, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize);
/**
* 评论(回复)上架
*
* @param id
* @param type
* @return boolean
*/
@GetMapping("/remote/manage/comment/up")
public Boolean up(@RequestParam("id") Long id, @RequestParam("type") Integer type);
/**
* 评论(回复)下架
*
* @param id
* @param type
* @return
*/
@GetMapping("/remote/manage/comment/down")
public Boolean down(@RequestParam("id") Long id, @RequestParam("type") Integer type);
@GetMapping("/remote/manage/comment/list/export")
public Map<String, Object> export(
@ApiParam(name = "bizId", value = "业务id") @RequestParam(name = "bizId") Long bizId,
@ApiParam(name = "bizType", value = "业务类型") @RequestParam("bizType") Integer bizType,
@ApiParam(name = "bizName", value = "业务名称") @RequestParam(name = "bizName") String bizName);
/**
* 学员端 评论列表
*
* @param accountId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/remote/manage/comment/api/list")
public Page<NewApiCommentVo> apiList(@RequestParam("bizId") Long bizId, @RequestParam("bizType") Integer bizType,
@RequestParam("accountId") Long accountId, @RequestParam("companyId") Long companyId, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize);
@GetMapping("/remote/manage/comment/getAllComments")
public List<NewCommentVo> getAllComments();
/**
* 管理端 评论(回复)下架或者是删除 若是评论则包含子级,否则不包含
*
* @param id
* @param type 1:评论、2-回复
* @param operationType 1-下架 2-删除
* @return
*/
@GetMapping("/remote/manage/comment/down/include/children")
public Integer downIncludeChildren(@RequestParam("id") Long id,
@RequestParam("type") Integer type,
@RequestParam("operationType") Integer operationType);
/**
*论坛 管理端--单个帖子--回复列表分页
* @param type
* @param postsId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/remote/manage/comment/getPageToManage")
public Page<ManageCommentVo> getPageToManage(@RequestParam("type") Integer type,
@RequestParam("postsId") Long postsId,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize);
/**
* 论坛--单个帖子的回复下载
* @return
*/
@GetMapping("/remote/manage/comment/forum/export")
public String exportFromForum(@RequestBody Map map);
@GetMapping("/remote/manage/comment/getPersonalDataMap")
public Map<Long, StatisticsForumAccountVo> getPersonalDataMap(@RequestParam("bizType") Integer bizType);
@GetMapping("/remote/manage/comment/getCommentNum")
public Integer getCommentNum(@RequestParam(name = "bizId") Long bizId,@RequestParam(name = "bizType") Integer bizType);
}
package com.yizhi.comment.application.feign;
import com.yizhi.comment.application.vo.domain.PdfPagesVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@FeignClient(name = "comment", contextId = "PdfPagesClient")
public interface PdfPagesClient {
@PostMapping("/remote/pdfPages/save")
public boolean save(@RequestBody List<PdfPagesVo> pdfPageVos);
@GetMapping("/remote/pdfPages/list")
public List<PdfPagesVo> list(@RequestParam("bizId")Long bizId, @RequestParam("bizType")Integer bizType);
}
package com.yizhi.comment.application.feign;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.comment.application.vo.CommentVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@FeignClient(name = "comment", contextId = "ReplyClient")
public interface ReplyClient {
/**
* 新增回复评论接口(保存)
* @param
* @return
*/
@PostMapping("/remote/reply/save")
public Boolean saveReply(@RequestBody NewReplyVo reply);
@GetMapping("/remote/reply/list")
public Page<CommentVo> list(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize);
/**
* 用于学员移动端回复列表查询
*/
@GetMapping("/remote/reply/list2")
public Page<NewReplyVo> replyList2(@RequestParam("commentId") Long commentId, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize);
}
package com.yizhi.comment.application.feign;
import com.yizhi.comment.application.vo.domain.SubscribeVo;
import com.yizhi.core.application.context.RequestContext;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@FeignClient(name = "comment", contextId = "SubscribeClient")
public interface SubscribeClient {
@GetMapping("/remote/subscribe/get")
public SubscribeVo get(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "bizType") Integer bizType, @RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId);
@GetMapping("/remote/subscribe/save")
public SubscribeVo save(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "bizType") Integer bizType, @RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId);
@GetMapping("/remote/subscribe/getMyList")
public List<Long> getMyList(@RequestParam(name = "bizType") Integer bizType,@RequestParam("accountId") Long accountId,@RequestParam("siteId") Long siteId,@RequestParam("companyId") Long companyId);
@GetMapping("/remote/subscribe/getAllList")
public List<SubscribeVo> getAllList();
@GetMapping("/remote/subscribe/getSubscribeNum")
public Integer getSubscribeNum(@RequestParam(name = "bizId") Long bizId,@RequestParam(name = "bizType") Integer bizType);
@PostMapping("/remote/subscribe/getMySubscribeNum")
public Integer getMySubscribeNum(@RequestBody RequestContext context);
}
package com.yizhi.comment.application.feign.student;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.comment.application.vo.CommentParam;
import com.yizhi.comment.application.vo.NewApiCommentVo;
import com.yizhi.comment.application.vo.PostsCommentVo;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(name = "comment", contextId = "StudentCommentClient")
public interface StudentCommentClient {
@PostMapping("/remote/student/comment/getPage")
public Page<NewApiCommentVo> getPage(@RequestBody CommentParam param);
/**
* 论坛 我收到的回复分页
*
* @param param
* @return
*/
@PostMapping("/remote/student/comment/myReceivedPage")
public Page<PostsCommentVo> myReceivedPage(@RequestBody CommentParam param);
/**
* 论坛 我收到的回复分页--查看对话
*
* @param id
* @return
*/
@GetMapping("/remote/student/comment/catCommunication")
public List<PostsCommentVo> catCommunication(@RequestParam("id") Long id);
/**
* 论坛 我发送的回复分页
*
* @param param
* @return
*/
@PostMapping("/remote/student/comment/mySendPage")
public Page<PostsCommentVo> mySendPage(@RequestBody CommentParam param);
/**
* 我的管理--回复管理--回复列表
*
* @param type
* @param postsId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/remote/student/comment/getPageByPostsId")
public Page<PostsCommentVo> getPageByPostsId(@ApiParam("type必传 ") @RequestParam("type") Integer type,
@ApiParam("帖子id ") @RequestParam("postsId") Long postsId,
@ApiParam("pageNo") @RequestParam("pageNo") Integer pageNo,
@ApiParam("pageSize ") @RequestParam("pageSize") Integer pageSize);
/**
* 论坛 评论(回复)--删除(下架) 包含子级回复
*
* @param id
* @param type
* @return
*/
@GetMapping("/remote/student/comment/down")
public Integer down(@RequestParam("id") Long id, @RequestParam("type") Integer type, @RequestParam("isInform") Boolean isInform);
/**
* 论坛的评论保存是可以保存评论附件的
* @param comment
* @return
*/
@PostMapping("/remote/student/comment/save")
public Integer studentSave(@RequestBody NewCommentVo comment);
/**
* 论坛我的回复--获取我的回复(收到的回复未查看的数量)
* @param taskType
* @param taskIds
* @return
*/
@GetMapping("/remote/student/comment/myNum")
public Integer myNum(@RequestParam("taskType") Integer taskType,
@RequestParam(value = "taskId",required = false) List<Long> taskIds);
/**
* 根据评论id 查询评论及其下的回复
* @param taskType
* @param taskId
* @param commentId
* @param orderType
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/remote/student/comment/getCommentDetails")
public NewApiCommentVo getCommentDetails(@ApiParam("taskType必传 ") @RequestParam("taskType") Integer taskType,
@ApiParam("业务id ") @RequestParam("taskId") Long taskId,
@ApiParam("评论id ") @RequestParam("commentId") Long commentId,
@ApiParam("作者id ") @RequestParam(value = "author",required = false) Long author,
@ApiParam("回复排序方式 ") @RequestParam("orderType") Integer orderType,
@ApiParam("回复的pageNo") @RequestParam("pageNo") Integer pageNo,
@ApiParam("回复的pageSize ") @RequestParam("pageSize") Integer pageSize);
}
package com.yizhi.comment.application.vo;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 评论点赞记录表
* </p>
*
*/
@Data
@ApiModel(value = "AdmireVO", description = "评论点赞记录表")
public class AdmireVO {
@ApiModelProperty(value = "点赞数")
private Integer admireNums = 0;
@ApiModelProperty(value = "是否已点赞")
private Boolean hasAdmire = false;
}
package com.yizhi.comment.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "评论删除参数")
public class CommentDelVO {
@ApiModelProperty(value = "评论回复Id 必传",required = true)
Long id;
@ApiModelProperty(value = "类型 必传 0评论 1回复",required = true)
Integer type;
}
package com.yizhi.comment.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "评论分页参数说明")
public class CommentParam {
@ApiModelProperty(value = "业务类型 0:课程、2:论坛、 7培训项目 15专辑", required = true)
Integer type;
@ApiModelProperty(value = "业务Id")
Long bizId;
@ApiModelProperty(value = "是否只看作者 默认否")
Boolean onlyAuthor = false;
@ApiModelProperty(value = "关键词")
String keyWord;
@ApiModelProperty(value = "作者Id")
Long author;
@ApiModelProperty(value = "排序类型:1-最新回复 2-最早回复")
Integer orderType;
@ApiModelProperty(value = "评论分页参数")
Integer pageNo = 1;
@ApiModelProperty(value = "评论分页参数")
Integer pageSize = 10;
@ApiModelProperty(value = "回复列表分页参数")
Integer replyPageNo = 1;
@ApiModelProperty(value = "回复列表分页参数")
Integer replyPageSize = Integer.MAX_VALUE;
}
package com.yizhi.comment.application.vo;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CommentVo {
private Long id;
@ApiModelProperty(value = "账号id")
private Long accountId;
@ApiModelProperty(value = "评论人")
private String commentator;
@ApiModelProperty(value = "评论人姓名")
private String commentatorName;
@ApiModelProperty(value = "评论对象")
private String replyName;
@ApiModelProperty(value = "评论对象id")
private Long replyId;
@ApiModelProperty(value = "评论内容")
private String content;
@ApiModelProperty(value = "评论时间")
private Date createTime;
@ApiModelProperty(value = "点赞数")
private Integer thumbsUp;
@ApiModelProperty(value = "用户头像")
private String userAvatar;
@ApiModelProperty(value = "回复数")
private Integer replys;
@ApiModelProperty("状态(1:上架|2:下架 默认为1)")
private Integer state;
@ApiModelProperty(value = "回复列表")
private List<NewReplyVo> replies = new ArrayList<>();
}
package com.yizhi.comment.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value = "InformCommentVo", description = "举报中的回复")
public class InformCommentVo {
private Long id;
@ApiModelProperty(value = "1:评论 2-回复")
private Integer type;
@ApiModelProperty(value = "账号id")
private Long accountId;
@ApiModelProperty(value = "评论人")
private String commentator;
@ApiModelProperty(value = "评论内容")
private String content;
@ApiModelProperty(value = "评论时间")
private Date createTime;
@ApiModelProperty(value = "是否被禁言")
private Boolean hasForbidden;
@ApiModelProperty(value = "评论人的状态")
private String status;
@ApiModelProperty(value = "评论回复的状态 1:上架 2:下架")
private Integer commentStatus;
@ApiModelProperty(value = "用户头像")
private String userAvatar;
}
package com.yizhi.comment.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@Data
@ApiModel(value = "InformRecordVo", description = "")
public class InformRecordVo {
private Long id;
@ApiModelProperty(value = "业务类型:2-帖子 ")
private Integer taskType;
@ApiModelProperty(value = "业务id task_type=2时,为帖子id")
private Long taskId;
@ApiModelProperty(value = "业务名称")
private String taskName;
@ApiModelProperty(value = "1-评论 2-回复")
private Integer type;
@ApiModelProperty(value = "1:上架 2:下架")
private Integer status;
@ApiModelProperty(value = "评论回复id")
private Long commentId;
@ApiModelProperty(value = "举报描述(理由)")
private String description;
@ApiModelProperty(value = "举报附件")
private List<TaskAppendixVo> taskAppendixVos;
@ApiModelProperty(value = "举报的回复内容")
private InformCommentVo informCommentVo;
@ApiModelProperty(value = "举报人id")
private Long createById;
@ApiModelProperty(value = "举报人用户名")
private String createByName;
@ApiModelProperty(value = "举报时间")
private Date createTime;
@ApiModelProperty(value = "用户头像")
private String userAvatar;
}
package com.yizhi.comment.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel(value = "ManageCommentVo", description = "管理端评论回复")
public class ManageCommentVo {
@ApiModelProperty(value = "序号")
private Integer num;
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "1:评论、2-回复")
private Integer type;
@ApiModelProperty(value = "业务id")
private Long taskId;
@ApiModelProperty(value = "账号id")
private Long accountId;
@ApiModelProperty(value = "评论人")
private String commentator;
@ApiModelProperty(value = "评论人真实姓名")
private String fullName;
@ApiModelProperty(value = "评论人头像")
private String photo;
@ApiModelProperty(value = "评论内容")
private String content;
@ApiModelProperty(value = "评论时间")
private Date createTime;
@ApiModelProperty(value = "评论时间string格式")
private String createTimeString;
@ApiModelProperty(value = "被@的人用户id")
private Long beAnswerId;
@ApiModelProperty(value = "被@的人用户名")
private String beAnswerName;
@ApiModelProperty(value = "评论id")
private Long commentId;
@ApiModelProperty(value = "回复父级id 如果是回复评论,则为0")
private Long replyParentId;
@ApiModelProperty(value = "当前评论点赞数")
private Integer commentAdmires;
@ApiModelProperty(value = "当前回复状态 0:删除 1:上架 2:下架 ")
private Integer status;
@ApiModelProperty(value = "是否被禁言")
private Boolean hasForbidden = false;
@ApiModelProperty(value = "当前回复状态String")
private String statusString;
}
package com.yizhi.comment.application.vo;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public class NewApiCommentVo {
private Long id;
@ApiModelProperty(value = "账号id")
private Long accountId;
@ApiModelProperty(value = "评论人")
private String commentator;
@ApiModelProperty(value = "评论内容")
private String content;
@ApiModelProperty(value = "评论时间")
private Date createTime;
@ApiModelProperty(value = "评论时间String")
private String createTimeString;
@ApiModelProperty(value = "点赞数")
private Integer thumbsUp;
@ApiModelProperty(value = "是否点赞 1 是 0否")
private Integer status;
@ApiModelProperty(value = "是否是楼主 true:是")
private Boolean isAuthor = false;
@ApiModelProperty(value = "是否被禁言 true:是")
private Boolean hasForbidden = false;
@ApiModelProperty(value = "是否为当前用户创建的记录 true:是")
private Boolean isSelf = false;
@ApiModelProperty(value = "用户头像")
private String userAvatar;
@ApiModelProperty(value = "回复数")
private Integer replys;
@ApiModelProperty(value = "回复列表")
private List<NewReplyVo> replies = new ArrayList<>();
@ApiModelProperty(value = "回复分页列表")
private Page<NewReplyVo> replyPage = new Page<>();
@ApiModelProperty(value = "剩余回复数")
private Integer restReplys;
@ApiModelProperty(value = "评论附件")
private List<TaskAppendixVo> taskAppendixVos;
}
package com.yizhi.comment.application.vo;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotations.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PdfVO implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "源文件url")
private String originalFileUrl;
@ApiModelProperty(value = "源文件名,带后缀")
private String originalFile;
private Long createById;
@TableField("company_id")
private Long companyId;
@TableField("site_id")
private Long siteId;
private Long bizId;
private Integer bizType;
}
package com.yizhi.comment.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
@ApiModel(value = "PostsCommentVo", description = "带帖子信息的评论回复")
public class PostsCommentVo {
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "1:评论、2-回复")
private Integer type;
@ApiModelProperty(value = "账号id")
private Long accountId;
@ApiModelProperty(value = "评论人")
private String commentator;
@ApiModelProperty(value = "评论人头像")
private String photo;
@ApiModelProperty(value = "评论内容")
private String content;
@ApiModelProperty(value = "评论时间")
private Date createTime;
@ApiModelProperty(value = "评论时间string格式")
private String createTimeString;
@ApiModelProperty(value = "帖子id")
private Long postsId;
@ApiModelProperty(value = "帖子标题")
private String postsTitle;
@ApiModelProperty(value = "帖子内容")
private String postsContent;
@ApiModelProperty(value = "帖子封面")
private String logo;
@ApiModelProperty(value = "帖子是否已被删除")
private Boolean postsHasDeleted = false;
@ApiModelProperty(value = "帖子创建时间")
private Date postsCreateTime;
@ApiModelProperty(value = "被@的人用户id")
private Long beAnswerId;
@ApiModelProperty(value = "被@的人用户名")
private String beAnswerName;
@ApiModelProperty(value = "被@的人说的话")
private String beAnswerContent;
@ApiModelProperty(value = "被@的人是否被禁言")
private Boolean beAnswerHasForbidden = false;
@ApiModelProperty(value = "评论id")
private Long commentId;
@ApiModelProperty(value = "回复父级id 如果是回复评论,则为0")
private Long replyParentId;
@ApiModelProperty(value = "创建该记录的用户在该贴是否被禁言")
private Boolean hasForbidden = false;
@ApiModelProperty(value = "是否为当前用户创建的记录 true:是")
private Boolean isSelf = false;
@ApiModelProperty(value = "是否是帖子作者")
private Boolean isAuthor = false;
@ApiModelProperty(value = "当前回复是否被删除 true:是 ")
private Boolean IsDeleted = false;
@ApiModelProperty(value = "最上层的回复是否被删除了 true:是 ")
private Boolean commentHasDeleted = false;
@ApiModelProperty(value = "被@的人说的话是否被删除啦 true:删除")
private Boolean beAnswerContentHasDelete = false;
@ApiModelProperty(value = "是否已点赞 true:已点赞")
private Boolean isAdmire = false;
@ApiModelProperty(value = "当前回复状态")
private Integer status;
@ApiModelProperty(value = "当前用户是否被禁言")
private Boolean currentHasForbidden = false;
@ApiModelProperty(value = "评论附件")
private List<TaskAppendixVo> taskAppendixVos;
}
package com.yizhi.comment.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
*
* </p>
*
* @author taoge123
* @since 2020-02-13
*/
@Data
@ApiModel(value = "StatisticsForumAccountVo", description = "")
public class StatisticsForumAccountVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "用户id")
private Long author;
@ApiModelProperty(value = "已发表数")
private Integer sendNum;
@ApiModelProperty(value = "阅读数 ")
private Integer readNum;
@ApiModelProperty(value = "评论数 ")
private Integer commentNum;
@ApiModelProperty(value = "回复数 ")
private Integer replyNum;
@ApiModelProperty(value = "草稿帖子数 ")
private Integer draftNum;
@ApiModelProperty(value = "精选帖子数")
private Integer highlightNum;
@ApiModelProperty(value = "置顶帖子数")
private Integer topNum;
@ApiModelProperty(value = "点赞数")
private Integer admireNum;
@ApiModelProperty(value = "被点赞数")
private Integer beAdmiredNum;
@ApiModelProperty(value = "举报数")
private Integer informNum;
@ApiModelProperty(value = "被举报数")
private Integer beInformNum;
@ApiModelProperty(value = "被禁言数")
private Integer beForbiddenNum;
}
package com.yizhi.comment.application.vo;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@Data
@ApiModel(value = "TaskAppendixVo", description = "举报评论附件表")
public class TaskAppendixVo {
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "业务类型 1-评论 2-回复(已弃用) 3-举报 ")
private Integer taskType;
@ApiModelProperty(value = "业务id")
private Long taskId;
@ApiModelProperty(value = "附件名称 必填")
private String name;
@ApiModelProperty(value = "附件大小 必填")
private Double fileSize;
@ApiModelProperty(value = "文件后缀名 必填")
private String fileSuffer;
@ApiModelProperty(value = "下载路径 必填")
private String url;
@ApiModelProperty(value = "附件类型 :1、文档;2、图片;3、音频;4、视频;5、其他(压缩包)")
private Integer fileType;
}
package com.yizhi.comment.application.vo.domain;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@Data
@ApiModel(value = "InformRecordVo", description = "")
@TableName("inform_record")
public class InformRecordVo {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "业务类型:2-帖子 ")
private Integer taskType;
@ApiModelProperty(value = "业务id task_type=2时,为帖子id")
private Long taskId;
@ApiModelProperty(value = "0-帖子 1-评论 2-回复")
private Integer type;
@ApiModelProperty(value = "评论回复id")
private Long commentId;
@ApiModelProperty(value = "1:上架 2:下架")
private Integer status;
@ApiModelProperty(value = "0:举报 1:移除举报")
private Integer deleted;
@ApiModelProperty(value = "举报描述")
private String description;
@ApiModelProperty(value = "举报人id")
private Long createById;
private String createByName;
@ApiModelProperty(value = "举报时间")
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
private Long companyId;
private Long siteId;
private Long orgId;
}
package com.yizhi.comment.application.vo.domain;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 评论点赞记录表
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "NewCommentAdmireVo", description = "评论点赞记录表")
@TableName("new_comment_admire")
public class NewCommentAdmireVo {
private static final long serialVersionUID = 1L;
private Long Id;
@ApiModelProperty(value = "点赞人id")
private Long accountId;
@ApiModelProperty(value = "评论或帖子id")
private Long commentId;
@ApiModelProperty(value = "业务类型 1评论 2帖子")
private Integer bizType;
private Long createById;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
@ApiModelProperty(value = "0:取消 1:点赞")
private Integer state;
}
package com.yizhi.comment.application.vo.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.yizhi.comment.application.vo.TaskAppendixVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* <p>
* 评论
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "NewCommentVo", description = "评论")
@TableName("new_comment")
public class NewCommentVo {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "业务id")
private Long bizId;
@ApiModelProperty(value = "业务名称")
private String bizName;
@ApiModelProperty(value = "业务类型 0课程、2:论坛、 7培训项目 15专辑")
private Integer bizType;
@ApiModelProperty(value = "评论内容")
private String content;
@ApiModelProperty(value = "用于论坛--我的回复是否已读 0:未读(默认)")
private Integer isRead;
private Long createById;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
@ApiModelProperty(value = "0:删除 1:上架 2:下架")
private Integer state;
private Long orgId;
private Long siteId;
@ApiModelProperty(value = "头像")
private String userAvatar;
private Long companyId;
@ApiModelProperty(value = "评论附件")
@TableField(exist = false)
private List<TaskAppendixVo> taskAppendixVos;
}
package com.yizhi.comment.application.vo.domain;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 回复
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "NewReplyVo", description = "回复")
@TableName("new_reply")
public class NewReplyVo {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "业务id")
private Long bizId;
@ApiModelProperty(value = "业务名称")
private String bizName;
@ApiModelProperty(value = "业务类型 0课程 2:论坛 7培训项目 15专辑")
private Integer bizType;
@ApiModelProperty(value = "评论id")
private Long commentId;
@ApiModelProperty(value = "被回复人id(评论人或者回复人)")
private Long commenterId;
@ApiModelProperty(value = "回复父级id")
private Long replyParentId;
@ApiModelProperty(value = "回复内容")
private String content;
private Long createById;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
@ApiModelProperty(value = "0:删除 1:上架 2:下架")
private Integer state;
@ApiModelProperty(value = "头像")
private String userAvatar;
@ApiModelProperty(value = "被回复人姓名")
private String commenterName;
@ApiModelProperty(value = "用于论坛--我的回复是否已读 0:未读(默认)")
private Integer isRead;
@ApiModelProperty(value = "是否是楼主 true:是")
private Boolean isAuthor = false;
@ApiModelProperty(value = "是否是自己创建的评论 true:是")
private Boolean isSelf = false;
@ApiModelProperty(value = "是否被禁言 true:是")
private Boolean hasForbidden = false;
}
package com.yizhi.comment.application.vo.domain;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@Api(tags = "PdfPagesVo", description = "pdf图片")
@TableName("pdf_pages")
public class PdfPagesVo {
private static final long serialVersionUID = 1L;
private Long id;
@ApiModelProperty(value = "页数")
private Integer pdfPage;
@ApiModelProperty(value = "业务id")
private Long bizId;
@ApiModelProperty(value = "业务类型")
private Integer bizType;
@ApiModelProperty(value = "图片地址")
private String imageUrl;
}
package com.yizhi.comment.application.vo.domain;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 订阅
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Data
@ApiModel(value = "SubscribeVo", description = "订阅")
@TableName("subscribe")
public class SubscribeVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "业务类型 0课程 7培训项目 15专辑")
private Integer bizType;
@ApiModelProperty(value = "业务id")
private Long bizId;
@ApiModelProperty(value = "状态")
private Integer status;
@ApiModelProperty(value = "所属站点id")
private Long siteId;
@ApiModelProperty(value = "学员id")
private Long accountId;
private String createByName;
private Date createTime;
private Long updateById;
private String updateByName;
private Date updateTime;
private Long companyId;
}
package com.yizhi.comment.application.vo.domain;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@Data
@ApiModel(value = "InformAppendix", description = "举报评论附件表")
@TableName("task_appendix")
public class TaskAppendixVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键 ")
private Long id;
@ApiModelProperty(value = "业务类型 1-评论 2-回复(已弃用) 3-举报 ")
private Integer taskType;
@ApiModelProperty(value = "业务id")
private Long taskId;
@ApiModelProperty(value = "附件名称 ")
private String name;
@ApiModelProperty(value = "附件大小")
private Double fileSize;
@ApiModelProperty(value = "文件后缀名")
private String fileSuffer;
@ApiModelProperty(value = "下载路径")
private String url;
@ApiModelProperty(value = "附件类型 :1、文档;2、图片;3、音频;4、视频;5、其他(压缩包)")
private Integer fileType;
@ApiModelProperty(value = "是否删除 0:未删除、1:已删除")
private Integer deleted;
@ApiModelProperty(value = "创建者id")
private Long createById;
@ApiModelProperty(value = "创建者名称")
private String createByName;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新者id")
private Long updateById;
@ApiModelProperty(value = "修改者名称")
private String updateByName;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yizhi</groupId>
<artifactId>comment</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>cloud-comment</artifactId>
<dependencies>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-comment-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-system-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-forum-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-point-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-site-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-course-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-job-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-newMessage-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-course-studyLog-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-album-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yizhi</groupId>
<artifactId>cloud-orm</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- deploy 时跳过该模块 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.yizhi.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.yizhi"})
@ComponentScan(basePackages = {"com.yizhi"})
public class CommentApplication {
public static void main(String[] args) {
SpringApplication.run(CommentApplication.class, args);
}
}
package com.yizhi.application;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("评论")
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.yizhi.application"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("评论")
//版本
.version("1.0")
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("docs.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.NewCommentAdmire;
import com.yizhi.application.service.ICommentAdmireService;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.comment.application.vo.domain.NewCommentAdmireVo;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.forum.application.feign.remote.RemotePostsClient;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.Map;
/**
* <p>
* 评论点赞记录表 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/commentAdmire")
public class CommentAdmireController {
@Autowired
private ICommentAdmireService commentAdmireService;
@Autowired
private IdGenerator idGenerator;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private RemotePostsClient remotePostsClient;
@GetMapping("/up")
public boolean up(@RequestParam(name = "commentId") Long commentId, @RequestParam("bizType") Integer bizType) {
RequestContext context = ContextHolder.get();
NewCommentAdmire commentAdmire = new NewCommentAdmire();
commentAdmire.setId(idGenerator.generate());
commentAdmire.setAccountId(context.getAccountId());
commentAdmire.setCommentId(commentId);
commentAdmire.setBizType(bizType);
commentAdmire.setCreateById(context.getAccountId());
commentAdmire.setCreateByName(context.getAccountName());
commentAdmire.setCreateTime(new Date());
commentAdmire.setUpdateById(context.getAccountId());
commentAdmire.setUpdateByName(context.getAccountName());
commentAdmire.setUpdateTime(new Date());
commentAdmire.setState(1);
boolean insert = commentAdmireService.insert(commentAdmire);
if (insert) {
updatePostsInfo(bizType, commentId);
}
return insert;
}
@GetMapping("/down")
public boolean down(@RequestParam(name = "commentId")Long commentId, @RequestParam("bizType") Integer bizType) {
RequestContext res = ContextHolder.get();
NewCommentAdmire commentAdmire = new NewCommentAdmire();
commentAdmire.setCommentId(commentId);
commentAdmire.setBizType(bizType);
commentAdmire.setAccountId(res.getAccountId());
commentAdmire.setState(1);
boolean delete = commentAdmireService.delete(new EntityWrapper<>(commentAdmire));
if (delete){
updatePostsInfo(bizType, commentId);
}
return delete ;
}
/**
* 获取点赞数
* @param bizType
* @param taskId
* @param accountId
* @return
*/
@GetMapping("/getNum")
public Integer getNum(@RequestParam("bizType") Integer bizType,
@RequestParam(name = "taskId") Long taskId,
@RequestParam(name = "accountId",required = false) Long accountId) {
RequestContext res = ContextHolder.get();
NewCommentAdmire commentAdmire = new NewCommentAdmire();
commentAdmire.setState(Constant.UP);
commentAdmire.setBizType(bizType);
commentAdmire.setCommentId(taskId);
commentAdmire.setAccountId(accountId);
return commentAdmireService.selectCount(new EntityWrapper<>(commentAdmire));
}
/**
* 获取<业务id,点赞数></>>Map
* @param bizType
* @return
*/
@GetMapping("/getPersonalDataMap")
public Map<Long, Integer> getPersonalDataMap(@RequestParam("bizType") Integer bizType) {
return commentAdmireService.getCountsMap(bizType);
}
/**
* 点赞或者取消点赞 更新帖子信息
* @param bizType
* @param bizId
*/
public void updatePostsInfo(Integer bizType, Long bizId) {
//如果业务类型对帖子的
if (Constant.TASK_TYPE_POSTS.equals(bizType)) {
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
NewCommentAdmire commentAdmire = new NewCommentAdmire();
commentAdmire.setBizType(bizType);
commentAdmire.setCommentId(bizId);
commentAdmire.setState(1);
//更新帖子新回复、最新评论时间、评论数、回复数字段
com.yizhi.forum.application.vo.domain.PostsVo vo = new com.yizhi.forum.application.vo.domain.PostsVo();
vo.setId(bizId);
vo.setThumbsNum(commentAdmireService.selectCount(new EntityWrapper<>(commentAdmire)));
remotePostsClient.updateInfo(vo);
}
});
}
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.NewComment;
import com.yizhi.application.domain.NewReply;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.ICommentService;
import com.yizhi.application.service.IReplyService;
import com.yizhi.application.task.CommentListExportAsync;
import com.yizhi.application.task.ForumCommentExportAsync;
import com.yizhi.comment.application.vo.*;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.core.application.cache.CacheNamespace;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.vo.AccountVO;
import com.yizhi.util.application.json.JsonUtil;
import com.yizhi.util.application.sensitive.SensitivewordFilter;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* <p>
* 评论 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/manage/comment")
public class CommentController {
@Autowired
private ICommentService commentService;
@Autowired
private IReplyService replyService;
@Autowired
private IdGenerator idGenerator;
@Autowired
private AccountClient accountClient;
@Autowired
private com.yizhi.application.mapper.CommentMapper CommentMapper;
@Autowired
private CommentListExportAsync commentListExportAsync;
@Autowired
private ForumCommentExportAsync forumCommentExportAsync;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private RedisCache redisCache;
@PostMapping("/delete")
public String delateComment(@RequestBody CommentDelVO vo) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
if (vo.getType().equals(0)) {
NewComment comment = commentService.selectById(vo.getId());
if (comment != null) {
comment.setState(0);
comment.setUpdateById(accountId);
comment.setUpdateByName(name);
comment.setUpdateTime(date);
if (commentService.updateById(comment)){
NewComment newCommentVo = commentService.selectById(comment.getId());
commentService.updatePostsInfo(newCommentVo.getBizId(), newCommentVo.getBizType(), newCommentVo.getSiteId(), null, false,false);
}
return "success";
}
} else {
NewReply reply = replyService.selectById(vo.getId());
if (reply != null) {
reply.setState(0);
reply.setUpdateById(accountId);
reply.setUpdateByName(name);
reply.setUpdateTime(date);
if (replyService.updateById(reply)){
NewReply newReplyVo = replyService.selectById(reply.getId());
commentService.updatePostsInfo(newReplyVo.getBizId(), newReplyVo.getBizType(), null, null, false,false);
}
return "success";
}
}
return "error";
}
@PostMapping("/save")
public NewComment saveComment(@RequestBody NewComment comment) {
RequestContext context = ContextHolder.get();
Date date = new Date();
comment.setId(idGenerator.generate());
comment.setCreateById(context.getAccountId());
comment.setCreateByName(context.getAccountName());
comment.setCreateTime(date);
comment.setSiteId(context.getSiteId());
comment.setOrgId(context.getOrgId());
if (commentService.insert(comment)) {
return comment;
}
return null;
}
@GetMapping("list")
public Page<com.yizhi.comment.application.vo.CommentVo> list(@RequestParam(name = "bizId") Long bizId, @RequestParam("bizType") Integer bizType,
@RequestParam(name = "pageNo") Integer pageNo, @RequestParam(name = "pageSize") Integer pageSize) {
Page<com.yizhi.comment.application.vo.CommentVo> page = new Page<com.yizhi.comment.application.vo.CommentVo>();
page = commentService.getCommentPage(bizId, bizType, pageNo, pageSize);
String fullName;
String name;
for (CommentVo vo : page.getRecords()) {
AccountVO account = accountClient.findById(vo.getAccountId());
name = account.getName();
fullName = account.getFullName();
vo.setCommentator(name);
vo.setCommentatorName(fullName);
vo.setReplyName("--");
vo.setContent(StringEscapeUtils.unescapeJava(vo.getContent()));
vo.setUserAvatar(account.getHeadPortrait());
}
return page;
}
/**
* 评论(回复)上架
*
* @param id
* @param type
* @return boolean
*/
@GetMapping("/up")
public Boolean up(@RequestParam("id") Long id, @RequestParam("type") Integer type) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
if (type == 0) {
NewComment comment = commentService.selectById(id);
if (comment != null) {
comment.setState(1);
comment.setUpdateById(accountId);
comment.setUpdateByName(name);
comment.setUpdateTime(date);
commentService.updateById(comment);
return true;
} else {
return false;
}
} else {
NewReply reply = replyService.selectById(id);
if (reply != null) {
reply.setState(1);
reply.setUpdateById(accountId);
reply.setUpdateByName(name);
reply.setUpdateTime(date);
replyService.updateById(reply);
return true;
} else {
return false;
}
}
}
/**
* 评论(回复)下架
*
* @param id
* @param type
* @return
*/
@GetMapping("/down")
public Boolean down(@RequestParam("id") Long id, @RequestParam("type") Integer type) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
if (type == 0) {
NewComment comment = commentService.selectById(id);
if (comment != null) {
comment.setState(2);
comment.setUpdateById(accountId);
comment.setUpdateByName(name);
comment.setUpdateTime(date);
commentService.updateById(comment);
return true;
} else {
return false;
}
} else {
NewReply reply = replyService.selectById(id);
if (reply != null) {
reply.setState(2);
reply.setUpdateById(accountId);
reply.setUpdateByName(name);
reply.setUpdateTime(date);
replyService.updateById(reply);
return true;
} else {
return false;
}
}
}
@GetMapping("/list/export")
public Map<String, Object> export(
@ApiParam(name = "bizId", value = "业务id") @RequestParam(name = "bizId") Long bizId,
@ApiParam(name = "bizType", value = "业务类型") @RequestParam("bizType") Integer bizType,
@ApiParam(name = "bizName", value = "业务名称") @RequestParam(name = "bizName") String bizName) {
RequestContext requestContext = ContextHolder.get();
Date submitTime = new Date();
Long taskId = submitTime.getTime();
String serialNo = "USER-EXPORT-" + taskId;
String taskName = "导出评论信息-" + taskId;
String result = "任务编号:" + serialNo + "。任务名称:" + taskName;
Map<String, Object> map = new HashMap<String, Object>();
map.put("accountId", requestContext.getAccountId());
map.put("siteId", requestContext.getSiteId());
map.put("companyId", requestContext.getCompanyId());
map.put("serialNo", serialNo);
map.put("taskId", taskId);
map.put("submitTime", submitTime);
map.put("taskName", taskName);
map.put("bizId", bizId);
map.put("bizType", bizType);
map.put("bizName", bizName);
map.put("result", result);
commentListExportAsync.execute(map, true);
return map;
}
/**
* 学员端 评论列表
*
* @param courseId
* @param accountId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/api/list")
public Page<NewApiCommentVo> apiList(@RequestParam("bizId") Long bizId, @RequestParam("bizType") Integer bizType,
@RequestParam("accountId") Long accountId, @RequestParam("companyId") Long companyId, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Page<NewApiCommentVo> page = commentService.apiCommentPage(bizId, bizType, accountId, pageNo, pageSize);
List<NewReply> replies = replyService.list(bizId);
Map<Long, List<NewReplyVo>> listMap = new HashMap<>();
List<Long> accountIds = new ArrayList<>();
for (NewReply replyVo : replies) {
NewReplyVo reply1=new NewReplyVo();
BeanUtils.copyProperties(replyVo,reply1);
if (listMap.containsKey(reply1.getCommentId())) {
listMap.get(reply1.getCommentId()).add(reply1);
} else {
List<NewReplyVo> replies1 = new ArrayList<>();
replies1.add(reply1);
listMap.put(reply1.getCommentId(), replies1);
}
}
for (NewApiCommentVo listCommentVo : page.getRecords()) {
if (listMap.containsKey(listCommentVo.getId())) {
listCommentVo.setReplies(listMap.get(listCommentVo.getId()));
}
//需要获得用户信息的评论人id
if (!accountIds.contains(listCommentVo.getAccountId())) {
accountIds.add(listCommentVo.getAccountId());
}
List<NewReplyVo> children = listCommentVo.getReplies();
//需要获得用户信息的回复人id
if (CollectionUtils.isNotEmpty(children)) {
for (NewReplyVo commentReplyVO : children) {
if (!accountIds.contains(commentReplyVO.getCommenterId())) {
accountIds.add(commentReplyVO.getCommenterId());
}
}
}
}
//根据用户ids获取用户信息并放到map中
List<AccountVO> accountVOList = accountClient.idsGet(accountIds);
Map<Long, AccountVO> accountVOMap = new HashMap<>(16);
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (AccountVO accountVO : accountVOList) {
accountVOMap.put(accountVO.getId(), accountVO);
}
}
getRecords(page, accountVOMap,companyId);
return page;
}
@GetMapping("getAllComments")
public List<NewCommentVo> getAllComments(){
List<NewComment> result = new ArrayList<NewComment>();
List<NewComment> list = CommentMapper.getallComments();
if (CollectionUtils.isNotEmpty(list)) {
result.addAll(list);
for(NewComment comment:list) {
NewReply reply = new NewReply();
reply.setCommenterId(comment.getId());
List<NewReply> replies = replyService.selectList(new EntityWrapper<NewReply>(reply));
if (CollectionUtils.isNotEmpty(replies)) {
for(NewReply vo:replies) {
NewComment newCommentVo = new NewComment();
newCommentVo.setId(vo.getId());
newCommentVo.setBizId(vo.getBizId());
newCommentVo.setBizType(vo.getBizType());
newCommentVo.setCreateById(vo.getCreateById());
result.add(newCommentVo);
}
}
}
}List<NewCommentVo> list2=new ArrayList<>();
for (NewComment n:result
) {
NewCommentVo NV=new NewCommentVo();
BeanUtils.copyProperties(n,NV);
list2.add(NV);
}
return list2;
}
private void getRecords(Page<NewApiCommentVo> page, Map<Long, AccountVO> accountVOMap, Long companyId) {
if (CollectionUtils.isNotEmpty(page.getRecords())) {
Set<String> sensitiveWordList = new HashSet<>();
String sensitiveValues = (String) redisCache.hget(CacheNamespace.REDIS_SENSITIVE_WORD_INFO, companyId.toString());
if (StringUtils.isNotBlank(sensitiveValues)) {
sensitiveWordList = JsonUtil.json2Ojbect(sensitiveValues, Set.class);
}
for (NewApiCommentVo commentVO : page.getRecords()) {
AccountVO accountVO = accountVOMap.get(commentVO.getAccountId());
//组装评论人信息
if (null != accountVO) {
commentVO.setCommentator((accountVO.getFullName()==null||accountVO.getFullName()=="")?accountVO.getName():accountVO.getFullName());
commentVO.setUserAvatar(accountVO.getHeadPortrait() == null ? "" : accountVO.getHeadPortrait());
}
//敏感词过滤评论内容
if (CollectionUtils.isNotEmpty(sensitiveWordList)) {
if (null != commentVO.getContent()) {
commentVO.setContent(filterWord(commentVO.getContent(), sensitiveWordList));
}
}
if (CollectionUtils.isNotEmpty(commentVO.getReplies())) {
for (NewReplyVo commentReplyVO : commentVO.getReplies()) {
AccountVO commentAccount = accountVOMap.get(commentReplyVO.getCreateById());
AccountVO replyAccount = accountVOMap.get(commentReplyVO.getCommenterId());
//组装回复人信息
if (null != commentAccount) {
commentReplyVO.setCreateByName(commentAccount.getFullName()==""||commentAccount.getFullName()==null?commentAccount.getName():commentAccount.getFullName());
}
//组装被回复人信息
if (null != replyAccount) {
commentReplyVO.setCommenterName(replyAccount.getFullName()==""||replyAccount.getFullName()==null?replyAccount.getName():replyAccount.getFullName());
}
//敏感词过滤回复内容
if (null != commentReplyVO.getContent()) {
commentReplyVO.setContent(filterWord(commentReplyVO.getContent(), sensitiveWordList));
}
}
}
}
}
}
/**
* 过滤敏感词
*
* @param content 评论内容
* @param sensitiveWordList 已设置的敏感词集合
* @return
*/
public String filterWord(String content, Set<String> sensitiveWordList) {
if (sensitiveWordList != null) {
if (!StringUtils.isBlank(content)) {
return SensitivewordFilter.sensitiveFilter(content, sensitiveWordList);
}
}
return content;
}
/**
* 管理端 评论(回复)下架或者删除 若是评论则包含子级,否则不包含
*
* @param id
* @param type 1:评论、2-回复
* @param operationType 1-下架 2-删除
* @return
*/
@GetMapping("/down/include/children")
public Integer downIncludeChildren(@RequestParam("id") Long id,
@RequestParam("type") Integer type,
@RequestParam("operationType") Integer operationType) {
if (type == 1) {
if (commentService.down(operationType, id) > 0) {
NewComment newCommentVo = commentService.selectById(id);
if (operationType == 2) {
//删除才需要更新
commentService.updatePostsInfo(newCommentVo.getBizId(), newCommentVo.getBizType(), newCommentVo.getSiteId(), null, false, false);
}
return 1;
}
return 0;
} else {
if (replyService.down(operationType, id) > 0) {
NewReply newReplyVo = replyService.selectById(id);
if (operationType == 2) {
commentService.updatePostsInfo(newReplyVo.getBizId(), newReplyVo.getBizType(), null, null, false, false);
}
return 1;
}
return 0;
}
}
/**
*论坛 管理端--单个帖子--回复列表分页
* @param type
* @param postsId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/getPageToManage")
@ApiOperation(value = "管理端--单个帖子--回复列表分页", response = ManageCommentVo.class)
public Page<ManageCommentVo> getPageToManage(@ApiParam("type业务类型 1:帖子 必传 ") @RequestParam("type") Integer type,
@ApiParam("帖子id ") @RequestParam("postsId") Long postsId,
@ApiParam("pageNo") @RequestParam("pageNo") Integer pageNo,
@ApiParam("pageSize ") @RequestParam("pageSize") Integer pageSize){
return commentService.getPageToManage(type,postsId,pageNo,pageSize);
}
/**
* 论坛--单个帖子的回复下载
* @return
*/
@GetMapping("/forum/export")
public String exportFromForum(@RequestBody Map map) {
forumCommentExportAsync.execute(map, true);
return "ok";
}
/**
* 获取用户的相关数据Map
* @param bizType
* @return
*/
@GetMapping("/getPersonalDataMap")
public Map<Long, StatisticsForumAccountVo> getPersonalDataMap(@RequestParam("bizType") Integer bizType) {
return commentService.getPersonalDataMap(bizType);
}
@GetMapping("/getCommentNum")
public Integer getCommentNum(@RequestParam(name = "bizId") Long bizId,@RequestParam(name = "bizType") Integer bizType) {
NewComment comment = new NewComment();
comment.setBizId(bizId);
comment.setBizType(bizType);
comment.setState(1);
return commentService.selectCount(new EntityWrapper<NewComment>(comment));
}
}
package com.yizhi.application.controller;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.comment.application.feign.InformRecordClient;
import com.yizhi.application.service.IInformRecordService;
import com.yizhi.comment.application.vo.InformRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 前端控制器
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@RestController
@RequestMapping("/informRecord")
public class InformRecordController implements InformRecordClient {
@Autowired
private IInformRecordService informRecordService;
@Override
@PostMapping("/save")
public Integer save(@RequestBody InformRecordVo informRecordVo) {
return informRecordService.save(informRecordVo);
}
@Override
@GetMapping("/getPage")
public Page<InformRecordVo> getPage(@RequestParam("taskType") Integer taskType,
@RequestParam("taskId") Long taskId,
@RequestParam("type") Integer type,
@RequestParam("terminalType") Integer terminalType,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
return informRecordService.getPage(taskType, taskId, type, terminalType, pageNo, pageSize);
}
@Override
@GetMapping("/cancel")
public Integer cancel(@RequestParam("id") Long id) {
return informRecordService.cancel(id);
}
@Override
@GetMapping("/cancelByCommentId")
public Integer cancelByCommentId(@RequestParam("taskType") Integer taskType,
@RequestParam("taskId") Long taskId,
@RequestParam("type") Integer type,
@RequestParam(value = "commentId",required = false) Long commentId) {
return informRecordService.cancelByCommentId(taskType, taskId, type, commentId);
}
// /**
// * 获取<业务id,举报数></>>Map
// * @param bizType
// * @return
// */
// @Override
// @GetMapping("/getPersonalDataMap")
// public Map<Long, Integer> getPersonalDataMap(@RequestParam("bizType") Integer bizType) {
// return informRecordService.getCountsMap(bizType);
// }
}
package com.yizhi.application.controller;
import com.yizhi.application.domain.NewReply;
import com.yizhi.application.service.ICommentService;
import com.yizhi.application.service.IReplyService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.core.application.cache.CacheNamespace;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.util.application.json.JsonUtil;
import com.yizhi.util.application.sensitive.SensitivewordFilter;
import com.yizhi.system.application.vo.AccountVO;
import com.yizhi.comment.application.vo.CommentVo;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
/**
* <p>
* 回复 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/reply")
public class ReplyController {
@Autowired
private ICommentService commentService;
@Autowired
private IReplyService replyService;
@Autowired
private IdGenerator idGenerator;
@Autowired
private AccountClient accountClient;
@Autowired
private RedisCache redisCache;
/**
* 新增回复评论接口(保存)
* @param
* @return
*/
@PostMapping("/save")
public Boolean saveReply(@RequestBody NewReply reply){
RequestContext context = ContextHolder.get();
Date date = new Date();
if (reply.getReplyParentId()!=null&&reply.getReplyParentId()!=0) {
NewReply newReplyVo = replyService.selectById(reply.getReplyParentId());
if (newReplyVo ==null) {
return false;
}
}else {
reply.setReplyParentId(0L);
}
reply.setId(idGenerator.generate());
reply.setCreateById(context.getAccountId());
reply.setCreateByName(context.getAccountName());
reply.setCreateTime(date);
if (replyService.insert(reply)){
commentService.updatePostsInfo(reply.getBizId(),reply.getBizType(),context.getSiteId(),date,true,false);
return true;
}
return false;
}
@GetMapping("/list")
public Page<CommentVo> list(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize) {
Page<CommentVo> page = new Page<CommentVo>();
page = replyService.getCommentPage(bizId, pageNo, pageSize);
List<Long> accountIds = new ArrayList<>();
Map<Long, AccountVO> accountVOMap = new HashMap<>(16);
for(CommentVo vo:page.getRecords()) {
if (!accountIds.contains(vo.getAccountId())) {
accountIds.add(vo.getAccountId());
}
if (!accountIds.contains(vo.getReplyId())) {
accountIds.add(vo.getReplyId());
}
}
List<AccountVO> accountVOList = accountClient.idsGet(accountIds);
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (AccountVO accountVO : accountVOList) {
accountVOMap.put(accountVO.getId(), accountVO);
}
}
//将用户名放入返回结果中
for (CommentVo commentReplyVO : page.getRecords()) {
if (null != accountVOMap.get(commentReplyVO.getAccountId())) {
AccountVO commentAccount = accountVOMap.get(commentReplyVO.getAccountId());
commentReplyVO.setCommentator(commentAccount.getName());
commentReplyVO.setCommentatorName(commentAccount.getFullName()==""||commentAccount.getFullName()==null?commentAccount.getName():commentAccount.getFullName());
commentReplyVO.setUserAvatar(accountVOMap.get(commentReplyVO.getAccountId()).getHeadPortrait());
}
if (null != accountVOMap.get(commentReplyVO.getReplyId())) {
AccountVO replyAccount = accountVOMap.get(commentReplyVO.getReplyId());
commentReplyVO.setReplyName(replyAccount.getFullName()==""||replyAccount.getFullName()==null?replyAccount.getName():replyAccount.getFullName());
}
}
return page;
}
/**
* 用于学员移动端回复列表查询
* @param commmentId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/list2")
public Page<NewReply> replyList2(@RequestParam("commentId") Long commentId, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
RequestContext res = ContextHolder.get();
Page<NewReply> page = new Page<NewReply>(pageNo, pageSize);
NewReply reply = new NewReply();
reply.setCommentId(commentId);
reply.setState(1);
EntityWrapper<NewReply> wrapper = new EntityWrapper<NewReply>(reply);
List<String> list = new ArrayList<String>();
list.add("createTime");
wrapper.orderDesc(list);
replyService.selectPage(page, wrapper);
//获取评论人和被评论人id并获取信息放入map中
List<Long> accountIds = new ArrayList<>();
Map<Long, AccountVO> accountVOMap = new HashMap<>(16);
for (NewReply listCommentVo : page.getRecords()) {
if (!accountIds.contains(listCommentVo.getCreateById())) {
accountIds.add(listCommentVo.getCreateById());
}
if (!accountIds.contains(listCommentVo.getCommenterId())) {
accountIds.add(listCommentVo.getCommenterId());
}
}
List<AccountVO> accountVOList = accountClient.idsGet(accountIds);
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (AccountVO accountVO : accountVOList) {
accountVOMap.put(accountVO.getId(), accountVO);
}
}
//获取敏感词
Set<String> sensitiveWordList = new HashSet<>();
String sensitiveValues = (String) redisCache.hget(CacheNamespace.REDIS_SENSITIVE_WORD_INFO, res.getCompanyId().toString());
if (StringUtils.isNotBlank(sensitiveValues)) {
sensitiveWordList = JsonUtil.json2Ojbect(sensitiveValues, Set.class);
}
//将用户名放入返回结果中
for (NewReply commentReplyVO : page.getRecords()) {
//过滤敏感词
if (CollectionUtils.isNotEmpty(sensitiveWordList)) {
if (null != commentReplyVO.getContent()) {
commentReplyVO.setContent(filterWord(commentReplyVO.getContent(), sensitiveWordList));
}
}
if (null != accountVOMap.get(commentReplyVO.getCreateById())) {
AccountVO commentAccount = accountVOMap.get(commentReplyVO.getCreateById());
commentReplyVO.setCreateByName(commentAccount.getFullName()==""||commentAccount.getFullName()==null?commentAccount.getName():commentAccount.getFullName());
commentReplyVO.setUserAvatar(accountVOMap.get(commentReplyVO.getCreateById()).getHeadPortrait());
}
if (null != accountVOMap.get(commentReplyVO.getCommenterId())) {
AccountVO replyAccount = accountVOMap.get(commentReplyVO.getCommenterId());
commentReplyVO.setCommenterName(replyAccount.getFullName()==""||replyAccount.getFullName()==null?replyAccount.getName():replyAccount.getFullName());
}
}
return page;
}
/**
* 过滤敏感词
*
* @param content 评论内容
* @param sensitiveWordList 已设置的敏感词集合
* @return
*/
public String filterWord(String content, Set<String> sensitiveWordList) {
if (sensitiveWordList != null) {
if (!StringUtils.isBlank(content)) {
return SensitivewordFilter.sensitiveFilter(content, sensitiveWordList);
}
}
return content;
}
}
package com.yizhi.application.controller;
import com.yizhi.application.domain.Subscribe;
import com.yizhi.application.mapper.SubscribeMapper;
import com.yizhi.comment.application.vo.domain.SubscribeVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.album.application.feign.AlbumClient;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.ISubscribeService;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
/**
* <p>
* 订阅 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/subscribe")
public class SubscribeController {
@Autowired
private ISubscribeService subscribeService;
@Autowired
private SubscribeMapper subscribeMapper;
@Autowired
IdGenerator idGenerator;
@Autowired
private AlbumClient albumClient;
@GetMapping("/get")
public Subscribe get(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "bizType") Integer bizType, @RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId) {
Subscribe subscribeVo = new Subscribe();
subscribeVo.setSiteId(siteId);
subscribeVo.setCompanyId(companyId);
subscribeVo.setAccountId(accountId);
subscribeVo.setBizId(bizId);
subscribeVo.setBizType(bizType);
EntityWrapper<Subscribe> wrapper = new EntityWrapper<Subscribe>(subscribeVo);
Subscribe one = subscribeService.selectOne(wrapper);
if (one==null) {
subscribeVo.setStatus(0);
return subscribeVo;
}
return one;
}
@GetMapping("/save")
public Subscribe save(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "bizType") Integer bizType, @RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId) {
Date date = new Date();
Subscribe subscribeVo = new Subscribe();
subscribeVo.setSiteId(siteId);
subscribeVo.setCompanyId(companyId);
subscribeVo.setAccountId(accountId);
subscribeVo.setBizId(bizId);
subscribeVo.setBizType(bizType);
EntityWrapper<Subscribe> wrapper = new EntityWrapper<Subscribe>(subscribeVo);
Subscribe one = subscribeService.selectOne(wrapper);
if (one==null) {
one = new Subscribe();
one.setId(idGenerator.generate());
one.setBizId(bizId);
one.setBizType(bizType);
one.setCompanyId(companyId);
one.setSiteId(siteId);
one.setAccountId(accountId);
one.setCreateTime(date);
one.setStatus(1);
subscribeService.insert(one);
}else {
one.setUpdateById(accountId);
one.setUpdateTime(date);
one.setStatus(one.getStatus().equals(0)?1:0);
subscribeService.updateById(one);
}
return one;
}
@GetMapping("/getMyList")
public List<Long> getMyList(@RequestParam(name = "bizType") Integer bizType,@RequestParam("accountId") Long accountId,@RequestParam("siteId") Long siteId,@RequestParam("companyId") Long companyId){
List<Long> list = subscribeService.getMyList(bizType, accountId, siteId, companyId);
return list;
}
@GetMapping("getAllList")
public List<Subscribe> getAllList(){
List<Subscribe> list = subscribeMapper.getAllList();
return list;
}
@GetMapping("/getSubscribeNum")
public Integer getSubscribeNum(@RequestParam(name = "bizId") Long bizId,@RequestParam(name = "bizType") Integer bizType) {
Subscribe subscribeVo = new Subscribe();
subscribeVo.setBizId(bizId);
subscribeVo.setBizType(bizType);
subscribeVo.setStatus(1);
return subscribeService.selectCount(new EntityWrapper<Subscribe>(subscribeVo));
}
@PostMapping("/getMySubscribeNum")
public Integer getMySubscribeNum(@RequestBody RequestContext context) {
Integer num = 0;
List<Long> ids = subscribeMapper.getMyList(null, context.getAccountId(), context.getSiteId(), context.getCompanyId());
if (!CollectionUtils.isEmpty(ids)) {
//专辑数量
num = albumClient.getSubcribeNum(ids);
}
return num;
}
}
package com.yizhi.application.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@RestController
@RequestMapping("/informAppendix")
public class TaskAppendixController {
}
package com.yizhi.application.controller.remote;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.NewCommentAdmire;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.ICommentAdmireService;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.comment.application.vo.domain.NewCommentAdmireVo;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.forum.application.feign.remote.RemotePostsClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.Map;
/**
* <p>
* 评论点赞记录表 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController(value = "CommentAdmireControllerRemote")
@RequestMapping("/remote/commentAdmire")
public class CommentAdmireController {
@Autowired
private ICommentAdmireService commentAdmireService;
@Autowired
private IdGenerator idGenerator;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private RemotePostsClient remotePostsClient;
@GetMapping("/up")
public boolean up(@RequestParam(name = "commentId") Long commentId, @RequestParam("bizType") Integer bizType) {
RequestContext context = ContextHolder.get();
NewCommentAdmire commentAdmire = new NewCommentAdmire();
commentAdmire.setId(idGenerator.generate());
commentAdmire.setAccountId(context.getAccountId());
commentAdmire.setCommentId(commentId);
commentAdmire.setBizType(bizType);
commentAdmire.setCreateById(context.getAccountId());
commentAdmire.setCreateByName(context.getAccountName());
commentAdmire.setCreateTime(new Date());
commentAdmire.setUpdateById(context.getAccountId());
commentAdmire.setUpdateByName(context.getAccountName());
commentAdmire.setUpdateTime(new Date());
commentAdmire.setState(1);
boolean insert = commentAdmireService.insert(commentAdmire);
if (insert) {
updatePostsInfo(bizType, commentId);
}
return insert;
}
@GetMapping("/down")
public boolean down(@RequestParam(name = "commentId")Long commentId, @RequestParam("bizType") Integer bizType) {
RequestContext res = ContextHolder.get();
NewCommentAdmire commentAdmire = new NewCommentAdmire();
commentAdmire.setCommentId(commentId);
commentAdmire.setBizType(bizType);
commentAdmire.setAccountId(res.getAccountId());
commentAdmire.setState(1);
boolean delete = commentAdmireService.delete(new EntityWrapper<>(commentAdmire));
if (delete){
updatePostsInfo(bizType, commentId);
}
return delete ;
}
/**
* 获取点赞数
* @param bizType
* @param taskId
* @param accountId
* @return
*/
@GetMapping("/getNum")
public Integer getNum(@RequestParam("bizType") Integer bizType,
@RequestParam(name = "taskId") Long taskId,
@RequestParam(name = "accountId",required = false) Long accountId) {
RequestContext res = ContextHolder.get();
NewCommentAdmire commentAdmire = new NewCommentAdmire();
commentAdmire.setState(Constant.UP);
commentAdmire.setBizType(bizType);
commentAdmire.setCommentId(taskId);
commentAdmire.setAccountId(accountId);
return commentAdmireService.selectCount(new EntityWrapper<>(commentAdmire));
}
/**
* 获取<业务id,点赞数></>>Map
* @param bizType
* @return
*/
@GetMapping("/getPersonalDataMap")
public Map<Long, Integer> getPersonalDataMap(@RequestParam("bizType") Integer bizType) {
return commentAdmireService.getCountsMap(bizType);
}
/**
* 点赞或者取消点赞 更新帖子信息
* @param bizType
* @param bizId
*/
public void updatePostsInfo(Integer bizType, Long bizId) {
//如果业务类型对帖子的
if (Constant.TASK_TYPE_POSTS.equals(bizType)) {
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
NewCommentAdmire commentAdmire = new NewCommentAdmire();
commentAdmire.setBizType(bizType);
commentAdmire.setCommentId(bizId);
commentAdmire.setState(1);
//更新帖子新回复、最新评论时间、评论数、回复数字段
com.yizhi.forum.application.vo.domain.PostsVo vo = new com.yizhi.forum.application.vo.domain.PostsVo();
vo.setId(bizId);
vo.setThumbsNum(commentAdmireService.selectCount(new EntityWrapper<>(commentAdmire)));
remotePostsClient.updateInfo(vo);
}
});
}
}
}
package com.yizhi.application.controller.remote;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.NewComment;
import com.yizhi.application.domain.NewReply;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.core.application.cache.CacheNamespace;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.util.application.json.JsonUtil;
import com.yizhi.util.application.sensitive.SensitivewordFilter;
import com.yizhi.system.application.vo.AccountVO;
import com.yizhi.comment.application.vo.StatisticsForumAccountVo;
import com.yizhi.application.service.ICommentService;
import com.yizhi.application.service.IReplyService;
import com.yizhi.application.task.CommentListExportAsync;
import com.yizhi.application.task.ForumCommentExportAsync;
import com.yizhi.comment.application.vo.CommentDelVO;
import com.yizhi.comment.application.vo.CommentVo;
import com.yizhi.comment.application.vo.ManageCommentVo;
import com.yizhi.comment.application.vo.NewApiCommentVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* <p>
* 评论 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController(value = "CommentControllerRemote")
@RequestMapping("/remote/manage/comment")
public class CommentController {
@Autowired
private ICommentService commentService;
@Autowired
private IReplyService replyService;
@Autowired
private IdGenerator idGenerator;
@Autowired
private AccountClient accountClient;
@Autowired
private com.yizhi.application.mapper.CommentMapper CommentMapper;
@Autowired
private CommentListExportAsync commentListExportAsync;
@Autowired
private ForumCommentExportAsync forumCommentExportAsync;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private RedisCache redisCache;
@PostMapping("/delete")
public String delateComment(@RequestBody CommentDelVO vo) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
if (vo.getType().equals(0)) {
NewComment comment = commentService.selectById(vo.getId());
if (comment != null) {
comment.setState(0);
comment.setUpdateById(accountId);
comment.setUpdateByName(name);
comment.setUpdateTime(date);
if (commentService.updateById(comment)){
NewComment newCommentVo = commentService.selectById(comment.getId());
commentService.updatePostsInfo(newCommentVo.getBizId(), newCommentVo.getBizType(), newCommentVo.getSiteId(), null, false,false);
}
return "success";
}
} else {
NewReply reply = replyService.selectById(vo.getId());
if (reply != null) {
reply.setState(0);
reply.setUpdateById(accountId);
reply.setUpdateByName(name);
reply.setUpdateTime(date);
if (replyService.updateById(reply)){
NewReply newReplyVo = replyService.selectById(reply.getId());
commentService.updatePostsInfo(newReplyVo.getBizId(), newReplyVo.getBizType(), null, null, false,false);
}
return "success";
}
}
return "error";
}
@PostMapping("/save")
public NewComment saveComment(@RequestBody NewComment comment) {
RequestContext context = ContextHolder.get();
Date date = new Date();
comment.setId(idGenerator.generate());
comment.setCreateById(context.getAccountId());
comment.setCreateByName(context.getAccountName());
comment.setCreateTime(date);
comment.setSiteId(context.getSiteId());
comment.setOrgId(context.getOrgId());
if (commentService.insert(comment)) {
return comment;
}
return null;
}
@GetMapping("list")
public Page<CommentVo> list(@RequestParam(name = "bizId") Long bizId, @RequestParam("bizType") Integer bizType,
@RequestParam(name = "pageNo") Integer pageNo, @RequestParam(name = "pageSize") Integer pageSize) {
Page<CommentVo> page = new Page<CommentVo>();
page = commentService.getCommentPage(bizId, bizType, pageNo, pageSize);
String fullName;
String name;
for (CommentVo vo : page.getRecords()) {
AccountVO account = accountClient.findById(vo.getAccountId());
name = account.getName();
fullName = account.getFullName();
vo.setCommentator(name);
vo.setCommentatorName(fullName);
vo.setReplyName("--");
vo.setContent(StringEscapeUtils.unescapeJava(vo.getContent()));
vo.setUserAvatar(account.getHeadPortrait());
}
return page;
}
/**
* 评论(回复)上架
*
* @param id
* @param type
* @return boolean
*/
@GetMapping("/up")
public Boolean up(@RequestParam("id") Long id, @RequestParam("type") Integer type) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
if (type == 0) {
NewComment comment = commentService.selectById(id);
if (comment != null) {
comment.setState(1);
comment.setUpdateById(accountId);
comment.setUpdateByName(name);
comment.setUpdateTime(date);
commentService.updateById(comment);
return true;
} else {
return false;
}
} else {
NewReply reply = replyService.selectById(id);
if (reply != null) {
reply.setState(1);
reply.setUpdateById(accountId);
reply.setUpdateByName(name);
reply.setUpdateTime(date);
replyService.updateById(reply);
return true;
} else {
return false;
}
}
}
/**
* 评论(回复)下架
*
* @param id
* @param type
* @return
*/
@GetMapping("/down")
public Boolean down(@RequestParam("id") Long id, @RequestParam("type") Integer type) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
if (type == 0) {
NewComment comment = commentService.selectById(id);
if (comment != null) {
comment.setState(2);
comment.setUpdateById(accountId);
comment.setUpdateByName(name);
comment.setUpdateTime(date);
commentService.updateById(comment);
return true;
} else {
return false;
}
} else {
NewReply reply = replyService.selectById(id);
if (reply != null) {
reply.setState(2);
reply.setUpdateById(accountId);
reply.setUpdateByName(name);
reply.setUpdateTime(date);
replyService.updateById(reply);
return true;
} else {
return false;
}
}
}
@GetMapping("/list/export")
public Map<String, Object> export(
@ApiParam(name = "bizId", value = "业务id") @RequestParam(name = "bizId") Long bizId,
@ApiParam(name = "bizType", value = "业务类型") @RequestParam("bizType") Integer bizType,
@ApiParam(name = "bizName", value = "业务名称") @RequestParam(name = "bizName") String bizName) {
RequestContext requestContext = ContextHolder.get();
Date submitTime = new Date();
Long taskId = submitTime.getTime();
String serialNo = "USER-EXPORT-" + taskId;
String taskName = "导出评论信息-" + taskId;
String result = "任务编号:" + serialNo + "。任务名称:" + taskName;
Map<String, Object> map = new HashMap<String, Object>();
map.put("accountId", requestContext.getAccountId());
map.put("siteId", requestContext.getSiteId());
map.put("companyId", requestContext.getCompanyId());
map.put("serialNo", serialNo);
map.put("taskId", taskId);
map.put("submitTime", submitTime);
map.put("taskName", taskName);
map.put("bizId", bizId);
map.put("bizType", bizType);
map.put("bizName", bizName);
map.put("result", result);
commentListExportAsync.execute(map, true);
return map;
}
/**
* 学员端 评论列表
*
* @param courseId
* @param accountId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/api/list")
public Page<NewApiCommentVo> apiList(@RequestParam("bizId") Long bizId, @RequestParam("bizType") Integer bizType,
@RequestParam("accountId") Long accountId, @RequestParam("companyId") Long companyId, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Page<NewApiCommentVo> page = commentService.apiCommentPage(bizId, bizType, accountId, pageNo, pageSize);
List<NewReply> replies = replyService.list(bizId);
Map<Long, List<NewReplyVo>> listMap = new HashMap<>();
List<Long> accountIds = new ArrayList<>();
for (NewReply reply1 : replies) {
NewReplyVo replyVo=new NewReplyVo();
BeanUtils.copyProperties(reply1,replyVo);
if (listMap.containsKey(reply1.getCommentId())) {
listMap.get(reply1.getCommentId()).add(replyVo);
} else {
List<NewReplyVo> replies1 = new ArrayList<>();
replies1.add(replyVo);
listMap.put(reply1.getCommentId(), replies1);
}
}
for (NewApiCommentVo listCommentVo : page.getRecords()) {
if (listMap.containsKey(listCommentVo.getId())) {
listCommentVo.setReplies(listMap.get(listCommentVo.getId()));
}
//需要获得用户信息的评论人id
if (!accountIds.contains(listCommentVo.getAccountId())) {
accountIds.add(listCommentVo.getAccountId());
}
List<NewReplyVo> children = listCommentVo.getReplies();
//需要获得用户信息的回复人id
if (CollectionUtils.isNotEmpty(children)) {
for (NewReplyVo commentReplyVO : children) {
if (!accountIds.contains(commentReplyVO.getCommenterId())) {
accountIds.add(commentReplyVO.getCommenterId());
}
}
}
}
//根据用户ids获取用户信息并放到map中
List<AccountVO> accountVOList = accountClient.idsGet(accountIds);
Map<Long, AccountVO> accountVOMap = new HashMap<>(16);
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (AccountVO accountVO : accountVOList) {
accountVOMap.put(accountVO.getId(), accountVO);
}
}
getRecords(page, accountVOMap,companyId);
return page;
}
@GetMapping("getAllComments")
public List<NewCommentVo> getAllComments(){
List<NewComment> result = new ArrayList<>();
List<NewComment> list = CommentMapper.getallComments();
if (CollectionUtils.isNotEmpty(list)) {
result.addAll(list);
for(NewComment comment:list) {
NewReply reply = new NewReply();
reply.setCommenterId(comment.getId());
List<NewReply> replies = replyService.selectList(new EntityWrapper<NewReply>(reply));
if (CollectionUtils.isNotEmpty(replies)) {
for(NewReply vo:replies) {
NewComment newComment = new NewComment();
newComment.setId(vo.getId());
newComment.setBizId(vo.getBizId());
newComment.setBizType(vo.getBizType());
newComment.setCreateById(vo.getCreateById());
result.add(newComment);
}
}
}
}
List<NewCommentVo> list2=new ArrayList<>();
for (NewComment n:result
) {
NewCommentVo NV=new NewCommentVo();
BeanUtils.copyProperties(n,NV);
list2.add(NV);
}
return list2;
}
private void getRecords(Page<NewApiCommentVo> page, Map<Long, AccountVO> accountVOMap, Long companyId) {
if (CollectionUtils.isNotEmpty(page.getRecords())) {
Set<String> sensitiveWordList = new HashSet<>();
String sensitiveValues = (String) redisCache.hget(CacheNamespace.REDIS_SENSITIVE_WORD_INFO, companyId.toString());
if (StringUtils.isNotBlank(sensitiveValues)) {
sensitiveWordList = JsonUtil.json2Ojbect(sensitiveValues, Set.class);
}
for (NewApiCommentVo commentVO : page.getRecords()) {
AccountVO accountVO = accountVOMap.get(commentVO.getAccountId());
//组装评论人信息
if (null != accountVO) {
commentVO.setCommentator((accountVO.getFullName()==null||accountVO.getFullName()=="")?accountVO.getName():accountVO.getFullName());
commentVO.setUserAvatar(accountVO.getHeadPortrait() == null ? "" : accountVO.getHeadPortrait());
}
//敏感词过滤评论内容
if (CollectionUtils.isNotEmpty(sensitiveWordList)) {
if (null != commentVO.getContent()) {
commentVO.setContent(filterWord(commentVO.getContent(), sensitiveWordList));
}
}
if (CollectionUtils.isNotEmpty(commentVO.getReplies())) {
for (NewReplyVo commentReplyVO : commentVO.getReplies()) {
AccountVO commentAccount = accountVOMap.get(commentReplyVO.getCreateById());
AccountVO replyAccount = accountVOMap.get(commentReplyVO.getCommenterId());
//组装回复人信息
if (null != commentAccount) {
commentReplyVO.setCreateByName(commentAccount.getFullName()==""||commentAccount.getFullName()==null?commentAccount.getName():commentAccount.getFullName());
}
//组装被回复人信息
if (null != replyAccount) {
commentReplyVO.setCommenterName(replyAccount.getFullName()==""||replyAccount.getFullName()==null?replyAccount.getName():replyAccount.getFullName());
}
//敏感词过滤回复内容
if (null != commentReplyVO.getContent()) {
commentReplyVO.setContent(filterWord(commentReplyVO.getContent(), sensitiveWordList));
}
}
}
}
}
}
/**
* 过滤敏感词
*
* @param content 评论内容
* @param sensitiveWordList 已设置的敏感词集合
* @return
*/
public String filterWord(String content, Set<String> sensitiveWordList) {
if (sensitiveWordList != null) {
if (!StringUtils.isBlank(content)) {
return SensitivewordFilter.sensitiveFilter(content, sensitiveWordList);
}
}
return content;
}
/**
* 管理端 评论(回复)下架或者删除 若是评论则包含子级,否则不包含
*
* @param id
* @param type 1:评论、2-回复
* @param operationType 1-下架 2-删除
* @return
*/
@GetMapping("/down/include/children")
public Integer downIncludeChildren(@RequestParam("id") Long id,
@RequestParam("type") Integer type,
@RequestParam("operationType") Integer operationType) {
if (type == 1) {
if (commentService.down(operationType, id) > 0) {
NewComment newCommentVo = commentService.selectById(id);
if (operationType == 2) {
//删除才需要更新
commentService.updatePostsInfo(newCommentVo.getBizId(), newCommentVo.getBizType(), newCommentVo.getSiteId(), null, false, false);
}
return 1;
}
return 0;
} else {
if (replyService.down(operationType, id) > 0) {
NewReply newReplyVo = replyService.selectById(id);
if (operationType == 2) {
commentService.updatePostsInfo(newReplyVo.getBizId(), newReplyVo.getBizType(), null, null, false, false);
}
return 1;
}
return 0;
}
}
/**
*论坛 管理端--单个帖子--回复列表分页
* @param type
* @param postsId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/getPageToManage")
@ApiOperation(value = "管理端--单个帖子--回复列表分页", response = ManageCommentVo.class)
public Page<ManageCommentVo> getPageToManage(@ApiParam("type业务类型 1:帖子 必传 ") @RequestParam("type") Integer type,
@ApiParam("帖子id ") @RequestParam("postsId") Long postsId,
@ApiParam("pageNo") @RequestParam("pageNo") Integer pageNo,
@ApiParam("pageSize ") @RequestParam("pageSize") Integer pageSize){
return commentService.getPageToManage(type,postsId,pageNo,pageSize);
}
/**
* 论坛--单个帖子的回复下载
* @return
*/
@GetMapping("/forum/export")
public String exportFromForum(@RequestBody Map map) {
forumCommentExportAsync.execute(map, true);
return "ok";
}
/**
* 获取用户的相关数据Map
* @param bizType
* @return
*/
@GetMapping("/getPersonalDataMap")
public Map<Long, StatisticsForumAccountVo> getPersonalDataMap(@RequestParam("bizType") Integer bizType) {
return commentService.getPersonalDataMap(bizType);
}
@GetMapping("/getCommentNum")
public Integer getCommentNum(@RequestParam(name = "bizId") Long bizId,@RequestParam(name = "bizType") Integer bizType) {
NewComment comment = new NewComment();
comment.setBizId(bizId);
comment.setBizType(bizType);
comment.setState(1);
return commentService.selectCount(new EntityWrapper<NewComment>(comment));
}
}
package com.yizhi.application.controller.remote;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.service.IInformRecordService;
import com.yizhi.comment.application.feign.InformRecordClient;
import com.yizhi.comment.application.vo.InformRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 前端控制器
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@RestController(value = "InformRecordControllerRemote")
@RequestMapping("/remote/informRecord")
public class InformRecordController implements InformRecordClient {
@Autowired
private IInformRecordService informRecordService;
@Override
@PostMapping("/save")
public Integer save(@RequestBody InformRecordVo informRecordVo) {
return informRecordService.save(informRecordVo);
}
@Override
@GetMapping("/getPage")
public Page<InformRecordVo> getPage(@RequestParam("taskType") Integer taskType,
@RequestParam("taskId") Long taskId,
@RequestParam("type") Integer type,
@RequestParam("terminalType") Integer terminalType,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
return informRecordService.getPage(taskType, taskId, type, terminalType, pageNo, pageSize);
}
@Override
@GetMapping("/cancel")
public Integer cancel(@RequestParam("id") Long id) {
return informRecordService.cancel(id);
}
@Override
@GetMapping("/cancelByCommentId")
public Integer cancelByCommentId(@RequestParam("taskType") Integer taskType,
@RequestParam("taskId") Long taskId,
@RequestParam("type") Integer type,
@RequestParam(value = "commentId",required = false) Long commentId) {
return informRecordService.cancelByCommentId(taskType, taskId, type, commentId);
}
// /**
// * 获取<业务id,举报数></>>Map
// * @param bizType
// * @return
// */
// @Override
// @GetMapping("/getPersonalDataMap")
// public Map<Long, Integer> getPersonalDataMap(@RequestParam("bizType") Integer bizType) {
// return informRecordService.getCountsMap(bizType);
// }
}
package com.yizhi.application.controller.remote;
import java.util.List;
import com.yizhi.application.domain.PdfPages;
import com.yizhi.application.mapper.PdfPagesMapper;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yizhi.comment.application.vo.domain.PdfPagesVo;
import com.yizhi.application.service.IPdfPagesService;
@RestController(value = "PdfPagesControllerRemote")
@RequestMapping("/remote/pdfPages")
public class PdfPagesController {
private static final Logger LOG = LoggerFactory.getLogger(PdfPagesController.class);
@Autowired
private PdfPagesMapper pdfPagesMapper;
@Autowired
private IPdfPagesService pdfPagesService;
@PostMapping("/save")
public boolean save(@RequestBody List<PdfPages> pdfPageVos) {
try {
if (CollectionUtils.isNotEmpty(pdfPageVos)) {
pdfPagesMapper.deleteByBizId(pdfPageVos.get(0).getBizId(), pdfPageVos.get(0).getBizType());
pdfPagesService.insertBatch(pdfPageVos, pdfPageVos.size());
}
return Boolean.TRUE;
} catch (Exception e) {
// TODO Auto-generated catch block
LOG.error("pdf图片保存异常",e.getMessage());
e.printStackTrace();
return Boolean.FALSE;
}
}
@GetMapping("/list")
public List<PdfPages> list(@RequestParam("bizId")Long bizId, @RequestParam("bizType")Integer bizType){
return pdfPagesMapper.getPages(bizId, bizType);
}
}
package com.yizhi.application.controller.remote;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.NewReply;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.core.application.cache.CacheNamespace;
import com.yizhi.core.application.cache.RedisCache;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.util.application.json.JsonUtil;
import com.yizhi.util.application.sensitive.SensitivewordFilter;
import com.yizhi.system.application.vo.AccountVO;
import com.yizhi.application.service.ICommentService;
import com.yizhi.application.service.IReplyService;
import com.yizhi.comment.application.vo.CommentVo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* <p>
* 回复 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController(value = "ReplyControllerRemote")
@RequestMapping("/remote/reply")
public class ReplyController {
@Autowired
private ICommentService commentService;
@Autowired
private IReplyService replyService;
@Autowired
private IdGenerator idGenerator;
@Autowired
private AccountClient accountClient;
@Autowired
private RedisCache redisCache;
/**
* 新增回复评论接口(保存)
* @param
* @return
*/
@PostMapping("/save")
public Boolean saveReply(@RequestBody NewReply reply){
RequestContext context = ContextHolder.get();
Date date = new Date();
if (reply.getReplyParentId()!=null&&reply.getReplyParentId()!=0) {
NewReply newReplyVo = replyService.selectById(reply.getReplyParentId());
if (newReplyVo ==null) {
return false;
}
}else {
reply.setReplyParentId(0L);
}
reply.setId(idGenerator.generate());
reply.setCreateById(context.getAccountId());
reply.setCreateByName(context.getAccountName());
reply.setCreateTime(date);
if (replyService.insert(reply)){
commentService.updatePostsInfo(reply.getBizId(),reply.getBizType(),context.getSiteId(),date,true,false);
return true;
}
return false;
}
@GetMapping("/list")
public Page<CommentVo> list(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "pageNo") Integer pageNo,
@RequestParam(name = "pageSize") Integer pageSize) {
Page<CommentVo> page = new Page<CommentVo>();
page = replyService.getCommentPage(bizId, pageNo, pageSize);
List<Long> accountIds = new ArrayList<>();
Map<Long, AccountVO> accountVOMap = new HashMap<>(16);
for(CommentVo vo:page.getRecords()) {
if (!accountIds.contains(vo.getAccountId())) {
accountIds.add(vo.getAccountId());
}
if (!accountIds.contains(vo.getReplyId())) {
accountIds.add(vo.getReplyId());
}
}
List<AccountVO> accountVOList = accountClient.idsGet(accountIds);
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (AccountVO accountVO : accountVOList) {
accountVOMap.put(accountVO.getId(), accountVO);
}
}
//将用户名放入返回结果中
for (CommentVo commentReplyVO : page.getRecords()) {
if (null != accountVOMap.get(commentReplyVO.getAccountId())) {
AccountVO commentAccount = accountVOMap.get(commentReplyVO.getAccountId());
commentReplyVO.setCommentator(commentAccount.getName());
commentReplyVO.setCommentatorName(commentAccount.getFullName()==""||commentAccount.getFullName()==null?commentAccount.getName():commentAccount.getFullName());
commentReplyVO.setUserAvatar(accountVOMap.get(commentReplyVO.getAccountId()).getHeadPortrait());
}
if (null != accountVOMap.get(commentReplyVO.getReplyId())) {
AccountVO replyAccount = accountVOMap.get(commentReplyVO.getReplyId());
commentReplyVO.setReplyName(replyAccount.getFullName()==""||replyAccount.getFullName()==null?replyAccount.getName():replyAccount.getFullName());
}
}
return page;
}
/**
* 用于学员移动端回复列表查询
* @param commmentId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/list2")
public Page<NewReply> replyList2(@RequestParam("commentId") Long commentId, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
RequestContext res = ContextHolder.get();
Page<NewReply> page = new Page<NewReply>(pageNo, pageSize);
NewReply reply = new NewReply();
reply.setCommentId(commentId);
reply.setState(1);
EntityWrapper<NewReply> wrapper = new EntityWrapper<NewReply>(reply);
List<String> list = new ArrayList<String>();
list.add("createTime");
wrapper.orderDesc(list);
replyService.selectPage(page, wrapper);
//获取评论人和被评论人id并获取信息放入map中
List<Long> accountIds = new ArrayList<>();
Map<Long, AccountVO> accountVOMap = new HashMap<>(16);
for (NewReply listCommentVo : page.getRecords()) {
if (!accountIds.contains(listCommentVo.getCreateById())) {
accountIds.add(listCommentVo.getCreateById());
}
if (!accountIds.contains(listCommentVo.getCommenterId())) {
accountIds.add(listCommentVo.getCommenterId());
}
}
List<AccountVO> accountVOList = accountClient.idsGet(accountIds);
if (CollectionUtils.isNotEmpty(accountVOList)) {
for (AccountVO accountVO : accountVOList) {
accountVOMap.put(accountVO.getId(), accountVO);
}
}
//获取敏感词
Set<String> sensitiveWordList = new HashSet<>();
String sensitiveValues = (String) redisCache.hget(CacheNamespace.REDIS_SENSITIVE_WORD_INFO, res.getCompanyId().toString());
if (StringUtils.isNotBlank(sensitiveValues)) {
sensitiveWordList = JsonUtil.json2Ojbect(sensitiveValues, Set.class);
}
//将用户名放入返回结果中
for (NewReply commentReplyVO : page.getRecords()) {
//过滤敏感词
if (CollectionUtils.isNotEmpty(sensitiveWordList)) {
if (null != commentReplyVO.getContent()) {
commentReplyVO.setContent(filterWord(commentReplyVO.getContent(), sensitiveWordList));
}
}
if (null != accountVOMap.get(commentReplyVO.getCreateById())) {
AccountVO commentAccount = accountVOMap.get(commentReplyVO.getCreateById());
commentReplyVO.setCreateByName(commentAccount.getFullName()==""||commentAccount.getFullName()==null?commentAccount.getName():commentAccount.getFullName());
commentReplyVO.setUserAvatar(accountVOMap.get(commentReplyVO.getCreateById()).getHeadPortrait());
}
if (null != accountVOMap.get(commentReplyVO.getCommenterId())) {
AccountVO replyAccount = accountVOMap.get(commentReplyVO.getCommenterId());
commentReplyVO.setCommenterName(replyAccount.getFullName()==""||replyAccount.getFullName()==null?replyAccount.getName():replyAccount.getFullName());
}
}
return page;
}
/**
* 过滤敏感词
*
* @param content 评论内容
* @param sensitiveWordList 已设置的敏感词集合
* @return
*/
public String filterWord(String content, Set<String> sensitiveWordList) {
if (sensitiveWordList != null) {
if (!StringUtils.isBlank(content)) {
return SensitivewordFilter.sensitiveFilter(content, sensitiveWordList);
}
}
return content;
}
}
package com.yizhi.application.controller.remote;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.NewComment;
import com.yizhi.application.domain.NewReply;
import com.yizhi.application.service.ICommentService;
import com.yizhi.application.service.IInformRecordService;
import com.yizhi.application.service.IReplyService;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.comment.application.feign.student.StudentCommentClient;
import com.yizhi.comment.application.vo.CommentParam;
import com.yizhi.comment.application.vo.NewApiCommentVo;
import com.yizhi.comment.application.vo.PostsCommentVo;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 评论 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController(value = "StudentCommentControllerRemote")
@RequestMapping("/remote/student/comment")
public class StudentCommentController implements StudentCommentClient {
@Autowired
private ICommentService commentService;
@Autowired
private IReplyService replyService;
@Autowired
private IInformRecordService informRecordService;
/**
* 论坛 学员端获取分页的评论和分页的回复
*
* @param param
* @return
*/
@Override
@PostMapping("/getPage")
public Page<NewApiCommentVo> getPage(@RequestBody CommentParam param) {
return commentService.getPage(param);
}
/**
* 论坛 我收到的回复分页
*
* @param param
* @return
*/
@Override
@PostMapping("/myReceivedPage")
public Page<PostsCommentVo> myReceivedPage(@RequestBody CommentParam param) {
return commentService.myReceivedPage(param);
}
/**
* 论坛 我收到的回复分页--查看对话
*
* @param id 回复的id
* @return
*/
@Override
@GetMapping("/catCommunication")
public List<PostsCommentVo> catCommunication(@RequestParam("id") Long id) {
return replyService.catCommunication(id);
}
@Override
@PostMapping("/mySendPage")
public Page<PostsCommentVo> mySendPage(@RequestBody CommentParam param) {
return commentService.mySendPage(param);
}
/**
* 论坛 我的管理--回复管理--回复列表分页
*
* @param type
* @param postsId
* @param pageNo
* @param pageSize
* @return
*/
@Override
@GetMapping("/getPageByPostsId")
@ApiOperation(value = "我的管理--回复管理--回复列表", response = PostsCommentVo.class)
public Page<PostsCommentVo> getPageByPostsId(@ApiParam("type必传 ") @RequestParam("type") Integer type,
@ApiParam("帖子id ") @RequestParam("postsId") Long postsId,
@ApiParam("pageNo") @RequestParam("pageNo") Integer pageNo,
@ApiParam("pageSize ") @RequestParam("pageSize") Integer pageSize) {
return commentService.getPageByPostsId(type, postsId, pageNo, pageSize);
}
/**
* 论坛 评论(回复)--删除(下架) 包含子级回复
*
* @param id
* @param type 1:评论、2-回复
* operationType 1-下架 2-删除
* isInform 是否是举报
* @return
*/
@Override
@GetMapping("/down")
public Integer down(@RequestParam("id") Long id, @RequestParam("type") Integer type, @RequestParam("isInform") Boolean isInform) {
if (type == 1) {
if (commentService.down(1, id) > 0) {
if (isInform) {
informRecordService.cancelByCommentId(Constant.TASK_TYPE_POSTS, null, type, id);
}
NewComment newCommentVo = commentService.selectById(id);
commentService.updatePostsInfo(newCommentVo.getBizId(), newCommentVo.getBizType(), newCommentVo.getSiteId(), null, false, false);
return 1;
}
return 0;
} else {
if (replyService.down(1, id) > 0) {
if (isInform) {
informRecordService.cancelByCommentId(Constant.TASK_TYPE_POSTS, null, type, id);
}
NewReply newReplyVo = replyService.selectById(id);
commentService.updatePostsInfo(newReplyVo.getBizId(), newReplyVo.getBizType(), null, null, false, false);
return 1;
}
return 0;
}
}
@Override
@PostMapping("/save")
public Integer studentSave(@RequestBody NewCommentVo comment) {
return commentService.save(comment);
}
/**
* 论坛我的回复--获取我的回复(收到的回复未查看的数量)
* @param taskType
* @param taskIds
* @return
*/
@Override
@GetMapping("/myNum")
public Integer myNum(@RequestParam("taskType") Integer taskType,
@RequestParam(value = "taskId",required = false) List<Long> taskIds) {
return commentService.myNum(taskType,taskIds);
}
@Override
@ApiOperation(value = "获取单个评论详情,包含回复", response = PostsCommentVo.class)
@GetMapping("/getCommentDetails")
public NewApiCommentVo getCommentDetails(@ApiParam("taskType必传 ") @RequestParam("taskType") Integer taskType,
@ApiParam("业务id ") @RequestParam("taskId") Long taskId,
@ApiParam("评论id ") @RequestParam("commentId") Long commentId,
@ApiParam("作者id ") @RequestParam(value = "author",required = false) Long author,
@ApiParam("回复排序方式 ") @RequestParam("orderType") Integer orderType,
@ApiParam("回复的pageNo") @RequestParam("pageNo") Integer pageNo,
@ApiParam("回复的pageSize ") @RequestParam("pageSize") Integer pageSize) {
return commentService.getCommentDetails(taskType, taskId,commentId,author,orderType, pageNo, pageSize);
}
}
package com.yizhi.application.controller.remote;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.Subscribe;
import com.yizhi.comment.application.vo.domain.SubscribeVo;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.album.application.feign.AlbumClient;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.mapper.SubscribeMapper;
import com.yizhi.application.service.ISubscribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
* <p>
* 订阅 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController(value = "SubscribeControllerRemote")
@RequestMapping("/remote/subscribe")
public class SubscribeController {
@Autowired
private ISubscribeService subscribeService;
@Autowired
private SubscribeMapper subscribeMapper;
@Autowired
IdGenerator idGenerator;
@Autowired
private AlbumClient albumClient;
@GetMapping("/get")
public Subscribe get(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "bizType") Integer bizType, @RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId) {
Subscribe subscribeVo = new Subscribe();
subscribeVo.setSiteId(siteId);
subscribeVo.setCompanyId(companyId);
subscribeVo.setAccountId(accountId);
subscribeVo.setBizId(bizId);
subscribeVo.setBizType(bizType);
EntityWrapper<Subscribe> wrapper = new EntityWrapper<Subscribe>(subscribeVo);
Subscribe one = subscribeService.selectOne(wrapper);
if (one==null) {
subscribeVo.setStatus(0);
return subscribeVo;
}
return one;
}
@GetMapping("/save")
public Subscribe save(@RequestParam(name = "bizId") Long bizId, @RequestParam(name = "bizType") Integer bizType, @RequestParam("accountId") Long accountId, @RequestParam("siteId") Long siteId, @RequestParam("companyId") Long companyId) {
Date date = new Date();
Subscribe subscribeVo = new Subscribe();
subscribeVo.setSiteId(siteId);
subscribeVo.setCompanyId(companyId);
subscribeVo.setAccountId(accountId);
subscribeVo.setBizId(bizId);
subscribeVo.setBizType(bizType);
EntityWrapper<Subscribe> wrapper = new EntityWrapper<Subscribe>(subscribeVo);
Subscribe one = subscribeService.selectOne(wrapper);
if (one==null) {
one = new Subscribe();
one.setId(idGenerator.generate());
one.setBizId(bizId);
one.setBizType(bizType);
one.setCompanyId(companyId);
one.setSiteId(siteId);
one.setAccountId(accountId);
one.setCreateTime(date);
one.setStatus(1);
subscribeService.insert(one);
}else {
one.setUpdateById(accountId);
one.setUpdateTime(date);
one.setStatus(one.getStatus().equals(0)?1:0);
subscribeService.updateById(one);
}
return one;
}
@GetMapping("/getMyList")
public List<Long> getMyList(@RequestParam(name = "bizType") Integer bizType,@RequestParam("accountId") Long accountId,@RequestParam("siteId") Long siteId,@RequestParam("companyId") Long companyId){
List<Long> list = subscribeService.getMyList(bizType, accountId, siteId, companyId);
return list;
}
@GetMapping("getAllList")
public List<Subscribe> getAllList(){
List<Subscribe> list = subscribeMapper.getAllList();
return list;
}
@GetMapping("/getSubscribeNum")
public Integer getSubscribeNum(@RequestParam(name = "bizId") Long bizId,@RequestParam(name = "bizType") Integer bizType) {
Subscribe subscribeVo = new Subscribe();
subscribeVo.setBizId(bizId);
subscribeVo.setBizType(bizType);
subscribeVo.setStatus(1);
return subscribeService.selectCount(new EntityWrapper<Subscribe>(subscribeVo));
}
@PostMapping("/getMySubscribeNum")
public Integer getMySubscribeNum(@RequestBody RequestContext context) {
Integer num = 0;
List<Long> ids = subscribeMapper.getMyList(null, context.getAccountId(), context.getSiteId(), context.getCompanyId());
if (!CollectionUtils.isEmpty(ids)) {
//专辑数量
num = albumClient.getSubcribeNum(ids);
}
return num;
}
}
package com.yizhi.application.controller.student;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.NewComment;
import com.yizhi.application.domain.NewReply;
import com.yizhi.application.service.ICommentService;
import com.yizhi.application.service.IReplyService;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.comment.application.feign.student.StudentCommentClient;
import com.yizhi.application.service.IInformRecordService;
import com.yizhi.comment.application.vo.CommentParam;
import com.yizhi.comment.application.vo.NewApiCommentVo;
import com.yizhi.comment.application.vo.PostsCommentVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 评论 前端控制器
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@RestController
@RequestMapping("/student/comment")
public class StudentCommentController implements StudentCommentClient {
@Autowired
private ICommentService commentService;
@Autowired
private IReplyService replyService;
@Autowired
private IInformRecordService informRecordService;
/**
* 论坛 学员端获取分页的评论和分页的回复
*
* @param param
* @return
*/
@Override
@PostMapping("/getPage")
public Page<NewApiCommentVo> getPage(@RequestBody CommentParam param) {
return commentService.getPage(param);
}
/**
* 论坛 我收到的回复分页
*
* @param param
* @return
*/
@Override
@PostMapping("/myReceivedPage")
public Page<PostsCommentVo> myReceivedPage(@RequestBody CommentParam param) {
return commentService.myReceivedPage(param);
}
/**
* 论坛 我收到的回复分页--查看对话
*
* @param id 回复的id
* @return
*/
@Override
@GetMapping("/catCommunication")
public List<PostsCommentVo> catCommunication(@RequestParam("id") Long id) {
return replyService.catCommunication(id);
}
@Override
@PostMapping("/mySendPage")
public Page<PostsCommentVo> mySendPage(@RequestBody CommentParam param) {
return commentService.mySendPage(param);
}
/**
* 论坛 我的管理--回复管理--回复列表分页
*
* @param type
* @param postsId
* @param pageNo
* @param pageSize
* @return
*/
@Override
@GetMapping("/getPageByPostsId")
@ApiOperation(value = "我的管理--回复管理--回复列表", response = PostsCommentVo.class)
public Page<PostsCommentVo> getPageByPostsId(@ApiParam("type必传 ") @RequestParam("type") Integer type,
@ApiParam("帖子id ") @RequestParam("postsId") Long postsId,
@ApiParam("pageNo") @RequestParam("pageNo") Integer pageNo,
@ApiParam("pageSize ") @RequestParam("pageSize") Integer pageSize) {
return commentService.getPageByPostsId(type, postsId, pageNo, pageSize);
}
/**
* 论坛 评论(回复)--删除(下架) 包含子级回复
*
* @param id
* @param type 1:评论、2-回复
* operationType 1-下架 2-删除
* isInform 是否是举报
* @return
*/
@Override
@GetMapping("/down")
public Integer down(@RequestParam("id") Long id, @RequestParam("type") Integer type, @RequestParam("isInform") Boolean isInform) {
if (type == 1) {
if (commentService.down(1, id) > 0) {
if (isInform) {
informRecordService.cancelByCommentId(Constant.TASK_TYPE_POSTS, null, type, id);
}
NewComment newCommentVo = commentService.selectById(id);
commentService.updatePostsInfo(newCommentVo.getBizId(), newCommentVo.getBizType(), newCommentVo.getSiteId(), null, false, false);
return 1;
}
return 0;
} else {
if (replyService.down(1, id) > 0) {
if (isInform) {
informRecordService.cancelByCommentId(Constant.TASK_TYPE_POSTS, null, type, id);
}
NewReply newReplyVo = replyService.selectById(id);
commentService.updatePostsInfo(newReplyVo.getBizId(), newReplyVo.getBizType(), null, null, false, false);
return 1;
}
return 0;
}
}
@Override
@PostMapping("/save")
public Integer studentSave(@RequestBody NewCommentVo comment) {
return commentService.save(comment);
}
/**
* 论坛我的回复--获取我的回复(收到的回复未查看的数量)
* @param taskType
* @param taskIds
* @return
*/
@Override
@GetMapping("/myNum")
public Integer myNum(@RequestParam("taskType") Integer taskType,
@RequestParam(value = "taskId",required = false) List<Long> taskIds) {
return commentService.myNum(taskType,taskIds);
}
@Override
@ApiOperation(value = "获取单个评论详情,包含回复", response = PostsCommentVo.class)
@GetMapping("/getCommentDetails")
public NewApiCommentVo getCommentDetails(@ApiParam("taskType必传 ") @RequestParam("taskType") Integer taskType,
@ApiParam("业务id ") @RequestParam("taskId") Long taskId,
@ApiParam("评论id ") @RequestParam("commentId") Long commentId,
@ApiParam("作者id ") @RequestParam(value = "author",required = false) Long author,
@ApiParam("回复排序方式 ") @RequestParam("orderType") Integer orderType,
@ApiParam("回复的pageNo") @RequestParam("pageNo") Integer pageNo,
@ApiParam("回复的pageSize ") @RequestParam("pageSize") Integer pageSize) {
return commentService.getCommentDetails(taskType, taskId,commentId,author,orderType, pageNo, pageSize);
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@Data
@TableName("inform_record")
public class InformRecord {
private static final long serialVersionUID = 1L;
private Long id;
@TableField("task_type")
private Integer taskType;
@TableField("task_id")
private Long taskId;
@TableField("type")
private Integer type;
@TableField("comment_id")
private Long commentId;
private Integer status;
private Integer deleted;
private String description;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
@TableField("company_id")
private Long companyId;
@TableField("site_id")
private Long siteId;
@TableField("org_id")
private Long orgId;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.yizhi.comment.application.vo.TaskAppendixVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* <p>
* 评论
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Data
@TableName("new_comment")
public class NewComment {
private static final long serialVersionUID = 1L;
private Long id;
@TableField("biz_id")
private Long bizId;
@TableField("biz_name")
private String bizName;
@TableField("biz_type")
private Integer bizType;
private String content;
@TableField("is_read")
private Integer isRead;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.UPDATE)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.UPDATE)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private Date updateTime;
private Integer state;
@TableField("org_id")
private Long orgId;
@TableField("site_id")
private Long siteId;
@TableField("user_avatar")
private String userAvatar;
@TableField("company_id")
private Long companyId;
@TableField(exist = false)
private List<TaskAppendixVo> taskAppendixVos;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 评论点赞记录表
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Data
@TableName("new_comment_admire")
public class NewCommentAdmire {
private static final long serialVersionUID = 1L;
private Long Id;
@TableField("account_id")
private Long accountId;
@TableField("comment_id")
private Long commentId;
@TableField("biz_type")
private Integer bizType;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
private Integer state;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 回复
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Data
@TableName("new_reply")
public class NewReply {
private static final long serialVersionUID = 1L;
private Long id;
@TableField("biz_id")
private Long bizId;
@TableField("biz_name")
private String bizName;
@TableField("biz_type")
private Integer bizType;
@TableField("comment_id")
private Long commentId;
@TableField("commenter_id")
private Long commenterId;
@TableField("reply_parent_id")
private Long replyParentId;
private String content;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.UPDATE)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.UPDATE)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private Date updateTime;
private Integer state;
@TableField("user_avatar")
private String userAvatar;
@TableField("commenter_name")
private String commenterName;
@TableField("is_read")
private Integer isRead;
@TableField(exist = false)
private Boolean isAuthor = false;
@TableField(exist = false)
private Boolean isSelf = false;
@TableField(exist = false)
private Boolean hasForbidden = false;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("pdf_pages")
public class PdfPages extends Model<PdfPages>{
private static final long serialVersionUID = 1L;
private Long id;
@TableField("pdf_page")
private Integer pdfPage;
@TableField("biz_id")
private Long bizId;
@TableField("biz_type")
private Integer bizType;
@TableField("image_url")
private String imageUrl;
@Override
protected Serializable pkVal() {
return this.id;
}
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 订阅
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Data
@TableName("subscribe")
public class Subscribe {
private static final long serialVersionUID = 1L;
private Long id;
@TableField("biz_type")
private Integer bizType;
@TableField("biz_id")
private Long bizId;
private Integer status;
@TableField("site_id")
private Long siteId;
@TableField("account_id")
private Long accountId;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.UPDATE)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.UPDATE)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.UPDATE)
private Date updateTime;
@TableField("company_id")
private Long companyId;
}
package com.yizhi.application.domain;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@Data
@TableName("task_appendix")
public class TaskAppendix {
private static final long serialVersionUID = 1L;
private Long id;
@TableField("task_type")
private Integer taskType;
@TableField("task_id")
private Long taskId;
private String name;
@TableField("file_size")
private Double fileSize;
@TableField("file_suffer")
private String fileSuffer;
private String url;
@TableField("file_type")
private Integer fileType;
@TableLogic
private Integer deleted;
@TableField(value = "create_by_id", fill = FieldFill.INSERT)
private Long createById;
@TableField(value = "create_by_name", fill = FieldFill.INSERT)
private String createByName;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private Date createTime;
@TableField(value = "update_by_id", fill = FieldFill.INSERT)
private Long updateById;
@TableField(value = "update_by_name", fill = FieldFill.INSERT)
private String updateByName;
@TableField(value = "update_time", fill = FieldFill.INSERT)
private Date updateTime;
}
package com.yizhi.application.mapper;
import com.yizhi.application.domain.NewCommentAdmire;
import com.yizhi.comment.application.vo.domain.NewCommentAdmireVo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* 评论点赞记录表 Mapper 接口
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
public interface CommentAdmireMapper extends BaseMapper<NewCommentAdmire> {
}
package com.yizhi.application.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.yizhi.application.domain.NewComment;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.comment.application.vo.CommentVo;
import com.yizhi.comment.application.vo.ManageCommentVo;
import com.yizhi.comment.application.vo.NewApiCommentVo;
import com.yizhi.comment.application.vo.PostsCommentVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import java.util.List;
/**
* <p>
* 评论 Mapper 接口
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
public interface CommentMapper extends BaseMapper<NewComment> {
List<CommentVo> getCommentPage(@Param("bizId") Long bizId, @Param("bizType") Integer bizType, RowBounds rowBounds);
Integer getCommentPageCount(@Param("bizId") Long bizId, @Param("bizType") Integer bizType);
List<CommentVo> getCommentList(@Param("bizId") Long bizId, @Param("bizType") Integer bizType);
List<NewApiCommentVo> apiCommentPage(@Param("bizId") Long bizId, @Param("bizType") Integer bizType, @Param("accountId") Long accountId, RowBounds rowBounds);
Integer apiCommentPageCount(@Param("bizId") Long courseId, @Param("bizType") Integer bizType, @Param("accountId") Long accountId);
List<com.yizhi.application.domain.NewComment> getallComments();
/**
* 帖子 我收到的回复
*
* @param type 业务类型
* @param keyWord 业务关键词
* @param postsIds 帖子ids
* @param accountId
* @param rowBounds
* @return
*/
List<PostsCommentVo> myReceivedPage(@Param("type") Integer type,
@Param("keyWord") String keyWord,
@Param("postsIds") List<Long> postsIds,
@Param("keyWordPostsIds") List<Long> keyWordPostsIds,
@Param("accountId") Long accountId,
RowBounds rowBounds);
Integer myReceivedPageNum(@Param("type") Integer type,
@Param("keyWord") String keyWord,
@Param("postsIds") List<Long> postsIds,
@Param("keyWordPostsIds") List<Long> keyWordPostsIds,
@Param("accountId") Long accountId);
/**
* 帖子 我发出的回复
*
* @param type 业务类型
* @param keyWord 业务关键词
* @param keyWordPostsIds 帖子ids
* @param accountId
* @param rowBounds
* @return
*/
List<PostsCommentVo> mySendPage(@Param("type") Integer type,
@Param("keyWord") String keyWord,
@Param("keyWordPostsIds") List<Long> keyWordPostsIds,
@Param("accountId") Long accountId,
RowBounds rowBounds);
Integer mySendPageNum(@Param("type") Integer type,
@Param("keyWord") String keyWord,
@Param("keyWordPostsIds") List<Long> keyWordPostsIds,
@Param("accountId") Long accountId);
/**
* 我的管理--回复管理
*
* @param type
* @param postsId
* @param rowBounds
* @return
*/
List <PostsCommentVo> getPageByPostsId(@Param("type") Integer type, @Param("postsId") Long postsId, RowBounds rowBounds);
Integer getPageByPostsIdNum(@Param("type") Integer type, @Param("postsId") Long postsId);
/**
* 论坛管理端-单个帖子的回复列表
*
* @param type
* @param postsId
* @param rowBounds
* @return
*/
List<ManageCommentVo> getPageToManage(@Param("type") Integer type, @Param("postsId") Long postsId, RowBounds rowBounds);
Integer getPageToManageNum(@Param("type") Integer type, @Param("postsId") Long postsId);
}
<?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.yizhi.application.mapper.CommentMapper">
<select id="getCommentPage"
resultType="com.yizhi.comment.application.vo.CommentVo">
SELECT
a.`id` id,
a.`accountId` accountId,
a.thumbsUp
thumbsUp,
a.`content` content,
a.`create_time` create_time,
a.state
state,
COUNT( r.id ) replys
FROM
(
SELECT
b.`id` id,
b.`accountId`
accountId,
COUNT( ca.id ) AS thumbsUp,
b.`content` content,
b.`create_time` create_time,
b.state state
FROM
(
SELECT
c.`id`,
c.`create_by_id` accountId,
c.`content`,
c.`create_time`,
c.state
FROM
`new_comment` c
WHERE
c.biz_id = #{bizId}
AND c.biz_type = #{bizType}
AND c.`state` != 0
GROUP BY
c.id
) b
LEFT JOIN new_comment_admire ca ON
ca.`comment_id` = b.`id`
GROUP BY
b.id
) a
LEFT JOIN new_reply r ON a.id =
r.`comment_id`
GROUP BY
a.id
ORDER BY
a.`create_time` DESC
</select>
<select id="getCommentPageCount" resultType="java.lang.Integer">
SELECT
count(c.`id`)
FROM
`new_comment` c
WHERE
c.`biz_id` = #{bizId}
AND c.biz_type =
#{bizType} AND
c.`state` != 0
ORDER BY c.`create_time` DESC
</select>
<select id="apiCommentPage"
resultType="com.yizhi.comment.application.vo.NewApiCommentVo">
SELECT
d.id AS id,
d.thumbsUp AS thumbsUp,
d.content AS
content,
d.create_time
AS create_time,
d.account_id AS accountId,
d.replys AS replys,
COUNT(t.id ) AS STATUS FROM
(
SELECT
a.id,
a.thumbsUp,
a.content,
a.create_time,
a.account_id,
COUNT(
r.id ) AS replys
FROM
(
SELECT
b.`id`,
COUNT( tu.id ) AS thumbsUp,
b.`content`,
b.`create_time`,
b.`account_id`
FROM
(
SELECT
c.`id`,
c.`content`,
c.`create_time`,
c.`create_by_id`account_id
FROM
`new_comment` c
WHERE
c.`biz_id` =
#{bizId}
AND c.biz_type = #{bizType}
AND c.state = 1
GROUP BY
c.id
) b
LEFT
JOIN new_comment_admire tu ON tu.`comment_id` = b.`id`
GROUP BY
b.id
) a
LEFT JOIN new_reply r ON a.id = r.`comment_id`
AND r.state = 1
GROUP BY
a.id
ORDER BY
a.create_time DESC
) d
LEFT JOIN new_comment_admire t ON
t.comment_id = d.id
AND t.account_id = #{accountId}
GROUP BY
d.id
ORDER BY
d.create_time DESC
</select>
<select id="apiCommentPageCount" resultType="java.lang.Integer">
SELECT
count(c.`id`)
FROM
`new_comment` c
WHERE
c.`biz_id` =
#{bizId}
AND c.biz_type =
#{bizType} AND c.state =1
ORDER BY c.`create_time` DESC
</select>
<select id="getCommentList"
resultType="com.yizhi.comment.application.vo.CommentVo">
SELECT
b.`id` id,
b.`accountId` accountId,
COUNT(ca.id) AS
thumbsUp,
b.`content` content,
b.`create_time` create_time,
b.state state
FROM
(
SELECT
c.`id`,
c.`create_by_id` accountId,
c.`content`,
c.`create_time`,
c.state
FROM
`new_comment` c
WHERE
c.biz_id = #{bizId}
AND
c.biz_type =
#{bizType}
AND c.`state` != 0
GROUP BY
c.id
) b
LEFT JOIN
new_comment_admire ca ON
ca.`comment_id` = b.`id`
GROUP BY
b.id
ORDER BY
b.`create_time` DESC
</select>
<select id="getallComments"
resultType="com.yizhi.application.domain.NewComment">
select id,biz_id,biz_type,create_by_id,create_time from
new_comment where
state != 0
</select>
<select id="myReceivedPage" resultType="com.yizhi.comment.application.vo.PostsCommentVo">
select a.id,1 as type, a.create_by_id as accountId,a.content,a.create_time as createTime,
a.biz_id as postsId,a.id as commentId,a.id as replyParentId ,a.state as status, a.create_by_id as beAnswerId from new_comment a
where 1=1 and a.biz_type=#{type} and a.state = 1
<if test="postsIds == null or postsIds.size == 0">
<!--如果没有自己的帖子,则应该让他查不到 -->
and a.state = -99
</if>
<if test="keyWord == null and postsIds != null and postsIds.size != 0">
and a.biz_id in (<foreach collection="postsIds" separator="," item="index1">#{index1}</foreach>)
</if>
<if test="keyWord != null and keyWord !='' ">
and (
a.content like concat('%',#{keyWord},'%')
<if test="postsIds != null and keyWordPostsIds != null and keyWordPostsIds.size != 0">
or ( a.biz_id in (<foreach collection="keyWordPostsIds" separator="," item="index2">#{index2}</foreach>)
<if test="postsIds != null and postsIds.size != 0">
and a.biz_id in (<foreach collection="postsIds" separator="," item="index1">#{index1}</foreach>)
</if>
)
</if>
)
</if>
UNION ALL
select b.id,2 as type, b.create_by_id as accountId, b.content,b.create_time as createTime,
b.biz_id as postsId,b.comment_id as commentId,b.reply_parent_id as replyParentId ,b.state as status ,b.commenter_id as beAnswerId from new_reply b
where b.biz_type=#{type} and b.state =1 and b.commenter_id = #{accountId}
<if test="keyWord != null and keyWord !='' ">
and (
b.content like concat('%',#{keyWord},'%')
<if test="keyWordPostsIds != null and keyWordPostsIds.size != 0">
or b.biz_id in (<foreach collection="keyWordPostsIds" separator="," item="index2">#{index2}</foreach>)
</if>
)
</if>
order by createTime desc;
</select>
<select id="myReceivedPageNum" resultType="Integer">
SELECT sum( c.num) FROM
( SELECT count( 1 ) num FROM new_comment a
where 1=1 and a.biz_type=#{type} and a.state = 1
<if test="postsIds == null or postsIds.size == 0">
<!--如果没有自己的帖子,则应该让他查不到相关评论 -->
and a.state = -99
</if>
<if test="keyWord == null and postsIds != null and postsIds.size != 0">
and a.biz_id in (<foreach collection="postsIds" separator="," item="index1">#{index1}</foreach>)
</if>
<if test="keyWord != null and keyWord !='' ">
and (
a.content like concat('%',#{keyWord},'%')
<if test="postsIds != null and keyWordPostsIds != null and keyWordPostsIds.size != 0">
or ( a.biz_id in (<foreach collection="keyWordPostsIds" separator="," item="index2">#{index2}</foreach>)
<if test="postsIds != null and postsIds.size != 0">
and a.biz_id in (<foreach collection="postsIds" separator="," item="index1">#{index1}</foreach>)
</if>
)
</if>
)
</if>
UNION ALL
SELECT count( 1 ) num FROM new_reply b
where b.biz_type=#{type} and b.state =1 and b.commenter_id = #{accountId}
<if test="keyWord != null and keyWord !='' ">
and (
b.content like concat('%',#{keyWord},'%')
<if test="keyWordPostsIds != null and keyWordPostsIds.size != 0">
or b.biz_id in (<foreach collection="keyWordPostsIds" separator="," item="index2">#{index2}</foreach>)
</if>
)
</if>
) c
</select>
<select id="mySendPage" resultType="com.yizhi.comment.application.vo.PostsCommentVo">
select a.id,1 as type, a.create_by_id as accountId,a.content,a.create_time as createTime,
a.biz_id as postsId,a.id as commentId,a.id as replyParentId ,a.state as status, a.id as beAnswerId from new_comment a
where 1=1 and a.biz_type=#{type} and a.state = 1 and a.create_by_id = #{accountId}
<if test="keyWord != null and keyWord !='' ">
and
(
a.content like concat('%',#{keyWord},'%')
<if test="keyWordPostsIds != null and keyWordPostsIds.size != 0">
or a.biz_id in (<foreach collection="keyWordPostsIds" separator="," item="index2">#{index2}</foreach>)
</if>
)
</if>
UNION ALL
select b.id,2 as type, b.create_by_id as accountId, b.content,b.create_time as createTime,
b.biz_id as postsId,b.comment_id as commentId,b.reply_parent_id as replyParentId ,b.state as status,b.commenter_id as beAnswerId from new_reply b
where b.biz_type=#{type} and b.state = 1 and b.create_by_id = #{accountId}
<if test="keyWord != null and keyWord !='' ">
and
(
b.content like concat('%',#{keyWord},'%')
<if test="keyWordPostsIds != null and keyWordPostsIds.size != 0">
or b.biz_id in (<foreach collection="keyWordPostsIds" separator="," item="index2">#{index2}</foreach>)
</if>
)
</if>
order by createTime desc;
</select>
<select id="mySendPageNum" resultType="Integer">
SELECT sum( c.num) FROM
( SELECT count( 1 ) num FROM new_comment a
where 1=1 and a.biz_type=#{type} and a.state = 1 and a.create_by_id = #{accountId}
<if test="keyWord != null and keyWord !='' ">
and
(
a.content like concat('%',#{keyWord},'%')
<if test="keyWordPostsIds != null and keyWordPostsIds.size != 0">
or a.biz_id in (<foreach collection="keyWordPostsIds" separator="," item="index2">#{index2}</foreach>)
</if>
)
</if>
UNION ALL
SELECT count( 1 ) num FROM new_reply b
where b.biz_type=#{type} and b.state = 1 and b.create_by_id = #{accountId}
<if test="keyWord != null and keyWord !='' ">
and
(
b.content like concat('%',#{keyWord},'%')
<if test="keyWordPostsIds != null and keyWordPostsIds.size != 0">
or b.biz_id in (<foreach collection="keyWordPostsIds" separator="," item="index2">#{index2}</foreach>)
</if>
)
</if>
) c
</select>
<select id="getPageByPostsId" resultType="com.yizhi.comment.application.vo.PostsCommentVo">
select a.id,1 as type, a.create_by_id as accountId,a.content,a.create_time as createTime,
a.biz_id as postsId,a.id as commentId,a.id as replyParentId ,a.state as status,a.id as beAnswerId from new_comment a
where 1=1 and a.biz_id=#{postsId} and a.biz_type=#{type} and a.state = 1
UNION ALL
select b.id,2 as type, b.create_by_id as accountId, b.content,b.create_time as createTime,
b.biz_id as postsId,b.comment_id as commentId,b.reply_parent_id as replyParentId ,b.state as status,b.commenter_id as beAnswerId from new_reply b
where b.biz_type=#{type} and b.state = 1 and b.biz_id=#{postsId}
order by createTime desc;
</select>
<select id="getPageByPostsIdNum" resultType="Integer">
SELECT sum( c.num) FROM
( SELECT count( 1 ) num FROM new_comment a
where 1=1 and a.biz_id=#{postsId} and a.biz_type=#{type} and a.state = 1
UNION ALL
SELECT count( 1 ) num FROM new_reply b
where b.biz_type=#{type} and b.state = 1 and b.biz_id=#{postsId}
) c
</select>
<select id="getPageToManage" resultType="com.yizhi.comment.application.vo.ManageCommentVo">
select a.id,1 as type, a.create_by_id as accountId,a.content,a.create_time as createTime,
a.biz_id as taskId ,a.state as status,a.id as beAnswerId from new_comment a
where 1=1 and a.biz_id=#{postsId} and a.biz_type=#{type} and a.state != 0
UNION ALL
select b.id,2 as type, b.create_by_id as accountId, b.content,b.create_time as createTime,
b.biz_id as taskId,b.state as status,b.commenter_id as beAnswerId from new_reply b
where b.biz_type=#{type} and b.state != 0 and b.biz_id=#{postsId}
order by createTime desc;
</select>
<select id="getPageToManageNum" resultType="Integer">
SELECT sum( c.num) FROM
( SELECT count( 1 ) num FROM new_comment a
where 1=1 and a.biz_id=#{postsId} and a.biz_type=#{type} and a.state != 0
UNION ALL
SELECT count( 1 ) num FROM new_reply b
where b.biz_type=#{type} and b.state != 0 and b.biz_id=#{postsId}
) c
</select>
</mapper>
<?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.yizhi.application.mapper.InformRecordMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.application.domain.InformRecord">
<id column="id" property="id" />
<result column="task_type" property="taskType" />
<result column="task_id" property="taskId" />
<result column="status" property="status" />
<result column="type" property="type" />
<result column="comment_id" property="commentId" />
<result column="deleted" property="deleted" />
<result column="description" property="description" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="create_time" property="createTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="update_time" property="updateTime" />
<result column="company_id" property="companyId" />
<result column="site_id" property="siteId" />
<result column="org_id" property="orgId" />
</resultMap>
</mapper>
package com.yizhi.application.mapper;
import com.yizhi.application.domain.InformRecord;
import com.yizhi.comment.application.vo.domain.InformRecordVo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
public interface InformRecordMapper extends BaseMapper<InformRecord> {
}
package com.yizhi.application.mapper;
import java.util.List;
import com.yizhi.application.domain.PdfPages;
import com.yizhi.comment.application.vo.domain.PdfPagesVo;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
public interface PdfPagesMapper extends BaseMapper<PdfPages>{
void deleteByBizId(@Param(value = "bizId") Long bizId,@Param(value = "bizType") Integer bizType);
List<PdfPages> getPages(@Param(value = "bizId") Long bizId, @Param(value = "bizType") Integer bizType);
}
<?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.yizhi.application.mapper.PdfPagesMapper">
<delete id="deleteByBizId">
DELETE FROM pdf_pages WHERE biz_id =#{bizId} and biz_type=#{bizType}
</delete>
<select id="getPages" resultType="com.yizhi.application.domain.PdfPages">
SELECT
*
FROM
pdf_pages pg
WHERE
pg.biz_id =#{bizId} and pg.biz_type=#{bizType}
ORDER BY pg.pdf_page ASC
</select>
</mapper>
package com.yizhi.application.mapper;
import com.yizhi.application.domain.NewReply;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* 回复 Mapper 接口
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
public interface ReplyMapper extends BaseMapper<NewReply> {
List<NewReply> getCommentPage(@Param("commentId")Long commentId, RowBounds rowBounds);
Integer getCommentPageCount(@Param("commentId") Long commentId);
List<NewReply> list(@Param("bizId") Long bizId);
}
<?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.yizhi.application.mapper.ReplyMapper">
<select id="getCommentPage" resultType="com.yizhi.application.domain.NewReply">
SELECT
*
FROM
`new_reply` c
WHERE
c.comment_id = #{commentId}
AND c.`state` != 0
GROUP BY
c.id
ORDER BY c.`create_time`
</select>
<select id="getCommentPageCount" resultType="java.lang.Integer">
SELECT
count(c.`id`)
FROM
`new_reply` c
WHERE
c.comment_id = #{commentId} AND
c.`state` != 0
ORDER BY c.`create_time` DESC
</select>
<select id="list" resultType="com.yizhi.application.domain.NewReply">
SELECT
*
FROM
new_reply r
WHERE
r.biz_id = #{bizId} and r.state=1 ORDER BY r.create_time desc
</select>
</mapper>
package com.yizhi.application.mapper;
import com.yizhi.application.domain.Subscribe;
import com.yizhi.comment.application.vo.domain.SubscribeVo;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* 订阅 Mapper 接口
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
public interface SubscribeMapper extends BaseMapper<Subscribe> {
public List<Long> getMyList(@Param(value = "bizType")Integer bizType,@Param(value = "accountId") Long accountId,@Param(value = "siteId") Long siteId,@Param(value = "companyId") Long companyId);
public List<Subscribe> getAllList();
}
<?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.yizhi.application.mapper.SubscribeMapper">
<select id="getMyList" resultType="java.lang.Long">
SELECT
s.biz_id
FROM
subscribe s
WHERE
s.account_id = #{accountId}
<if test="bizType!=null">
AND s.biz_type = #{bizType}
</if>
AND s.site_id = #{siteId}
AND s.company_id = #{companyId}
AND s.`status` = 1
</select>
<select id="getAllList" resultType="com.yizhi.application.domain.Subscribe">
select id,biz_type,biz_id,account_id,create_time from subscribe where status = 1
</select>
</mapper>
<?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.yizhi.application.mapper.TaskAppendixMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.yizhi.application.domain.TaskAppendix">
<id column="id" property="id" />
<result column="task_type" property="taskType" />
<result column="task_id" property="taskId" />
<result column="name" property="name" />
<result column="file_size" property="fileSize" />
<result column="file_suffer" property="fileSuffer" />
<result column="url" property="url" />
<result column="file_type" property="fileType" />
<result column="deleted" property="deleted" />
<result column="create_by_id" property="createById" />
<result column="create_by_name" property="createByName" />
<result column="create_time" property="createTime" />
<result column="update_by_id" property="updateById" />
<result column="update_by_name" property="updateByName" />
<result column="update_time" property="updateTime" />
</resultMap>
</mapper>
package com.yizhi.application.mapper;
import com.yizhi.application.domain.TaskAppendix;
import com.yizhi.comment.application.vo.domain.TaskAppendixVo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
public interface TaskAppendixMapper extends BaseMapper<TaskAppendix> {
}
package com.yizhi.application.service;
import com.yizhi.application.domain.NewCommentAdmire;
import com.yizhi.comment.application.vo.domain.NewCommentAdmireVo;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.comment.application.vo.AdmireVO;
import com.yizhi.comment.application.vo.StatisticsForumAccountVo;
import java.util.List;
import java.util.Map;
/**
* <p>
* 评论点赞记录表 服务类
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
public interface ICommentAdmireService extends IService<NewCommentAdmire> {
/**
* 获取《评论id,点赞vo》
* @param type
* @param commentIds
* @return
*/
public Map<Long, AdmireVO> getCountsByCommentId(Integer type, List<Long> commentIds,Boolean isExport);
/**
* 获取 《用户id,点赞数》
* @param bizType
* @param map
* @return
*/
Map<Long, StatisticsForumAccountVo> getPersonalDataMap(Integer bizType, Map<Long, StatisticsForumAccountVo> map);
/**
* 获取《业务id,点赞数》
* @param type
* @param
* @return
*/
public Map<Long, Integer> getCountsMap(Integer type);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.NewComment;
import com.yizhi.comment.application.vo.*;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* <p>
* 评论 服务类
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
public interface ICommentService extends IService<NewComment> {
Page<com.yizhi.comment.application.vo.CommentVo> getCommentPage(Long bizId, Integer bizType, int pageNo, int pageSize);
List<CommentVo> getCommentList(Long bizId, Integer bizType);
Page<NewApiCommentVo> apiCommentPage(Long bizId, Integer bizType, Long accountId, int pageNo, int pageSize);
Page<NewApiCommentVo> getPage(CommentParam param);
/**
* 论坛 收到的回复
* @param param
* @return
*/
Page<PostsCommentVo> myReceivedPage(CommentParam param);
/**
* 获取评论id,评论的map
* @param ids
* @return
*/
Map<Long, NewCommentVo> getMap(List<Long> ids);
/**
* 论坛 发送的回复
* @param param
* @return
*/
Page<PostsCommentVo> mySendPage(CommentParam param);
Page<PostsCommentVo> getPageByPostsId(Integer type, Long postsId, Integer pageNo, Integer pageSize);
/**
* 论坛-评论删除或下架
* @param operationType 1-下架 2-删除
* @param id
* @return
*/
Integer down(Integer operationType,Long id);
Page<ManageCommentVo> getPageToManage(Integer type, Long postsId, Integer pageNo, Integer pageSize);
public void updatePostsInfo(Long bizId, Integer bizType, Long siteId,Date date, Boolean save,Boolean isManage);
Map<Long, StatisticsForumAccountVo> getPersonalDataMap(Integer bizType);
Integer save(NewCommentVo comment);
/**
* 更新评论回复的已读状态 论坛需要
* @param taskType
* @param taskId
* @return
*/
Integer updateIsReadField(Integer taskType,List<Long> taskId);
Integer myNum(Integer taskType, List<Long> taskIds);
NewApiCommentVo getCommentDetails(Integer taskType, Long taskId, Long commentId, Long author, Integer orderType, Integer pageNo, Integer pageSize);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.domain.InformRecord;
import com.yizhi.comment.application.vo.domain.InformRecordVo;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.comment.application.vo.StatisticsForumAccountVo;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
public interface IInformRecordService extends IService<InformRecord> {
Integer save(com.yizhi.comment.application.vo.InformRecordVo informRecordVo);
Page<com.yizhi.comment.application.vo.InformRecordVo> getPage(Integer taskType, Long taskId, Integer type, Integer terminalType, Integer pageNo, Integer pageSize);
Integer cancel(Long id);
Integer cancelByCommentId(Integer taskType,Long taskId,Integer type,Long commentId);
/**
* 获取《用户id,举报数》
* @param bizType
* @param map
* @return
*/
Map<Long, StatisticsForumAccountVo> getPersonalDataMap(Integer bizType, Map<Long, StatisticsForumAccountVo> map);
// /**
// * 获取《业务id,举报数》
// * @param type
// * @param
// * @return
// */
// public Map<Long, Integer> getCountsMap(Integer type);
}
package com.yizhi.application.service;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.application.domain.PdfPages;
import com.yizhi.comment.application.vo.domain.PdfPagesVo;
public interface IPdfPagesService extends IService<PdfPages> {
}
package com.yizhi.application.service;
import com.yizhi.application.domain.NewReply;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.comment.application.vo.CommentParam;
import com.yizhi.comment.application.vo.CommentVo;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.yizhi.comment.application.vo.PostsCommentVo;
import com.yizhi.comment.application.vo.StatisticsForumAccountVo;
/**
* <p>
* 回复 服务类
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
public interface IReplyService extends IService<NewReply> {
Page<CommentVo> getCommentPage(Long commentId, int pageNo, int pageSize);
List<NewReply> list(Long bizId);
/**
* 获取《评论id,回复数》
* @param commentId
* @return
*/
public Map<Long,Integer> getCountsByCommentId(List<Long> commentId);
/**
* 分页获取回复
* @param commentId
* @return
*/
Page<NewReplyVo> getPage(Long commentId, CommentParam param);
/**
* 获取《评论id,回复》目前是传楼主id
*
* @return
*/
public Map<Long, List<NewReplyVo>> getMapByAccountId(Integer taskType, Long taskId, Long author);
/**
* 获取回复id,回复的map
* @param ids
* @return
*/
Map<Long, NewReplyVo> getMap(List<Long> ids);
List<PostsCommentVo> catCommunication(Long id);
/**
* 论坛-评论删除或下架
* @param operationType 1-下架 2-删除
* @param id
* @return
*/
Integer down(Integer operationType,Long id);
/**
* 获取《用户id,回复数》
* @param bizType
* @param map
* @return
*/
Map<Long, StatisticsForumAccountVo> getPersonalDataMap(Integer bizType, Map<Long, StatisticsForumAccountVo> map);
}
package com.yizhi.application.service;
import com.yizhi.application.domain.Subscribe;
import com.yizhi.comment.application.vo.domain.SubscribeVo;
import java.util.List;
import com.baomidou.mybatisplus.service.IService;
/**
* <p>
* 订阅 服务类
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
public interface ISubscribeService extends IService<Subscribe> {
public List<Long> getMyList(Integer bizType,Long accountId,Long siteId,Long companyId);
}
package com.yizhi.application.service;
import com.yizhi.application.domain.TaskAppendix;
import com.yizhi.comment.application.vo.domain.TaskAppendixVo;
import com.baomidou.mybatisplus.service.IService;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务类
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
public interface ITaskAppendixService extends IService<TaskAppendix> {
public Integer save(Integer taskType, Long taskId, List<com.yizhi.comment.application.vo.TaskAppendixVo> taskAppendixVoVos);
public List<com.yizhi.comment.application.vo.TaskAppendixVo> getList(Integer taskType, Long taskId);
public Map<Long,List<com.yizhi.comment.application.vo.TaskAppendixVo>> getListMap(Integer taskType, List<Long> taskIds);
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.application.domain.NewCommentAdmire;
import com.yizhi.application.mapper.CommentAdmireMapper;
import com.yizhi.application.service.ICommentAdmireService;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.comment.application.vo.domain.NewCommentAdmireVo;
import com.yizhi.core.application.context.ContextHolder;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.comment.application.vo.AdmireVO;
import com.yizhi.comment.application.vo.StatisticsForumAccountVo;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* 评论点赞记录表 服务实现类
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Service
public class CommentAdmireServiceImpl extends ServiceImpl<CommentAdmireMapper, NewCommentAdmire> implements ICommentAdmireService {
@Override
public Map<Long, AdmireVO> getCountsByCommentId(Integer type, List<Long> commentIds,Boolean isExport) {
Map<Long, AdmireVO> commentAdmireMap = null;
Long accountId = 0L;
if (!CollectionUtils.isEmpty(commentIds)) {
if (!isExport){
accountId = ContextHolder.get().getAccountId();
}
NewCommentAdmireVo commentAdmire = new NewCommentAdmireVo();
commentAdmire.setState(Constant.UP);
commentAdmire.setBizType(type);
EntityWrapper<NewCommentAdmire> wrapper = new EntityWrapper(commentAdmire);
wrapper.in("comment_id", commentIds);
List<NewCommentAdmire> newCommentAdmireVos = this.selectList(wrapper);
if (!CollectionUtils.isEmpty(newCommentAdmireVos)) {
commentAdmireMap = new HashMap<>(newCommentAdmireVos.size());
for (NewCommentAdmire a : newCommentAdmireVos) {
if (commentAdmireMap.containsKey(a.getCommentId())) {
AdmireVO vo = commentAdmireMap.get(a.getCommentId());
if (vo != null) {
Integer admireNums = vo.getAdmireNums();
vo.setAdmireNums(admireNums + 1);
vo.setHasAdmire(accountId.equals(a.getAccountId()));
commentAdmireMap.put(a.getCommentId(), vo);
}
} else {
AdmireVO vo = new AdmireVO();
vo.setAdmireNums(1);
vo.setHasAdmire(accountId.equals(a.getAccountId()));
commentAdmireMap.put(a.getCommentId(), vo);
}
}
}
}
return commentAdmireMap;
}
@Override
public Map<Long, StatisticsForumAccountVo> getPersonalDataMap(Integer bizType, Map<Long, StatisticsForumAccountVo> map) {
NewCommentAdmireVo commentAdmire = new NewCommentAdmireVo();
commentAdmire.setState(Constant.UP);
commentAdmire.setBizType(bizType);
EntityWrapper<NewCommentAdmire> wrapper = new EntityWrapper(commentAdmire);
List<NewCommentAdmire> newCommentAdmireVos = this.selectList(wrapper);
if (!CollectionUtils.isEmpty(newCommentAdmireVos)) {
for (NewCommentAdmire a : newCommentAdmireVos) {
if (map.containsKey(a.getAccountId())) {
StatisticsForumAccountVo vo = map.get(a.getAccountId());
if (vo != null) {
Integer admireNums = vo.getAdmireNum();
admireNums = admireNums == null ? 0 : admireNums;
vo.setAdmireNum(admireNums + 1);
map.put(a.getAccountId(), vo);
}
} else {
StatisticsForumAccountVo vo = new StatisticsForumAccountVo();
vo.setAdmireNum(1);
map.put(a.getAccountId(), vo);
}
}
}
return map;
}
@Override
public Map<Long, Integer> getCountsMap(Integer type) {
Map<Long, Integer> commentAdmireMap = null;
NewCommentAdmireVo commentAdmire = new NewCommentAdmireVo();
commentAdmire.setState(Constant.NOT_DELETED);
commentAdmire.setBizType(type);
EntityWrapper<NewCommentAdmire> wrapper = new EntityWrapper(commentAdmire);
List<NewCommentAdmire> newCommentAdmireVos = this.selectList(wrapper);
if (!CollectionUtils.isEmpty(newCommentAdmireVos)) {
for (NewCommentAdmire a : newCommentAdmireVos) {
if (commentAdmireMap.containsKey(a.getCommentId())) {
Integer num = commentAdmireMap.get(a.getCommentId());
commentAdmireMap.put(a.getCommentId(), num + 1);
} else {
commentAdmireMap.put(a.getCommentId(), 1);
}
}
}
return commentAdmireMap;
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.NewComment;
import com.yizhi.application.domain.NewReply;
import com.yizhi.application.mapper.CommentMapper;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.*;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.comment.application.vo.*;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.forum.application.feign.remote.RemotePostsClient;
import com.yizhi.forum.application.vo.forum.PostsParamsVo;
import com.yizhi.forum.application.vo.forum.PostsStudentVo;
import com.yizhi.point.application.feign.PointRedisFeignClients;
import com.yizhi.point.application.vo.PointParamVO;
import org.apache.ibatis.session.RowBounds;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 评论 服务实现类
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, NewComment> implements ICommentService {
@Autowired
private IdGenerator idGenerator;
@Autowired
private IReplyService replyService;
@Autowired
private ICommentAdmireService commentAdmireService;
@Autowired
private CommentMapper commentMapper;
@Autowired
private RemotePostsClient remotePostsClient;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private IInformRecordService informRecordService;
@Autowired
private ITaskAppendixService taskAppendixService;
@Autowired
private PointRedisFeignClients pointRedisFeignClients;
@Autowired
private AmqpTemplate amqpTemplate;
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private Logger logger = LoggerFactory.getLogger(CommentServiceImpl.class);
@Override
public Page<com.yizhi.comment.application.vo.CommentVo> getCommentPage(Long bizId, Integer bizType, int pageNo, int pageSize) {
Page<com.yizhi.comment.application.vo.CommentVo> page = new Page<com.yizhi.comment.application.vo.CommentVo>(pageNo, pageSize);
page.setRecords(
this.baseMapper.getCommentPage(bizId, bizType, new RowBounds(page.getOffset(), page.getLimit())));
Integer count = this.baseMapper.getCommentPageCount(bizId, bizType);
page.setTotal(count);
return page;
}
@Override
public List<com.yizhi.comment.application.vo.CommentVo> getCommentList(Long bizId, Integer bizType) {
// TODO Auto-generated method stub
List<CommentVo> list = this.baseMapper.getCommentList(bizId, bizType);
return list;
}
@Override
public Page<NewApiCommentVo> apiCommentPage(Long bizId, Integer bizType, Long accountId, int pageNo, int pageSize) {
Page<NewApiCommentVo> page = new Page<NewApiCommentVo>(pageNo, pageSize);
page.setRecords(this.baseMapper.apiCommentPage(bizId, bizType, accountId,
new RowBounds(page.getOffset(), page.getLimit())));
Integer count = this.baseMapper.apiCommentPageCount(bizId, bizType, accountId);
if (count == null) {
count = 0;
}
page.setTotal(count);
return page;
}
@Override
public Page<NewApiCommentVo> getPage(CommentParam param) {
Page page = new Page<NewApiCommentVo>(param.getPageNo(), param.getPageSize());
RequestContext context = ContextHolder.get();
Map<Long, List<NewReplyVo>> replyMap = null;
NewComment newCommentVo = new NewComment();
newCommentVo.setBizType(param.getType());
newCommentVo.setBizId(param.getBizId());
newCommentVo.setState(Constant.UP);
newCommentVo.setSiteId(context.getSiteId());
EntityWrapper<NewComment> wrapper = new EntityWrapper(newCommentVo);
//是否是最新回复
wrapper.orderBy("create_time", Constant.ORDER_BY_OLD_REPLY.equals(param.getOrderType()));
//只看楼主
if (param.getOnlyAuthor()) {
wrapper.andNew().eq("create_by_id", param.getAuthor());
replyMap = replyService.getMapByAccountId(param.getType(), param.getBizId(), param.getAuthor());
if (replyMap != null) {
if (!CollectionUtils.isEmpty(replyMap.keySet())) {
wrapper.or().in("id", replyMap.keySet());
}
}
}
page = this.selectPage(page, wrapper);
List<NewComment> records = page.getRecords();
page.setRecords(buildVo(param, records, replyMap,context));
return page;
}
/**
* 判断是否为楼主
*
* @param replies
* @param author
* @return
*/
public void isAuthor(List<NewReplyVo> replies, Long author) {
if (!CollectionUtils.isEmpty(replies)) {
replies.forEach(a -> {
a.setIsAuthor(author.equals(a.getCreateById()));
});
}
}
/**
* 评论填充vo数据
*
* @param param
* @param records
* @param replyMap
* @return
*/
public List<NewApiCommentVo> buildVo(CommentParam param, List<NewComment> records, Map<Long, List<NewReplyVo>> replyMap, RequestContext context) {
if (!CollectionUtils.isEmpty(records)) {
List<NewApiCommentVo> commentVos = new ArrayList<>(records.size());
List<Long> commentIds = records.stream().map(a -> a.getId()).collect(Collectors.toList());
//获取点赞相关数据
Map<Long, AdmireVO> admireMap = commentAdmireService.getCountsByCommentId(Constant.TYPE_COMMENT, commentIds, false);
//获取评论附件
Map<Long, List<TaskAppendixVo>> appendixMap = taskAppendixService.getListMap(Constant.TYPE_COMMENT, commentIds);
for (NewComment a : records) {
NewApiCommentVo vo = new NewApiCommentVo();
BeanUtils.copyProperties(a, vo);
vo.setAccountId(a.getCreateById());
//判断是否是楼主
if (param.getAuthor() != null) {
vo.setIsAuthor(param.getAuthor().equals(a.getCreateById()));
}
//判断是否是当前用户创建的评论
vo.setIsSelf(context.getAccountId().equals(a.getCreateById()));
List<NewReplyVo> replies = null;
if (admireMap != null) {
AdmireVO admireVO = admireMap.get(a.getId());
vo.setThumbsUp(0);
vo.setStatus(0);
if (admireVO != null) {
vo.setThumbsUp(admireVO.getAdmireNums());
vo.setStatus(admireVO.getHasAdmire()? 1 : 0);
}
}
if (appendixMap != null) {
vo.setTaskAppendixVos(appendixMap.get(a.getId()));
}
Page<NewReplyVo> replyPage = replyService.getPage(a.getId(),param);
replies = replyPage.getRecords();
vo.setReplies(replies);
vo.setReplys(replyPage.getTotal());
if (vo.getReplys() > param.getReplyPageSize()) {
vo.setRestReplys(vo.getReplys() - param.getReplyPageSize());
} else {
vo.setRestReplys(0);
}
commentVos.add(vo);
}
return commentVos;
}
return new ArrayList<>();
}
@Override
public Page<PostsCommentVo> myReceivedPage(CommentParam param) {
RequestContext context = ContextHolder.get();
Page<PostsCommentVo> page = new Page(param.getPageNo(), param.getPageSize());
String keyWord = null;
if (!StringUtils.isEmpty(param.getKeyWord())) {
keyWord = param.getKeyWord();
}
PostsParamsVo vo = new PostsParamsVo();
vo.setAuthor(context.getAccountId());
vo.setIncludeDeleted(true);
Map<Long, PostsStudentVo> map = remotePostsClient.getMap(vo);
//获取作者已发帖ids
List<Long> authorTaskIds = null;
List<Long> keyWordPostsIds = null;
if (map != null) {
authorTaskIds = new ArrayList<>(map.size());
authorTaskIds.addAll(map.keySet());
}
if (!StringUtils.isEmpty(param.getKeyWord())) {
//获取模糊查询到帖子ids
vo.setAuthor(null);
vo.setTitle(param.getKeyWord());
Map<Long, PostsStudentVo> map1 = remotePostsClient.getMap(vo);
if (map1 != null) {
keyWordPostsIds = new ArrayList<>(map1.size());
keyWordPostsIds.addAll(map1.keySet());
}
}
List<PostsCommentVo> records = commentMapper.myReceivedPage(param.getType(), keyWord, authorTaskIds, keyWordPostsIds, context.getAccountId(), new RowBounds(page.getOffset(), page.getLimit()));
Integer total = commentMapper.myReceivedPageNum(param.getType(), keyWord, authorTaskIds, keyWordPostsIds, context.getAccountId());
buildRecords(records);
if (Constant.TASK_TYPE_POSTS.equals(param.getType())) {
this.updateIsReadField(Constant.TASK_TYPE_POSTS, authorTaskIds);
}
page.setRecords(records);
page.setTotal(total);
return page;
}
/**
* 组装数据
*
* @param records
*/
public void buildRecords(List<PostsCommentVo> records) {
if (!CollectionUtils.isEmpty(records)) {
List<Long> admireCommentIds = new ArrayList<>();
List<Long> commentIds = new ArrayList<>();
List<Long> replyIds = new ArrayList<>();
for (PostsCommentVo a : records) {
//获取回复帖子的评论id,方便查询是否自己已点赞
if (Constant.TYPE_COMMENT.equals(a.getType())){
admireCommentIds.add(a.getCommentId());
}
//获取回复回复的评论id(一级回复,查询该评论是否被删除)、父回复id(查询父回复是否被删除)
if (Constant.TYPE_REPLY.equals(a.getType())) {
commentIds.add(a.getCommentId());
//若该数据是第N级回复(排除第二级)
if (!Constant.ZERO.equals(a.getReplyParentId())) {
replyIds.add(a.getReplyParentId());
}
}
}
Map<Long, NewCommentVo> commentMap = null;
Map<Long, NewReplyVo> replyMap = null;
Map<Long, AdmireVO> admireMap = null;
Map<Long, List<TaskAppendixVo>> appendixMap = null;
if (!CollectionUtils.isEmpty(admireCommentIds)){
//获取点赞数据
admireMap = commentAdmireService.getCountsByCommentId(Constant.TYPE_COMMENT, admireCommentIds, false);
//获取评论附件
appendixMap = taskAppendixService.getListMap(Constant.TYPE_COMMENT, admireCommentIds);
}
if (!CollectionUtils.isEmpty(commentIds)){
commentMap = this.getMap(commentIds);
}
if (!CollectionUtils.isEmpty(replyIds)){
replyMap = replyService.getMap(replyIds);
}
for (PostsCommentVo a : records) {
//判断是否自己已点赞
if (Constant.TYPE_COMMENT.equals(a.getType())) {
if (admireMap != null) {
a.setIsAdmire(admireMap.containsKey(a.getCommentId()));
}
if (appendixMap != null) {
a.setTaskAppendixVos(appendixMap.get(a.getCommentId()));
}
}
if (Constant.TYPE_REPLY.equals(a.getType())) {
if (commentMap != null) {
NewCommentVo newCommentVo = commentMap.get(a.getCommentId());
//判断一级回复(评论)是否被删除
a.setCommentHasDeleted(newCommentVo == null ? false : newCommentVo.getState() != Constant.UP ? true : false);
}
//如果该数据是二级回复
if (Constant.ZERO.equals(a.getReplyParentId().intValue())) {
if (commentMap != null) {
NewCommentVo newCommentVo = commentMap.get(a.getCommentId());
a.setBeAnswerContent(newCommentVo == null ? "" : newCommentVo.getContent());
a.setBeAnswerContentHasDelete(newCommentVo == null ? false : newCommentVo.getState() != Constant.UP ? true : false);
}
} else {
//若该数据是第N级回复(排除第二级)
if (replyMap != null) {
NewReplyVo newReplyVo = replyMap.get(a.getReplyParentId());
a.setBeAnswerContent(newReplyVo == null ? "" : newReplyVo.getContent());
a.setBeAnswerContentHasDelete(newReplyVo == null ? false : newReplyVo.getState() != Constant.UP ? true : false);
}
}
}
}
}
}
public static void main(String[] args) {
Integer a =0;
}
@Override
public Map<Long, NewCommentVo> getMap(List<Long> ids) {
Map<Long, NewCommentVo> map = null;
List<NewComment> newCommentVos = this.selectBatchIds(ids);
if (!CollectionUtils.isEmpty(newCommentVos)) {
map = new HashMap<>(newCommentVos.size());
for (NewComment a : newCommentVos) {
if (!map.containsKey(a.getId())) {
NewCommentVo nv=new NewCommentVo();
BeanUtils.copyProperties(a,nv);
map.put(a.getId(), nv);
}
}
}
return map;
}
@Override
public Page<PostsCommentVo> mySendPage(CommentParam param) {
RequestContext context = ContextHolder.get();
Page<PostsCommentVo> page = new Page(param.getPageNo(), param.getPageSize());
//获取包含关键字的帖子ids
List<Long> taskIds = null;
if (!StringUtils.isEmpty(param.getKeyWord())) {
PostsParamsVo vo = new PostsParamsVo();
vo.setIncludeDeleted(true);
vo.setTitle(param.getKeyWord());
Map<Long, PostsStudentVo> map = remotePostsClient.getMap(vo);
if (map != null) {
taskIds = new ArrayList<>(map.size());
taskIds.addAll(map.keySet());
}
}
List<PostsCommentVo> records = commentMapper.mySendPage(param.getType(), param.getKeyWord(), taskIds, context.getAccountId(), new RowBounds(page.getOffset(), page.getLimit()));
Integer total = commentMapper.mySendPageNum(param.getType(), param.getKeyWord(), taskIds, context.getAccountId());
buildRecords(records);
page.setRecords(records);
page.setTotal(total);
return page;
}
@Override
public Page<PostsCommentVo> getPageByPostsId(Integer type, Long postsId, Integer pageNo, Integer pageSize) {
Page<PostsCommentVo> page = new Page(pageNo, pageSize);
List<PostsCommentVo> records = commentMapper.getPageByPostsId(type, postsId, new RowBounds(page.getOffset(), page.getLimit()));
if (!CollectionUtils.isEmpty(records)) {
Set<Long> commentIds = records.stream().map(a -> a.getCommentId()).collect(Collectors.toSet());
Map<Long, List<TaskAppendixVo>> map = taskAppendixService.getListMap(Constant.TYPE_COMMENT, new ArrayList<>(commentIds));
records.forEach(a -> {
if (map!=null){
a.setTaskAppendixVos(map.get(a.getId()));
}
});
}
page.setRecords(records);
page.setTotal(commentMapper.getPageByPostsIdNum(type, postsId));
//修改帖子主体信息
this.updatePostsInfo(postsId,type, ContextHolder.get().getSiteId(), new Date(), false,true);
return page;
}
@Override
// @param operationType 1-下架 2-删除
public Integer down(Integer operationType, Long id) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
NewComment comment = this.selectById(id);
if (comment != null) {
comment.setState(operationType == 1 ? Constant.DOWN : Constant.STATE_DELETED);
comment.setUpdateById(accountId);
comment.setUpdateByName(name);
comment.setUpdateTime(date);
if (this.updateById(comment)) {
NewReply reply = new NewReply();
reply.setState(operationType == 1 ? Constant.DOWN : Constant.STATE_DELETED);
EntityWrapper wrapper = new EntityWrapper();
wrapper.eq("comment_id", id);
replyService.update(reply, wrapper);
}
return 1;
}
return 0;
}
@Override
public Page<ManageCommentVo> getPageToManage(Integer type, Long postsId, Integer pageNo, Integer pageSize) {
Page<ManageCommentVo> page = new Page(pageNo, pageSize);
List<ManageCommentVo> records = commentMapper.getPageToManage(type, postsId, new RowBounds(page.getOffset(), page.getLimit()));
page.setRecords(records);
page.setTotal(commentMapper.getPageToManageNum(type, postsId));
if (!CollectionUtils.isEmpty(records)) {
List<Long> commentIds = new ArrayList<>();
records.forEach(a -> {
if (a.getType().equals(1)) {
commentIds.add(a.getId());
}
});
//获取点赞相关数据
Map<Long, AdmireVO> admireMap = null;
if (!CollectionUtils.isEmpty(commentIds)) {
admireMap = commentAdmireService.getCountsByCommentId(Constant.TYPE_COMMENT, commentIds, true);
}
Integer i = 0;
for (ManageCommentVo a : records) {
a.setStatusString(a.getStatus() == 1 ? "已上架" : "已下架");
a.setCreateTimeString(format.format(a.getCreateTime()));
if (a.getType().equals(1)) {
a.setNum(++i);
a.setBeAnswerName("--");
if (admireMap != null) {
AdmireVO admireVO = admireMap.get(a.getId());
if (admireVO != null) {
a.setCommentAdmires(admireVO.getAdmireNums());
}
}
}
}
//如果评论回复是对帖子的
if (Constant.TASK_TYPE_POSTS.equals(type)) {
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
//更新帖子的新回复字段
com.yizhi.forum.application.vo.domain.PostsVo vo = new com.yizhi.forum.application.vo.domain.PostsVo();
vo.setId(postsId);
vo.setNewCommentNum(0);
remotePostsClient.updateInfo(vo);
}
});
}
}
return page;
}
/**
*
* @param bizId
* @param bizType
* @param siteId
* @param date
* @param save 是否为保存
* @param isManage 是否进行了管理
*/
@Override
public void updatePostsInfo(Long bizId, Integer bizType, Long siteId, Date date, Boolean save,Boolean isManage) {
//如果业务类型对帖子的
if (Constant.TASK_TYPE_POSTS.equals(bizType)) {
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
//更新帖子新回复、最新评论时间、评论数、回复数字段、排序字段
com.yizhi.forum.application.vo.domain.PostsVo info = remotePostsClient.getInfo(bizId);
if (info != null) {
com.yizhi.forum.application.vo.domain.PostsVo vo = new com.yizhi.forum.application.vo.domain.PostsVo();
vo.setId(bizId);
if (isManage){
//如果是代管员查看列表,需要把该字段置零
vo.setNewCommentNum(0);
remotePostsClient.updateInfo(vo);
return;
}
NewCommentVo comment1 = new NewCommentVo();
comment1.setBizId(bizId);
comment1.setBizType(bizType);
comment1.setSiteId(siteId);
EntityWrapper wrapper1 = new EntityWrapper(comment1);
wrapper1.ne("state",Constant.STATE_DELETED);
Integer commentCount = commentMapper.selectCount(wrapper1);
NewReplyVo newReplyVo = new NewReplyVo();
newReplyVo.setBizId(bizId);
newReplyVo.setBizType(bizType);
EntityWrapper wrapper2 = new EntityWrapper(newReplyVo);
wrapper2.ne("state",Constant.STATE_DELETED);
int replyCount = replyService.selectCount(wrapper2);
vo.setCommentNum(commentCount);
vo.setReplyNum(replyCount);
if (save) {
vo.setCommentTime(date);
vo.setManageSortTime(date);
vo.setNewCommentNum(info.getNewCommentNum() == null ? 1 : info.getNewCommentNum() + 1);
if (info.getIsTop() != 1) {
vo.setSortTime(date);
}
}
remotePostsClient.updateInfo(vo);
}
}
});
}
}
@Override
public Map<Long, StatisticsForumAccountVo> getPersonalDataMap(Integer bizType) {
Map<Long, StatisticsForumAccountVo> map = new HashMap<>();
NewCommentVo comment = new NewCommentVo();
comment.setBizType(bizType);
comment.setState(Constant.UP);
EntityWrapper wrapper1 = new EntityWrapper(comment);
List<NewCommentVo> newCommentVos = commentMapper.selectList(wrapper1);
if (!CollectionUtils.isEmpty(newCommentVos)) {
for (NewCommentVo a : newCommentVos) {
if (!map.containsKey(a.getCreateById())) {
StatisticsForumAccountVo vo = new StatisticsForumAccountVo();
vo.setCommentNum(1);
map.put(a.getCreateById(), vo);
} else {
StatisticsForumAccountVo vo1 = map.get(a.getCreateById());
if (vo1 != null) {
vo1.setCommentNum(vo1.getCommentNum() + 1);
map.put(a.getCreateById(), vo1);
}
}
}
}
replyService.getPersonalDataMap(bizType, map);
commentAdmireService.getPersonalDataMap(bizType, map);
informRecordService.getPersonalDataMap(bizType, map);
return map;
}
@Override
public Integer save(NewCommentVo comment) {
RequestContext context = ContextHolder.get();
Date date = new Date();
Long id = idGenerator.generate();
comment.setId(id);
comment.setCreateById(context.getAccountId());
comment.setCreateByName(context.getAccountName());
comment.setCreateTime(date);
comment.setSiteId(context.getSiteId());
comment.setOrgId(context.getOrgId());
NewComment n=new NewComment();
BeanUtils.copyProperties(comment,n);
if (this.insert(n)) {
taskAppendixService.save(Constant.TYPE_COMMENT, id, comment.getTaskAppendixVos());
//修改帖子主体信息
this.updatePostsInfo(comment.getBizId(), comment.getBizType(), context.getSiteId(), date, true,false);
//发积分
sendPoint(comment.getBizType(),id,comment.getBizId(),context,comment.getContent());
return 1;
}
return 0;
}
/**
* 判断评论是否发积分
*
* @param taskType 业务类型
* @param commentId 评论id
* @param postsId 帖子id
* @param context
*/
public void sendPoint(Integer taskType, Long commentId, Long postsId, RequestContext context,String activityName) {
//只有对论坛的评论可以发积分
if (!Constant.TASK_TYPE_POSTS.equals(taskType)) {
return;
}
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
//先判断当前用户是否已评论啦
NewComment comment = new NewComment();
comment.setBizType(taskType);
comment.setBizId(postsId);
comment.setSiteId(context.getSiteId());
comment.setCreateById(context.getAccountId());
int count = commentMapper.selectCount(new EntityWrapper<>(comment));
if (count > 1) {
//说明已评论则不发积分
logger.info("用户:"+comment.getCreateById()+"已经在帖子:"+comment.getBizId()+"评论啦!");
return;
}
//论坛回帖发送积分
PointParamVO pointParamVO = new PointParamVO();
pointParamVO.setEventName("pointForum");
pointParamVO.setActivityName(activityName);
pointParamVO.setActivityType("发布论坛回复发放积分");
pointParamVO.setActivitySource("论坛");
pointParamVO.setCreatePointTime(new Date());
pointParamVO.setSourceId(commentId);
pointParamVO.setAccountId(context.getAccountId());
pointParamVO.setSiteId(context.getSiteId());
pointParamVO.setCompanyId(context.getCompanyId());
pointParamVO.setAccountName(context.getAccountName());
pointParamVO.setOrgId(context.getOrgId());
pointParamVO.setOperatingPoint(0);
com.yizhi.forum.application.vo.domain.PostsVo info = remotePostsClient.getInfo(postsId);
//PostsVo info = remotePostsClient.getInfo(postsId);
if (info != null) {
pointParamVO.setOperatingPoint(info.getCommentPoint());
}
String sitePointId = pointRedisFeignClients.addPointRedis(pointParamVO);
// 发送积分
if (!StringUtils.isEmpty(sitePointId)) {
amqpTemplate.convertAndSend("forum", sitePointId);
}
}
});
}
@Override
public Integer updateIsReadField(Integer taskType, List<Long> taskIds) {
RequestContext context = ContextHolder.get();
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
if (!CollectionUtils.isEmpty(taskIds)) {
NewComment comment = new NewComment();
comment.setIsRead(1);
EntityWrapper wrapper = new EntityWrapper();
wrapper.eq("biz_type", taskType)
.eq("site_id", context.getSiteId())
.eq("is_read", Constant.ZERO)
.in("biz_id", taskIds);
commentMapper.update(comment, wrapper);
}
NewReply reply = new NewReply();
reply.setIsRead(1);
EntityWrapper wrapper1 = new EntityWrapper();
wrapper1.eq("biz_type", taskType)
.eq("is_read", Constant.ZERO)
.eq("commenter_id", context.getAccountId());
replyService.update(reply, wrapper1);
}
});
return 1;
}
@Override
public Integer myNum(Integer taskType, List<Long> taskIds) {
Integer totalNum = 0;
RequestContext context = ContextHolder.get();
if (!CollectionUtils.isEmpty(taskIds)) {
NewCommentVo comment = new NewCommentVo();
comment.setBizType(taskType);
comment.setIsRead(Constant.ZERO);
comment.setSiteId(context.getSiteId());
EntityWrapper wrapper = new EntityWrapper(comment);
wrapper.in("biz_id", taskIds);
Integer commentNum = commentMapper.selectCount(wrapper);
totalNum += commentNum;
}
NewReplyVo reply = new NewReplyVo();
reply.setBizType(taskType);
reply.setIsRead(Constant.ZERO);
reply.setCommenterId(context.getAccountId());
EntityWrapper wrapper1 = new EntityWrapper(reply);
int replyNum = replyService.selectCount(wrapper1);
totalNum += replyNum;
return totalNum;
}
@Override
public NewApiCommentVo getCommentDetails(Integer taskType, Long taskId, Long commentId, Long author, Integer orderType, Integer pageNo, Integer pageSize) {
NewComment newCommentVo = this.selectById(commentId);
NewApiCommentVo vo = new NewApiCommentVo();
if (newCommentVo != null) {
BeanUtils.copyProperties(newCommentVo, vo);
vo.setAccountId(newCommentVo.getCreateById());
vo.setIsSelf(ContextHolder.get().getAccountId().equals(newCommentVo.getCreateById()));
List<Long> commentIds = Arrays.asList(commentId);
//获取点赞相关数据
Map<Long, AdmireVO> admireMap = commentAdmireService.getCountsByCommentId(Constant.TYPE_COMMENT, commentIds, false);
//获取评论附件
Map<Long, List<TaskAppendixVo>> appendixMap = taskAppendixService.getListMap(Constant.TYPE_COMMENT, commentIds);
if (admireMap != null) {
AdmireVO admireVO = admireMap.get(commentId);
if (admireVO != null) {
vo.setThumbsUp(admireVO.getAdmireNums());
vo.setStatus(admireVO.getHasAdmire() == true ? 1 : 0);
}
}
if (appendixMap != null) {
vo.setTaskAppendixVos(appendixMap.get(commentId));
}
CommentParam param = new CommentParam();
param.setReplyPageNo(pageNo);
param.setReplyPageSize(pageSize);
param.setOrderType(orderType);
param.setAuthor(author);
Page<NewReplyVo> replyPage = replyService.getPage(commentId, param);
// vo.setReplies(replyPage.getRecords());
vo.setReplyPage(replyPage);
vo.setReplys(replyPage.getTotal());
}
return vo;
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.InformRecord;
import com.yizhi.application.domain.NewComment;
import com.yizhi.application.domain.NewReply;
import com.yizhi.application.mapper.InformRecordMapper;
import com.yizhi.application.service.ICommentService;
import com.yizhi.application.service.IReplyService;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.comment.application.vo.domain.InformRecordVo;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.forum.application.feign.remote.RemotePostsClient;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.ITaskAppendixService;
import com.yizhi.application.service.IInformRecordService;
import com.yizhi.core.application.task.AbstractTaskHandler;
import com.yizhi.core.application.task.TaskExecutor;
import com.yizhi.comment.application.vo.InformCommentVo;
import com.yizhi.comment.application.vo.StatisticsForumAccountVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务实现类
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@Service
public class InformRecordServiceImpl extends ServiceImpl<InformRecordMapper, InformRecord> implements IInformRecordService {
private Logger logger = LoggerFactory.getLogger(InformRecordServiceImpl.class);
@Autowired
private IdGenerator idGenerator;
@Autowired
private ITaskAppendixService taskAppendixService;
@Autowired
private IReplyService replyService;
@Autowired
private ICommentService commentService;
@Autowired
private TaskExecutor taskExecutor;
@Autowired
private RemotePostsClient remotePostsClient;
@Autowired
private InformRecordMapper informRecordMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Integer save(com.yizhi.comment.application.vo.InformRecordVo informRecordVo) {
RequestContext context = ContextHolder.get();
Long id = idGenerator.generate();
InformRecord informRecord = new InformRecord();
BeanUtils.copyProperties(informRecordVo, informRecord);
informRecord.setId(id);
informRecord.setCreateById(context.getAccountId());
informRecord.setCreateByName(context.getAccountName());
informRecord.setCreateTime(new Date());
informRecord.setSiteId(context.getSiteId());
informRecord.setCompanyId(context.getCompanyId());
informRecord.setOrgId(context.getOrgId());
if (this.insert(informRecord)) {
taskAppendixService.save(Constant.TYPE_INFORM, id, informRecordVo.getTaskAppendixVos());
updatePostsInfo(informRecordVo.getTaskType(), informRecordVo.getTaskId(), false, true);
return 1;
}
return 0;
}
@Override
public Page<com.yizhi.comment.application.vo.InformRecordVo> getPage(Integer taskType, Long taskId, Integer type, Integer terminalType, Integer pageNo, Integer pageSize) {
Page page = new Page<>(pageNo, pageSize);
RequestContext context = ContextHolder.get();
InformRecordVo informRecordVo = new InformRecordVo();
informRecordVo.setTaskType(taskType);
informRecordVo.setTaskId(taskId);
informRecordVo.setStatus(terminalType == 1 ? null : Constant.UP);
informRecordVo.setDeleted(Constant.NOT_DELETED);
EntityWrapper wrapper = new EntityWrapper(informRecordVo);
if (type != null) {
if (type == 0) {
wrapper.eq("type", 0);
} else {
wrapper.ne("type", 0);
}
}
page = this.selectPage(page, wrapper);
List<InformRecord> records = page.getRecords();
if (!CollectionUtils.isEmpty(records)) {
List<com.yizhi.comment.application.vo.InformRecordVo> informRecordVoVos = new ArrayList<>(records.size());
records.forEach(a -> {
com.yizhi.comment.application.vo.InformRecordVo vo = new com.yizhi.comment.application.vo.InformRecordVo();
BeanUtils.copyProperties(a, vo);
vo.setTaskAppendixVos(taskAppendixService.getList(Constant.TYPE_INFORM, a.getId()));
//构建回复vo
vo.setInformCommentVo(buildCommentVo(taskType, a.getType(), a.getCommentId()));
informRecordVoVos.add(vo);
});
page.setRecords(informRecordVoVos);
//更新帖子的举报字段
updatePostsInfo(taskType, taskId, true, false);
}
return page;
}
/**
* 举报或者移除举报 更新帖子信息
*
* @param bizType 2-论坛
* @param bizId
* @param isManage 是否是管理员管理啦
* @param isSave 是否是保存啦
*/
public void updatePostsInfo(Integer bizType, Long bizId, Boolean isManage, Boolean isSave) {
//如果业务类型对帖子的
if (Constant.TASK_TYPE_POSTS.equals(bizType)) {
taskExecutor.asynExecute(new AbstractTaskHandler() {
@Override
public void handle() {
com.yizhi.forum.application.vo.domain.PostsVo vo = new com.yizhi.forum.application.vo.domain.PostsVo();
vo.setId(bizId);
if (isSave) {
vo.setHasNewInform(1);
vo.setManageSortTime(new Date());
}
if (isManage) {
vo.setHasNewInform(0);
remotePostsClient.updateInfo(vo);
return;
}
//更新帖子的举报数字段
InformRecordVo informRecordVo1 = new InformRecordVo();
informRecordVo1.setTaskId(bizId);
informRecordVo1.setTaskType(bizType);
informRecordVo1.setDeleted(Constant.NOT_DELETED);
EntityWrapper wrapper = new EntityWrapper(informRecordVo1);
Integer count = informRecordMapper.selectCount(wrapper);
vo.setInformNum(count);
vo.setHasNewInform(count == 0 ? 0 : 1);
remotePostsClient.updateInfo(vo);
}
});
}
}
/**
* 举报类型为评论,需要带上评论信息
*
* @param taskType
* @param type 1-评论 2-回复
* @return commentReplyId 评论或回复的id
*/
public InformCommentVo buildCommentVo(Integer taskType, Integer type, Long commentReplyId) {
InformCommentVo vo = null;
//只有为举报的回复评论类型才执行
if (Constant.TASK_TYPE_POSTS.equals(taskType)) {
vo = new InformCommentVo();
vo.setType(type);
if (Constant.TYPE_COMMENT.equals(type)) {
NewComment newCommentVo = commentService.selectById(commentReplyId);
if (newCommentVo != null) {
vo.setId(newCommentVo.getId());
vo.setAccountId(newCommentVo.getCreateById());
vo.setContent(newCommentVo.getContent());
vo.setCreateTime(newCommentVo.getCreateTime());
vo.setCommentStatus(newCommentVo.getState());
} else {
logger.info("评论id无效");
}
} else {
NewReply newReplyVo = replyService.selectById(commentReplyId);
if (newReplyVo != null) {
vo.setId(newReplyVo.getId());
vo.setAccountId(newReplyVo.getCreateById());
vo.setContent(newReplyVo.getContent());
vo.setCreateTime(newReplyVo.getCreateTime());
vo.setCommentStatus(newReplyVo.getState());
} else {
logger.info("回复id无效");
}
}
}
return vo;
}
@Override
public Integer cancel(Long id) {
InformRecord informRecordVo = this.selectById(id);
if (informRecordVo != null) {
RequestContext context = ContextHolder.get();
InformRecord record = new InformRecord();
record.setId(id);
record.setDeleted(Constant.DELETED);
record.setUpdateById(context.getAccountId());
record.setUpdateByName(context.getAccountName());
record.setUpdateTime(new Date());
if (this.updateById(record)) {
updatePostsInfo(informRecordVo.getTaskType(), informRecordVo.getTaskId(), false, false);
return 1;
}
return 0;
} else {
return -1;
}
}
@Override
public Map<Long, StatisticsForumAccountVo> getPersonalDataMap(Integer bizType, Map<Long, StatisticsForumAccountVo> map) {
InformRecordVo informRecordVo1 = new InformRecordVo();
informRecordVo1.setTaskType(bizType);
informRecordVo1.setDeleted(Constant.NOT_DELETED);
EntityWrapper wrapper = new EntityWrapper(informRecordVo1);
List<InformRecordVo> informRecordVos = this.selectList(wrapper);
if (!CollectionUtils.isEmpty(informRecordVos)) {
for (InformRecordVo a : informRecordVos) {
if (!map.containsKey(a.getCreateById())) {
StatisticsForumAccountVo vo = new StatisticsForumAccountVo();
vo.setInformNum(1);
map.put(a.getCreateById(), vo);
} else {
StatisticsForumAccountVo vo1 = map.get(a.getCreateById());
if (vo1 != null) {
Integer informNum = vo1.getInformNum();
informNum = informNum == null ? 0 : informNum;
vo1.setInformNum(informNum + 1);
map.put(a.getCreateById(), vo1);
}
}
}
}
return map;
}
@Override
public Integer cancelByCommentId(Integer taskType, Long taskId, Integer type, Long commentId) {
RequestContext context = ContextHolder.get();
InformRecord record = new InformRecord();
record.setStatus(Constant.DOWN);
record.setUpdateById(context.getAccountId());
record.setUpdateByName(context.getAccountName());
record.setUpdateTime(new Date());
EntityWrapper wrapper = new EntityWrapper();
wrapper.eq("task_type", taskType)
.eq("type", type)
.eq("deleted", Constant.NOT_DELETED);
if (taskId != null) {
wrapper.eq("task_id", taskId);
}
if (commentId != null) {
wrapper.eq("comment_id", commentId);
}
if (this.update(record, wrapper)) {
updatePostsInfo(taskType, taskId, false, false);
return 1;
}
return 0;
}
// @Override
// public Map<Long, Integer> getCountsMap(Integer type) {
// Map<Long, Integer> informMap = null;
// InformRecordVo informRecord1 = new InformRecordVo();
// informRecord1.setTaskType(type);
// informRecord1.setDeleted(Constant.NOT_DELETED);
// EntityWrapper wrapper = new EntityWrapper(informRecord1);
// List<InformRecordVo> informRecords = this.selectList(wrapper);
// if (!CollectionUtils.isEmpty(informRecords)) {
// for (InformRecordVo a : informRecords) {
// if (informMap.containsKey(a.getCreateById())) {
// Integer num = informMap.get(a.getCreateById());
// informMap.put(a.getCreateById(), num + 1);
// } else {
// informMap.put(a.getCreateById(), 1);
// }
// }
// }
// return informMap;
// }
}
package com.yizhi.application.service.impl;
import com.yizhi.application.domain.PdfPages;
import com.yizhi.application.mapper.PdfPagesMapper;
import com.yizhi.comment.application.vo.domain.PdfPagesVo;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.service.IPdfPagesService;
@Service
public class PdfPagesServiceImpl extends ServiceImpl<PdfPagesMapper, PdfPages> implements IPdfPagesService{
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.NewComment;
import com.yizhi.application.domain.NewReply;
import com.yizhi.application.mapper.CommentMapper;
import com.yizhi.application.mapper.ReplyMapper;
import com.yizhi.application.service.IReplyService;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.comment.application.vo.domain.NewCommentVo;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.application.service.ITaskAppendixService;
import com.yizhi.comment.application.vo.CommentParam;
import com.yizhi.comment.application.vo.CommentVo;
import com.yizhi.comment.application.vo.PostsCommentVo;
import com.yizhi.comment.application.vo.StatisticsForumAccountVo;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* <p>
* 回复 服务实现类
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Service
public class ReplyServiceImpl extends ServiceImpl<ReplyMapper, NewReply> implements IReplyService {
@Autowired
private CommentMapper commentMapper;
@Autowired
private ITaskAppendixService taskAppendixService;
@Override
public Page<CommentVo> getCommentPage(Long commentId, int pageNo, int pageSize) {
Page<CommentVo> page = new Page<CommentVo>(pageNo, pageSize);
List<CommentVo> arrayList = new ArrayList<CommentVo>();
List<NewReply> list = this.baseMapper.getCommentPage(commentId, new RowBounds(page.getOffset(), page.getLimit()));
NewComment comment = commentMapper.selectById(commentId);
if(!CollectionUtils.isEmpty(list)) {
for(NewReply reply:list) {
CommentVo vo = new CommentVo();
vo.setAccountId(reply.getCreateById());
vo.setContent(reply.getContent());
vo.setId(reply.getId());
vo.setCreateTime(reply.getCreateTime());
vo.setState(reply.getState());
vo.setReplyId(reply.getReplyParentId()==0?comment.getCreateById():reply.getCommenterId());
arrayList.add(vo);
}
}
page.setRecords(arrayList);
Integer count = this.baseMapper.getCommentPageCount(commentId);
page.setTotal(count);
return page;
}
@Override
public List<NewReply> list(Long bizId) {
return this.baseMapper.list(bizId);
}
@Override
public Map<Long, Integer> getCountsByCommentId(List<Long> commentIds) {
Map<Long, Integer> replyMap = null;
if (!CollectionUtils.isEmpty(commentIds)) {
NewReplyVo newReplyVo = new NewReplyVo();
EntityWrapper<NewReply> wrapper = new EntityWrapper(newReplyVo);
wrapper.in("comment_id", commentIds);
newReplyVo.setState(Constant.UP);
List<NewReply> newReplies = this.selectList(wrapper);
if (!CollectionUtils.isEmpty(newReplies)) {
replyMap = new HashMap<>(newReplies.size());
for (NewReply a : newReplies) {
if (replyMap.containsKey(a.getCommentId())) {
Integer commentAdmireNum = replyMap.get(a.getCommentId());
replyMap.put(a.getCommentId(), commentAdmireNum + 1);
} else {
replyMap.put(a.getCommentId(), 1);
}
}
}
}
return replyMap;
}
@Override
public Page<NewReplyVo> getPage(Long commentId, CommentParam param) {
Page<NewReply> page = new Page<NewReply>(param.getReplyPageNo(), param.getReplyPageSize());
NewReply newReplyVo = new NewReply();
newReplyVo.setCommentId(commentId);
newReplyVo.setState(Constant.UP);
if (param.getOnlyAuthor()){
newReplyVo.setCreateById(param.getAuthor());
}
EntityWrapper<NewReply> wrapper = new EntityWrapper(newReplyVo);
//是否是最新回复
wrapper.orderBy("create_time", Constant.ORDER_BY_OLD_REPLY.equals(param.getOrderType()));
Page<NewReply> replyPage = this.selectPage(page, wrapper);
Page<NewReplyVo> replyVoPage=new Page<>();
BeanUtils.copyProperties(replyPage,replyVoPage);
replyVoPage.setRecords(isAuthor(replyPage.getRecords(),param.getAuthor()));
replyVoPage.setCondition(replyPage.getCondition());
return replyVoPage;
}
@Override
public Map<Long, List<NewReplyVo>> getMapByAccountId(Integer taskType, Long taskId, Long author) {
Map<Long, List<NewReplyVo>> replyMap = null;
NewReply newReplyVo = new NewReply();
newReplyVo.setBizType(taskType);
newReplyVo.setState(Constant.UP);
newReplyVo.setBizId(taskId);
newReplyVo.setCreateById(author);
EntityWrapper<NewReply> wrapper = new EntityWrapper(newReplyVo);
List<NewReply> newReplies = this.selectList(wrapper);
if (!CollectionUtils.isEmpty(newReplies)) {
replyMap = new HashMap<>(newReplies.size());
for (NewReply a : newReplies) {
a.setIsAuthor(true);
if (!replyMap.containsKey(a.getCommentId())) {
NewReplyVo nrv=new NewReplyVo();
BeanUtils.copyProperties(a,nrv);
replyMap.put(a.getCommentId(), Arrays.asList(nrv));
}
}
}
return replyMap;
}
/**
* 判断是否为楼主,判断是否为当前用户创建的回复
*
* @param replies
* @param author
* @return
*/
public List<NewReplyVo> isAuthor(List<NewReply> replies, Long author) {
RequestContext context = ContextHolder.get();
if (!CollectionUtils.isEmpty(replies)) {
if (author != null) {
replies.forEach(a -> {
a.setIsAuthor(author.equals(a.getCreateById()));
a.setIsSelf(context.getAccountId().equals(a.getCreateById()));
});
}
}
List<NewReplyVo> list=new ArrayList<>();
for (NewReply nr:replies
) {
NewReplyVo nrv=new NewReplyVo();
BeanUtils.copyProperties(nr,nrv);
list.add(nrv);
}
return list;
}
@Override
public Map<Long, NewReplyVo> getMap(List<Long> ids) {
Map<Long, NewReplyVo> map = null;
List<NewReply> newReplies = this.selectBatchIds(ids);
if (!CollectionUtils.isEmpty(newReplies)) {
map = new HashMap<>(newReplies.size());
for (NewReply a : newReplies) {
if (!map.containsKey(a.getId())) {
NewReplyVo nrv=new NewReplyVo();
BeanUtils.copyProperties(a,nrv);
map.put(a.getId(), nrv);
}
}
}
return map;
}
@Override
public List<PostsCommentVo> catCommunication(Long id) {
NewReply newReplyVo = this.selectById(id);
List<PostsCommentVo> postsCommentVos = new ArrayList<>();
if (newReplyVo != null) {
//构建vo
buildVo(newReplyVo,postsCommentVos);
Long replyParentId = newReplyVo.getReplyParentId();
//该数据为二级回复
if (Constant.ZERO.equals(replyParentId)) {
buildCommentToVo(newReplyVo,postsCommentVos);
}else {
//否则递归获取直到最顶层
getListByReplyParentId(newReplyVo, postsCommentVos);
}
}
return postsCommentVos;
}
public void buildVo(NewReply newReplyVo, List<PostsCommentVo> postsCommentVos){
if (newReplyVo != null) {
PostsCommentVo vo = new PostsCommentVo();
vo.setId(newReplyVo.getId());
vo.setCommentId(newReplyVo.getCommentId());
vo.setPostsId(newReplyVo.getBizId());
vo.setType(Constant.TYPE_REPLY);
vo.setIsDeleted(!newReplyVo.getState().equals(Constant.UP));
vo.setContent(vo.getIsDeleted() ? Constant.COMMENT_HAS_DELETED : newReplyVo.getContent());
vo.setCreateTime(newReplyVo.getCreateTime());
vo.setAccountId(newReplyVo.getCreateById());
vo.setIsSelf(ContextHolder.get().getAccountId().equals(newReplyVo.getCreateById()));
vo.setBeAnswerId(newReplyVo.getCommenterId());
postsCommentVos.add(vo);
}
}
/**
* 查询出评论
* @param newReplyVo
* @param postsCommentVos
*/
public void buildCommentToVo(NewReply newReplyVo, List<PostsCommentVo> postsCommentVos){
Long replyParentId = newReplyVo.getReplyParentId();
//该数据为二级回复
if (replyParentId != null && Constant.ZERO.toString().equals(replyParentId.toString()) ) {
NewComment newCommentVo = commentMapper.selectById(newReplyVo.getCommentId());
PostsCommentVo vo = new PostsCommentVo();
vo.setId(newCommentVo.getId());
vo.setPostsId(newCommentVo.getBizId());
vo.setCommentId(newCommentVo.getId());
vo.setType(Constant.TYPE_COMMENT);
vo.setIsDeleted(!newCommentVo.getState().equals(Constant.UP));
vo.setContent(vo.getIsDeleted() ? Constant.COMMENT_HAS_DELETED : newCommentVo.getContent());
vo.setCreateTime(newCommentVo.getCreateTime());
vo.setAccountId(newCommentVo.getCreateById());
vo.setIsSelf(ContextHolder.get().getAccountId().equals(newCommentVo.getCreateById()));
vo.setTaskAppendixVos(taskAppendixService.getList(Constant.TYPE_COMMENT, newCommentVo.getId()));
postsCommentVos.add(vo);
}
}
/**
* 递归获取父类回复
* @param newReplyVo
* @param postsCommentVos
*/
public void getListByReplyParentId(NewReply newReplyVo, List<PostsCommentVo> postsCommentVos) {
Long replyParentId = newReplyVo.getReplyParentId();
if (replyParentId != null && !Constant.ZERO.toString().equals(replyParentId.toString()) ) {
NewReply newReplyVo1 = this.selectById(replyParentId);
if (newReplyVo1 != null) {
buildVo(newReplyVo1, postsCommentVos);
getListByReplyParentId(newReplyVo1, postsCommentVos);
}
} else {
buildCommentToVo(newReplyVo, postsCommentVos);
}
}
@Override
public Integer down(Integer operationType,Long id) {
RequestContext context = ContextHolder.get();
Long accountId = context.getAccountId();
String name = context.getAccountName();
Date date = new Date();
NewReply reply = this.selectById(id);
if (reply != null) {
reply.setState(operationType == 1 ? Constant.DOWN : Constant.STATE_DELETED);
reply.setUpdateById(accountId);
reply.setUpdateByName(name);
reply.setUpdateTime(date);
this.updateById(reply);
return 1;
}
return 0;
}
@Override
public Map<Long, StatisticsForumAccountVo> getPersonalDataMap(Integer bizType, Map<Long, StatisticsForumAccountVo> map) {
NewReplyVo newReplyVo = new NewReplyVo();
newReplyVo.setBizType(bizType);
newReplyVo.setState(Constant.UP);
EntityWrapper wrapper2 = new EntityWrapper(newReplyVo);
List<NewReplyVo> replies = this.selectList(wrapper2);
if (!CollectionUtils.isEmpty(replies)){
for (NewReplyVo a : replies) {
if (!map.containsKey(a.getCreateById())) {
StatisticsForumAccountVo vo = new StatisticsForumAccountVo();
vo.setReplyNum(1);
map.put(a.getCreateById(), vo);
} else {
StatisticsForumAccountVo vo1 = map.get(a.getCreateById());
if (vo1 != null) {
Integer replyNum = vo1.getReplyNum();
replyNum = replyNum == null ? 0 : replyNum;
vo1.setReplyNum(replyNum + 1);
map.put(a.getCreateById(), vo1);
}
}
}
}
return map;
}
// public static void main(String[] args) {
// Map<Long, StatisticsForumAccountVo> map = new HashMap<>();
// List<NewReplyVo> replies = new ArrayList<>()
// if (!CollectionUtils.isEmpty(replies)){
// for (NewReplyVo a : replies) {
// if (!map.containsKey(a.getCreateById())) {
// StatisticsForumAccountVo vo = new StatisticsForumAccountVo();
// vo.setReplyNum(1);
// map.put(a.getCreateById(), vo);
// } else {
// StatisticsForumAccountVo vo1 = map.get(a.getCreateById());
// if (vo1 != null) {
// vo1.setReplyNum(vo1.getReplyNum() + 1);
// map.put(a.getCreateById(), vo1);
// }
// }
// }
// }
// }
}
package com.yizhi.application.service.impl;
import com.yizhi.application.domain.Subscribe;
import com.yizhi.application.mapper.SubscribeMapper;
import com.yizhi.comment.application.vo.domain.SubscribeVo;
import com.yizhi.application.service.ISubscribeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import java.util.List;
import org.springframework.stereotype.Service;
/**
* <p>
* 订阅 服务实现类
* </p>
*
* @author yizhi123
* @since 2019-12-30
*/
@Service
public class SubscribeServiceImpl extends ServiceImpl<SubscribeMapper, Subscribe> implements ISubscribeService {
@Override
public List<Long> getMyList(Integer bizType, Long accountId, Long siteId, Long companyId) {
// TODO Auto-generated method stub
return this.baseMapper.getMyList(bizType, accountId, siteId, companyId);
}
}
package com.yizhi.application.service.impl;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yizhi.application.domain.TaskAppendix;
import com.yizhi.message.application.constans.Constans;
import com.yizhi.core.application.context.ContextHolder;
import com.yizhi.core.application.context.RequestContext;
import com.yizhi.application.mapper.TaskAppendixMapper;
import com.yizhi.comment.application.vo.domain.TaskAppendixVo;
import com.yizhi.application.orm.id.IdGenerator;
import com.yizhi.application.service.ITaskAppendixService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* <p>
* 服务实现类
* </p>
*
* @author taoge123
* @since 2020-01-16
*/
@Service
public class TaskAppendixServiceImpl extends ServiceImpl<TaskAppendixMapper, TaskAppendix> implements ITaskAppendixService {
@Autowired
private IdGenerator idGenerator;
@Override
public Integer save(Integer taskType, Long taskId, List<com.yizhi.comment.application.vo.TaskAppendixVo> taskAppendixVoVos) {
if (CollectionUtils.isEmpty(taskAppendixVoVos)) {
return 0;
}
RequestContext context = ContextHolder.get();
List<TaskAppendix> informAppendices = new ArrayList<>(taskAppendixVoVos.size());
taskAppendixVoVos.forEach(a -> {
TaskAppendix taskAppendixVo = new TaskAppendix();
BeanUtils.copyProperties(a, taskAppendixVo);
taskAppendixVo.setId(idGenerator.generate());
taskAppendixVo.setTaskType(taskType);
taskAppendixVo.setTaskId(taskId);
taskAppendixVo.setCreateById(context.getAccountId());
taskAppendixVo.setCreateByName(context.getAccountName());
taskAppendixVo.setCreateTime(new Date());
informAppendices.add(taskAppendixVo);
});
return this.insertBatch(informAppendices) == true ? 1 : 0;
}
@Override
public List<com.yizhi.comment.application.vo.TaskAppendixVo> getList(Integer taskType, Long taskId) {
TaskAppendix taskAppendixVo = new TaskAppendix();
taskAppendixVo.setTaskType(taskType);
taskAppendixVo.setDeleted(Constans.NOT_DELETED);
taskAppendixVo.setTaskId(taskId);
EntityWrapper<TaskAppendix> wrapper = new EntityWrapper(taskAppendixVo);
List<TaskAppendix> informAppendices = this.selectList(wrapper);
List<com.yizhi.comment.application.vo.TaskAppendixVo> taskAppendixVoVos = null;
if (!CollectionUtils.isEmpty(informAppendices)) {
taskAppendixVoVos = new ArrayList<>(informAppendices.size());
for (TaskAppendix a : informAppendices) {
com.yizhi.comment.application.vo.TaskAppendixVo vo = new com.yizhi.comment.application.vo.TaskAppendixVo();
BeanUtils.copyProperties(a, vo);
taskAppendixVoVos.add(vo);
}
}
return taskAppendixVoVos;
}
@Override
public Map<Long, List<com.yizhi.comment.application.vo.TaskAppendixVo>> getListMap(Integer taskType, List<Long> taskIds) {
Map<Long, List<com.yizhi.comment.application.vo.TaskAppendixVo>> map = null;
if (!CollectionUtils.isEmpty(taskIds)) {
map = new HashMap<>(taskIds.size());
TaskAppendix taskAppendixVo = new TaskAppendix();
taskAppendixVo.setTaskType(taskType);
taskAppendixVo.setDeleted(Constans.NOT_DELETED);
EntityWrapper<TaskAppendix> wrapper = new EntityWrapper(taskAppendixVo);
wrapper.in("task_id", taskIds);
List<TaskAppendix> informAppendices = this.selectList(wrapper);
if (!CollectionUtils.isEmpty(informAppendices)) {
for (TaskAppendix a : informAppendices) {
com.yizhi.comment.application.vo.TaskAppendixVo vo = new com.yizhi.comment.application.vo.TaskAppendixVo();
BeanUtils.copyProperties(a, vo);
if (map.containsKey(a.getTaskId())) {
List<com.yizhi.comment.application.vo.TaskAppendixVo> taskAppendixVoVos = map.get(a.getTaskId());
taskAppendixVoVos.add(vo);
map.put(a.getTaskId(), taskAppendixVoVos);
} else {
List<com.yizhi.comment.application.vo.TaskAppendixVo> taskAppendixVoVos = new ArrayList<>(informAppendices.size());
taskAppendixVoVos.add(vo);
map.put(a.getTaskId(), taskAppendixVoVos);
}
}
}
}
return map;
}
}
package com.yizhi.application.task;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.yizhi.application.domain.NewReply;
import com.yizhi.application.service.ICommentService;
import com.yizhi.application.service.IReplyService;
import com.yizhi.comment.application.vo.domain.NewReplyVo;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.core.application.file.constant.FileConstant;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.core.application.file.util.OssUpload;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.vo.AccountVO;
import com.yizhi.comment.application.vo.CommentVo;
@Component
public class CommentListExportAsync extends AbstractDefaultTask<String, Map<String,Object>>{
private static final Logger logger = LoggerFactory.getLogger(CommentListExportAsync.class);
@Autowired
private ICommentService commentService;
@Autowired
private IReplyService replyService;
@Autowired
private AccountClient accountClient;
@Override
protected String execute(Map<String, Object> arg0) {
Long accountId=(Long) arg0.get("accountId");
Long siteId=(Long) arg0.get("siteId");
Long companyId=(Long) arg0.get("companyId");
Long taskId=(Long) arg0.get("taskId");
Date submitTime=(Date) arg0.get("submitTime");
String serialNo=(String) arg0.get("serialNo");
String taskName=(String) arg0.get("taskName");
Long bizId=(Long) arg0.get("bizId");
Integer bizType = (Integer) arg0.get("bizType");
String bizName=(String) arg0.get("bizName");
/**
* 走异步任务
*/
TaskContext taskContext = new TaskContext(taskId, serialNo, taskName, accountId, submitTime, siteId, companyId);
working(taskContext);
String upLoadUrl=null;
String requestPath=FileConstant.SAVE_PATH;
File fileDir=new File(requestPath);
if(!fileDir.exists()) {
fileDir.mkdir();
}
List<CommentVo> listVO=new ArrayList<CommentVo>();
List<CommentVo> list = null;
list = commentService.getCommentList(bizId,bizType);
NewReply reply = new NewReply();
CommentVo vo = new CommentVo();
for(CommentVo commentVo:list) {
AccountVO accountVO = accountClient.findById(commentVo.getAccountId());
commentVo.setCommentatorName(null==accountVO.getFullName()||""==accountVO.getFullName()?accountVO.getName():accountVO.getFullName());
commentVo.setReplyName(bizName);
commentVo.setCommentator(accountVO.getName());
reply.setCommentId(commentVo.getId());
EntityWrapper<NewReply> wrapper = new EntityWrapper<NewReply>(reply);
wrapper.notIn("state", 0);
List<String> time = new ArrayList<String>();
time.add("createTime");
wrapper.orderDesc(time);
List<NewReply> replyList = replyService.selectList(wrapper);
listVO.add(commentVo);
for(NewReply r:replyList) {
CommentVo vo1 = new CommentVo();
if (null!=r.getReplyParentId()&&0!=r.getReplyParentId()) {
Long accountId1 = replyService.selectById(r.getReplyParentId()).getCreateById();
AccountVO findById = accountClient.findById(accountId1);
vo1.setReplyName(null==findById.getFullName()||""==findById.getFullName()?findById.getName():findById.getFullName());
}else {
AccountVO findById = accountClient.findById(commentService.selectById(r.getCommentId()).getCreateById());
vo1.setReplyName(null==findById.getFullName()||""==findById.getFullName()?findById.getName():findById.getFullName());
}
logger.info("-----");
AccountVO findById = accountClient.findById(r.getCreateById());
vo1.setId(r.getId());
vo1.setAccountId(findById.getId());
vo1.setCommentator(findById.getName());
vo1.setCommentatorName(null==findById.getFullName()||""==findById.getFullName()?findById.getName():findById.getFullName());
vo1.setContent(r.getContent());
vo1.setCreateTime(r.getCreateTime());
vo1.setState(reply.getState());
vo1.setThumbsUp(0);
listVO.add(vo1);
}
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
try {
//excel生成过程: excel-->sheet-->row-->cell
// 第一步,创建一个Excel文件
XSSFWorkbook wb = new XSSFWorkbook();
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
XSSFSheet sheet = wb.createSheet("评论信息");
XSSFFont font = wb.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 11);
font.setBold(true);
XSSFCellStyle style = wb.createCellStyle();
style.setFont(font);
style.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
XSSFRow row = sheet.createRow((int) 0);
row.setHeight((short) (20*20));
// 合并单元格
CellRangeAddress cra=new CellRangeAddress(0,0,0,7); // 起始行, 终止行, 起始列, 终止列
sheet.addMergedRegion(cra);
XSSFCell cell = row.createCell((short) 0);
cell.setCellValue(bizName+"评论信息 "+sf.format(submitTime));
cell.setCellStyle(style);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
XSSFRow row2 = sheet.createRow((int) 1);
row2.setRowStyle(style);
row2.setHeight((short) (14*20));
// 第四步,创建单元格
row2.createCell((short) 0).setCellValue("评论人/回复人");
row2.createCell((short) 1).setCellValue("姓名");
row2.createCell((short) 2).setCellValue("评论对象");
row2.createCell((short) 3).setCellValue("评论内容");
row2.createCell((short) 4).setCellValue("提交时间");
row2.createCell((short) 5).setCellValue("点赞数");
row2.createCell((short) 6).setCellValue("状态");
for(int i=0;i<listVO.size();i++) {
font.setBold(false);
row = sheet.createRow(i + 2);
row.setRowStyle(style);
row.setHeight((short) (13*20));
// 第四步,创建单元格,并设置值
vo=listVO.get(i);
if(vo!=null&&vo.getCommentator()!=null) {
row.createCell((short) 0).setCellValue(vo.getCommentator());
}
if(vo!=null&&vo.getCommentatorName()!=null) {
row.createCell((short) 1).setCellValue(null==vo.getCommentatorName()?"":vo.getCommentatorName());
}
if(vo!=null&&vo.getReplyName()!=null) {
row.createCell((short) 2).setCellValue(null==vo.getReplyName()?"":vo.getReplyName());
}
if(vo!=null&&vo.getContent()!=null) {
row.createCell((short) 3).setCellValue(vo.getContent());
}
if(vo!=null&&vo.getCreateTime()!=null) {
row.createCell((short) 4).setCellValue(df.format(vo.getCreateTime()));
}
if (vo!=null&&vo.getThumbsUp()!=null) {
row.createCell((short) 5).setCellValue(null==vo.getThumbsUp()?"--":vo.getThumbsUp().toString());
}
if (vo!=null&&vo.getState()!=null) {
row.createCell((short) 6).setCellValue(1==vo.getState()?"已上架":"已下架");
}
}
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
StringBuffer fileNameSb = new StringBuffer().append(bizName+"评论记录").append(sf.format(submitTime)).append(".xlsx");
String fileName = fileNameSb.toString();
String path = new StringBuffer().append(requestPath).append(fileNameSb).toString();
FileOutputStream os=null;
File file=null;
try {
os= new FileOutputStream(path);
wb.write(os);
//阿里云返回url
upLoadUrl = OssUpload.upload(path, fileName);
file=new File(path);
success(taskContext,"成功", upLoadUrl);
} catch (Exception e1) {
e1.printStackTrace();
fail(taskContext, "写入数据到Excel的过程中或者上传到阿里云中发生错误"+e1.getMessage());
logger.error("写入数据到Excel的过程中或者上传到阿里云中发生错误"+e1.getMessage());
}
finally {
if(os!=null) {
os.close();
}
if(wb!=null) {
wb.close();
}
if(file!=null) {
file.delete();
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(taskContext, "评论信息导出过程中发生错误,请查看日志"+e.getMessage());
logger.error("评论信息导出过程中发生错误,请查看日志"+e.getMessage());
}
return upLoadUrl;
}
}
package com.yizhi.application.task;
import com.baomidou.mybatisplus.plugins.Page;
import com.yizhi.application.service.ICommentService;
import com.yizhi.comment.application.constans.Constant;
import com.yizhi.core.application.context.TaskContext;
import com.yizhi.forum.application.vo.domain.PostsForbiddenAccountVo;
import com.yizhi.forum.application.feign.PostsForbiddenAccountClient;
import com.yizhi.core.application.file.task.AbstractDefaultTask;
import com.yizhi.core.application.file.util.OssUpload;
import com.yizhi.forum.application.feign.PostsForbiddenAccountClient;
import com.yizhi.system.application.system.remote.AccountClient;
import com.yizhi.system.application.vo.AccountVO;
import com.yizhi.comment.application.vo.ManageCommentVo;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Component
public class ForumCommentExportAsync extends AbstractDefaultTask<String, Map<String, Object>> {
private static final Logger logger = LoggerFactory.getLogger(ForumCommentExportAsync.class);
@Autowired
private ICommentService commentService;
@Autowired
private AccountClient accountClient;
@Autowired
private PostsForbiddenAccountClient postsForbiddenAccountClient;
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMddHHmmss");
@Override
protected String execute(Map<String, Object> arg0) {
Long taskId = (Long) arg0.get("currentTaskId");
String serialNo = (String) arg0.get("serialNo");
String taskName = (String) arg0.get("currentTaskName");
Long accountId = Long.valueOf(arg0.get("accountId").toString());
Date submitTime = new Date((Long) arg0.get("submitTime"));
Long siteId = Long.valueOf(arg0.get("siteId").toString());
Long companyId = Long.valueOf(arg0.get("companyId").toString());
Long bizId = (Long) arg0.get("bizId");
Integer bizType = (Integer) arg0.get("bizType");
String bizName = (String) arg0.get("bizName");
/**
* 走异步任务
*/
TaskContext taskContext = new TaskContext(taskId, serialNo, taskName, accountId, submitTime, siteId, companyId);
working(taskContext);
//获取单个帖子下的回复数据
Page<ManageCommentVo> page = commentService.getPageToManage(Constant.TASK_TYPE_POSTS, bizId, 1, Integer.MAX_VALUE);
if (page == null) {
return "数据为空!";
}
List<ManageCommentVo> records = page.getRecords();
if (CollectionUtils.isEmpty(records)) {
return "数据为空!";
}
//获取禁言名单
List<PostsForbiddenAccountVo> postsForbiddenAccountVoList = postsForbiddenAccountClient.getListByPostsId(Arrays.asList(bizId));
List<Long> forbiddenAccountIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(postsForbiddenAccountVoList)) {
forbiddenAccountIds = postsForbiddenAccountVoList.stream().map(a -> a.getAccountId()).collect(Collectors.toList());
}
/*List<PostsForbiddenAccount> forbiddenAccounts = postsForbiddenAccountClient.getListByPostsId(Arrays.asList(bizId));
List<Long> forbiddenAccountIds = new ArrayList<>();
if (!CollectionUtils.isEmpty(forbiddenAccounts)) {
forbiddenAccountIds = forbiddenAccounts.stream().map(a -> a.getAccountId()).collect(Collectors.toList());
}*/
//实时获取用户名
Set<Long> accountIds = new HashSet<>(records.size());
records.forEach(a -> {
accountIds.add(a.getAccountId());
});
Map<Long, AccountVO> accountMap = this.queryAccountByIds(new ArrayList<>(accountIds));
for (ManageCommentVo a : records) {
//判断是否被禁言
if (!CollectionUtils.isEmpty(forbiddenAccountIds)) {
if (forbiddenAccountIds.contains(a.getAccountId())) {
a.setStatus(3);
a.setStatusString("已禁言");
}
}
//填充用户信息
if (accountMap != null) {
AccountVO accountVO = accountMap.get(a.getAccountId());
if (accountVO != null) {
a.setFullName(accountVO.getFullName());
a.setCommentator(accountVO.getName());
}
AccountVO accountVO1 = accountMap.get(a.getBeAnswerId());
if (accountVO1 != null) {
a.setBeAnswerName(accountVO1.getName());
}
}
}
//下载路径
String upLoadUrl = null;
try {
//excel生成过程: excel-->sheet-->row-->cell
// 第一步,创建一个Excel文件
XSSFWorkbook wb = new XSSFWorkbook();
String title = bizName + "回复信息" + format1.format(submitTime);
// 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet
XSSFSheet sheet = wb.createSheet(title);
XSSFFont font = wb.createFont();
// font.setFontName("宋体");
// font.setFontHeightInPoints((short) 11);
font.setBold(true);
XSSFCellStyle style = wb.createCellStyle();
style.setFont(font);
//居中格式
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制short
XSSFRow row = sheet.createRow((int) 0);
// 合并单元格
CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 7); // 起始行, 终止行, 起始列, 终止列
sheet.addMergedRegion(cra);
XSSFCell cell = row.createCell((short) 0);
cell.setCellValue(title);
cell.setCellStyle(style);
XSSFRow titleRow = sheet.createRow((int) 1);
// row2.setRowStyle(style);
// row2.setHeight((short) (14 * 20));
// 第四步,创建单元格
titleRow.createCell((short) 0).setCellValue("回复人");
titleRow.createCell((short) 1).setCellValue("姓名");
titleRow.createCell((short) 2).setCellValue("回复对象");
titleRow.createCell((short) 3).setCellValue("回复内容");
titleRow.createCell((short) 4).setCellValue("回复时间");
titleRow.createCell((short) 5).setCellValue("点赞数");
titleRow.createCell((short) 6).setCellValue("回复状态");
for (int i = 0; i < records.size(); i++) {
row = sheet.createRow(i + 2);
// row.setRowStyle(style);
// row.setHeight((short) (13 * 20));
// 第四步,创建单元格,并设置值
ManageCommentVo vo = records.get(i);
if (vo != null) {
row.createCell((short) 0).setCellValue(null == vo.getCommentator() ? "" : vo.getCommentator());
row.createCell((short) 1).setCellValue(null == vo.getFullName() ? "" : vo.getFullName());
row.createCell((short) 2).setCellValue(null == vo.getBeAnswerName() ? "" : vo.getBeAnswerName());
row.createCell((short) 3).setCellValue(null == vo.getContent() ? "" : vo.getContent());
row.createCell((short) 4).setCellValue(null == vo.getCreateTimeString() ? "" : vo.getCreateTimeString());
row.createCell((short) 5).setCellValue(null == vo.getCommentAdmires() ? "0个" : vo.getCommentAdmires() + "个");
row.createCell((short) 6).setCellValue(null == vo.getStatusString() ? "" : vo.getStatusString());
}
}
String requestPath = "D:\\";
// String requestPath = FileConstant.SAVE_PATH;
File fileDir = new File(requestPath);
if (!fileDir.exists()) {
fileDir.mkdir();
}
// 第五步,写入实体数据 实际应用中这些数据从数据库得到,
StringBuffer fileNameSb = new StringBuffer().append(title).append(".xlsx");
String path = new StringBuffer().append(requestPath).append(fileNameSb).toString();
FileOutputStream os = null;
File file = null;
try {
os = new FileOutputStream(path);
wb.write(os);
//阿里云返回url
upLoadUrl = OssUpload.upload(path, fileNameSb.toString());
file = new File(path);
success(taskContext, "成功", upLoadUrl);
} catch (Exception e1) {
e1.printStackTrace();
fail(taskContext, "写入数据到Excel的过程中或者上传到阿里云中发生错误" + e1.getMessage());
logger.error("写入数据到Excel的过程中或者上传到阿里云中发生错误" + e1.getMessage());
} finally {
if (os != null) {
os.close();
}
if (wb != null) {
wb.close();
}
if (file != null) {
file.delete();
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(taskContext, "评论信息导出过程中发生错误,请查看日志" + e.getMessage());
logger.error("评论信息导出过程中发生错误,请查看日志" + e.getMessage());
}
return upLoadUrl;
}
/**
* 返回《accountId,account》的map
*
* @param accountIds
* @return
*/
public Map<Long, AccountVO> queryAccountByIds(List<Long> accountIds) {
if (!CollectionUtils.isEmpty(accountIds)) {
Map<Long, AccountVO> map = new HashMap<>(accountIds.size());
List<AccountVO> accountVOS = accountClient.findByIds(accountIds);
//组装map 以免双重循环
if (!CollectionUtils.isEmpty(accountVOS)) {
accountVOS.forEach(a -> {
if (!map.containsKey(a.getId())) {
map.put(a.getId(), a);
}
});
}
return map;
}
return null;
}
}
server.port=39001
spring.application.name=comment
ACTIVE=${spring.profiles.active}
spring.profiles.active=dev
# nacos
spring.cloud.nacos.config.shared-dataids=common-${spring.profiles.active}.properties
spring.cloud.nacos.config.namespace=${spring.profiles.active}
spring.cloud.nacos.config.prefix=${spring.application.name}
spring.cloud.nacos.config.file-extension=properties
spring.cloud.nacos.config.server-addr=192.168.1.22:3333,192.168.1.22:4444,192.168.1.22:5555
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yizhi</groupId>
<artifactId>wmy-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath/>
</parent>
<groupId>com.yizhi</groupId>
<artifactId>comment</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>cloud-comment-api</module>
<module>cloud-comment</module>
</modules>
<repositories>
<repository>
<id>wmy4.0</id>
<url>http://mvn.km365.pw/nexus/content/groups/wmy4.0-group/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment