提交
This commit is contained in:
34
ruoyi-main/ruoyi-post/pom.xml
Normal file
34
ruoyi-main/ruoyi-post/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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.ruoyi</groupId>
|
||||
<artifactId>ruoyi-main</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ruoyi-post</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-custom</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-message</artifactId>
|
||||
<version>3.7.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.post.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.annotations.UserLoginToken;
|
||||
import com.ruoyi.common.page.PageResult;
|
||||
import com.ruoyi.controller.req.DialoguePageReq;
|
||||
import com.ruoyi.post.controller.req.DeleteCommentReq;
|
||||
import com.ruoyi.post.controller.req.PostCommentPageReq;
|
||||
import com.ruoyi.post.controller.req.PostCommentReq;
|
||||
import com.ruoyi.post.controller.resp.PostCommentPageResp;
|
||||
import com.ruoyi.post.controller.resp.PostCommentResp;
|
||||
import com.ruoyi.post.frequency.postcomment.service.PostCommentService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.BodyIdReq;
|
||||
import com.ruoyi.vo.RyController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 帖子评论相关
|
||||
* @author liwenlong
|
||||
*
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/postComment")
|
||||
@Api(tags = "帖子评论相关")
|
||||
public class ApiPostCommentController extends RyController {
|
||||
|
||||
@Autowired
|
||||
private PostCommentService postCommentService;
|
||||
|
||||
@PostMapping("/postComment")
|
||||
@UserLoginToken
|
||||
@ApiOperation(value = "帖子评论", notes = "帖子评论")
|
||||
public ResponseData<PostCommentResp> postComment(@RequestBody PostCommentReq req) {
|
||||
return postCommentService.postComment(req,getUserVo());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/postCommentPage")
|
||||
@ApiOperation(value = "帖子评论列表", notes = "帖子评论列表")
|
||||
public ResponseData<PageResult<PostCommentPageResp>> postCommentPage(@RequestBody PostCommentPageReq req) {
|
||||
return postCommentService.postCommentPage(req,getUserVo());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/deleteComment")
|
||||
@UserLoginToken
|
||||
@ApiOperation(value = "删除评论", notes = "删除评论")
|
||||
public ResponseData deleteComment(@RequestBody DeleteCommentReq req) {
|
||||
return postCommentService.deleteComment(req,getUserVo());
|
||||
}
|
||||
|
||||
@PostMapping("/postCommentDetail")
|
||||
@ApiOperation(value = "帖子评论详情", notes = "帖子评论详情")
|
||||
public ResponseData<PostCommentResp> postCommentDetail(@RequestBody BodyIdReq req) {
|
||||
return postCommentService.postCommentDetail(req.getId(),getUserVo());
|
||||
}
|
||||
|
||||
@PostMapping("/postCommentDialoguePage")
|
||||
@ApiOperation(value = "帖子对话评论列表", notes = "帖子对话评论列表")
|
||||
public ResponseData<PageResult<Page<PostCommentPageResp>>> postCommentDialoguePage(@RequestBody DialoguePageReq req) {
|
||||
return postCommentService.postCommentDialoguePage(req,getUserVo());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ruoyi.post.controller;
|
||||
|
||||
import com.ruoyi.annotations.UserLoginToken;
|
||||
import com.ruoyi.post.controller.req.PostLikeReq;
|
||||
import com.ruoyi.post.frequency.postlike.service.PostLikeService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.RyController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 帖子点赞相关
|
||||
* @author liwenlong
|
||||
*
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/postLike")
|
||||
@Api(tags = "帖子点赞相关")
|
||||
public class ApiPostLikeController extends RyController {
|
||||
|
||||
@Autowired
|
||||
private PostLikeService postLikeService;
|
||||
|
||||
|
||||
/**
|
||||
* 帖子点赞
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/postLike")
|
||||
@UserLoginToken
|
||||
@ApiOperation(value = "帖子点赞", notes = "帖子点赞")
|
||||
public ResponseData postLike(@RequestBody PostLikeReq req) {
|
||||
return postLikeService.postLike(req,getUserVo());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.ruoyi.post.controller;
|
||||
|
||||
import com.ruoyi.annotations.UserLoginToken;
|
||||
import com.ruoyi.post.controller.req.PostReportReq;
|
||||
import com.ruoyi.post.frequency.posreport.service.PostReportService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.RyController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 帖子举报相关
|
||||
* @author liwenlong
|
||||
*
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/postReport")
|
||||
@Api(tags = "帖子举报相关")
|
||||
public class ApiPostReportController extends RyController {
|
||||
|
||||
@Autowired
|
||||
private PostReportService postReportService;
|
||||
|
||||
@PostMapping("/postReport")
|
||||
@UserLoginToken
|
||||
@ApiOperation(value = "帖子举报", notes = "帖子举报")
|
||||
public ResponseData postReport(@RequestBody PostReportReq req) {
|
||||
return postReportService.postReport(req,getUserVo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.post.controller;
|
||||
|
||||
import com.ruoyi.annotations.UserLoginToken;
|
||||
import com.ruoyi.post.frequency.posshield.service.PostShieldService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.BodyIdReq;
|
||||
import com.ruoyi.vo.RyController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 帖子屏蔽
|
||||
* @author liwenlong
|
||||
*
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/postShield")
|
||||
@Api(tags = "帖子屏蔽")
|
||||
public class ApiPostShieldController extends RyController {
|
||||
|
||||
@Autowired
|
||||
private PostShieldService postShieldService;
|
||||
|
||||
@PostMapping("/postShield")
|
||||
@UserLoginToken
|
||||
@ApiOperation(value = "帖子屏蔽", notes = "帖子屏蔽")
|
||||
public ResponseData postShield(@RequestBody BodyIdReq req) {
|
||||
return postShieldService.postShield(req.getId(),getUserVo());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ruoyi.post.controller;
|
||||
|
||||
import com.ruoyi.post.controller.req.PostTypeListReq;
|
||||
import com.ruoyi.post.frequency.posttype.entity.PostType;
|
||||
import com.ruoyi.post.frequency.posttype.service.PostTypeService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.RyController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子分类
|
||||
* @author liwenlong
|
||||
*
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/api/postType")
|
||||
@Api(tags = "帖子分类")
|
||||
public class ApiPostTypeController extends RyController {
|
||||
|
||||
@Autowired
|
||||
private PostTypeService postTypeService;
|
||||
|
||||
|
||||
@ApiOperation(value = "获取帖子分类列表")
|
||||
@PostMapping("/postTypeList")
|
||||
public ResponseData<List<PostType>> postTypeList(@RequestBody PostTypeListReq req) {
|
||||
return postTypeService.postTypeList(req);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/1 10:05
|
||||
*/
|
||||
@Data
|
||||
public class CommentMessageReadOrDeleteReq {
|
||||
|
||||
|
||||
/**
|
||||
* 1 标记已读 2 删除消息
|
||||
*/
|
||||
@NotNull(message = "类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 评论消息id 集合 为空删除全部
|
||||
*/
|
||||
@NotNull(message = "评论消息id不能为空")
|
||||
private List<Long> ids;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/13 18:28
|
||||
*/
|
||||
@Data
|
||||
public class DeleteCommentReq {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
// /**
|
||||
// * 类型 1 帖子评论 2
|
||||
// */
|
||||
// @NotNull(message = "类型不能为空")
|
||||
// private Integer type;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/1 10:04
|
||||
*/
|
||||
@Data
|
||||
public class LikeMessageReadOrDeleteReq {
|
||||
|
||||
/**
|
||||
* 1 标记已读 2 删除消息
|
||||
*/
|
||||
@NotNull(message = "类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 点赞消息id 集合 为空删除全部
|
||||
*/
|
||||
@NotNull(message = "点赞消息id不能为空")
|
||||
private List<Long> ids;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import com.ruoyi.vo.PageBasic;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 14:18
|
||||
*/
|
||||
@Data
|
||||
public class PostCommentPageReq extends PageBasic {
|
||||
|
||||
@NotNull(message = "帖子id不能为空")
|
||||
@ApiModelProperty(value = "帖子id", required = true)
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty(value = "上级评论id", required = false)
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("排序 1时间 2热度")
|
||||
private Integer sortType;
|
||||
|
||||
@ApiModelProperty(value = "1升序 2 降序")
|
||||
private Integer isAsc;
|
||||
|
||||
@ApiModelProperty(value = "拉黑用户")
|
||||
private List<UserVo> blockUserList;
|
||||
|
||||
@ApiModelProperty(value = "屏蔽用户")
|
||||
private List<UserVo> shieldUserList;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 14:17
|
||||
*/
|
||||
@Data
|
||||
public class PostCommentReq {
|
||||
|
||||
|
||||
@NotNull(message = "帖子id不能为空")
|
||||
@ApiModelProperty(value = "帖子id", required = true)
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty(value = "上级评论id,如果没有上级评论,(不传值默认0,评论帖子)")
|
||||
private Long parentId = 0L;
|
||||
|
||||
@ApiModelProperty(value = "评论内容", required = true)
|
||||
@NotNull(message = "评论内容不能为空")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("评论图片")
|
||||
private String image;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 16:18
|
||||
*/
|
||||
@Data
|
||||
public class PostLikeReq {
|
||||
|
||||
|
||||
/**
|
||||
* 1 帖子 2 帖子评论
|
||||
*/
|
||||
@NotNull(message = "类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 帖子id/帖子评论id
|
||||
*/
|
||||
@NotNull(message = "objectId不能为空")
|
||||
private Long objectId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import com.ruoyi.vo.PageBasic;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 14:07
|
||||
*/
|
||||
@Data
|
||||
public class PostPageReq extends PageBasic {
|
||||
|
||||
@ApiModelProperty(value = "类型 1 关注 2 发现")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "帖子分类id")
|
||||
private Long postTypeId;
|
||||
|
||||
@ApiModelProperty(value = "关键字搜索")
|
||||
private String keyword;
|
||||
|
||||
@ApiModelProperty(value = "用户类型 1 用户 对应枚举 UserEnums")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "帖子类型 1 帖子(用户发布) 2资讯(平台发布)")
|
||||
private Integer postType;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("排序方式 1 最新 2 点赞最多 3 评论最多")
|
||||
private Integer orderSort;
|
||||
|
||||
@ApiModelProperty(value = "拉黑用户")
|
||||
private List<UserVo> blockUserList;
|
||||
|
||||
@ApiModelProperty(value = "屏蔽用户")
|
||||
private List<UserVo> shieldUserList;
|
||||
|
||||
@ApiModelProperty(value = "屏蔽的帖子")
|
||||
private List<Long> shieldPostIdList;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 14:02
|
||||
*/
|
||||
@Data
|
||||
public class PostReleaseReq {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "帖子id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "帖子分类id")
|
||||
private Long postTypeId;
|
||||
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "封面图")
|
||||
private String coverImage;
|
||||
|
||||
@ApiModelProperty(value = "视频路径")
|
||||
private String videoUrl;
|
||||
|
||||
@ApiModelProperty(value = "地址")
|
||||
private String address;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 17:08
|
||||
*/
|
||||
@Data
|
||||
public class PostReportReq {
|
||||
|
||||
/**
|
||||
* 帖子id
|
||||
*/
|
||||
private Long postId;
|
||||
|
||||
/**
|
||||
* 举报原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private String images;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.post.controller.req;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author a
|
||||
* @date 2024/1/29 15:24
|
||||
*/
|
||||
@Data
|
||||
public class PostTypeListReq {
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("1帖子 2 资讯")
|
||||
private Integer type;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.post.controller.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/1 9:54
|
||||
*/
|
||||
@Data
|
||||
public class CommentMessagePageResp {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 1未读 2 已读
|
||||
*/
|
||||
private Integer isRead;
|
||||
/**
|
||||
* 是否清空 1 不清空 2 清空
|
||||
*/
|
||||
private Integer isShow;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
|
||||
/**
|
||||
* 跳转id
|
||||
*/
|
||||
private Long skipId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户类型 1 用户 2 商家
|
||||
*/
|
||||
private Integer userType;
|
||||
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.ruoyi.post.controller.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/3/31 17:51
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class LikeMessagePageResp {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 用户类型 : 1用户 2 商家
|
||||
*/
|
||||
private Integer userType;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 消息类型 1 论坛 2 视频
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer objectType;
|
||||
|
||||
/**
|
||||
* 主体id
|
||||
*/
|
||||
private Long skipId;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 1未读 2 已读
|
||||
*/
|
||||
private Integer isRead;
|
||||
/**
|
||||
* 是否清空 1 不清空 2 清空
|
||||
*/
|
||||
private Integer isShow;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.post.controller.resp;
|
||||
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 14:26
|
||||
*/
|
||||
@Data
|
||||
public class PostCommentPageResp {
|
||||
|
||||
@ApiModelProperty(value = "租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "上级用户类型")
|
||||
private Integer parentUserType;
|
||||
|
||||
@ApiModelProperty(value = "上级用户id")
|
||||
private Long parentUserId;
|
||||
|
||||
@ApiModelProperty(value = "上级评论id")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty(value = "用户信息")
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ApiModelProperty(value = "上级用户用户昵称")
|
||||
private UserInfo parentUserInfo;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty("顶级评论id")
|
||||
private Long topId;
|
||||
|
||||
@ApiModelProperty(value = "点赞数")
|
||||
private Integer likeNum;
|
||||
|
||||
@ApiModelProperty(value = "评论数")
|
||||
private Integer commentNum;
|
||||
|
||||
@ApiModelProperty(value = "是否点赞 1 没有 2 点赞")
|
||||
private Integer isLike;
|
||||
|
||||
@ApiModelProperty(value = "是否自己 1 不是 2 是自己")
|
||||
private Integer isSelf;
|
||||
|
||||
@ApiModelProperty(value = "是否精选评论 1 不是 2 是")
|
||||
private Integer isSelectedComment;
|
||||
|
||||
@ApiModelProperty(value = "二级评论")
|
||||
private List<PostCommentPageResp> childrenList;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.post.controller.resp;
|
||||
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class PostCommentResp {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "评论id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "上级评论id")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty(value = "评论内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "点赞数")
|
||||
private Integer likeNum;
|
||||
|
||||
@ApiModelProperty(value = "评论数")
|
||||
private Integer commentNum;
|
||||
|
||||
@ApiModelProperty(value = "是否点赞1没有 2点赞")
|
||||
private Integer isLike;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "评论时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("顶级评论id")
|
||||
private Long topId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("评论用户id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "评论用户信息")
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
private Integer parentUserType;
|
||||
|
||||
@ApiModelProperty("上级评论用户id")
|
||||
private Long parentUserId;
|
||||
|
||||
@ApiModelProperty(value = "上级评论用户信息")
|
||||
private UserInfo parentUserInfo;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.ruoyi.post.controller.resp;
|
||||
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 17:32
|
||||
*/
|
||||
@Data
|
||||
public class PostDetailResp {
|
||||
|
||||
@ApiModelProperty(value = "帖子id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "头像")
|
||||
private String avatar;
|
||||
|
||||
@ApiModelProperty(value = "昵称")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "用户类型 1用户")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "帖子内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("图片(包括封面图)")
|
||||
private String coverImage;
|
||||
|
||||
@ApiModelProperty("视频路径(一个)")
|
||||
private String videoUrl;
|
||||
|
||||
@ApiModelProperty(value = "分享数量")
|
||||
private Integer shareNum;
|
||||
|
||||
@ApiModelProperty(value = "点赞数量")
|
||||
private Integer likeNum;
|
||||
|
||||
@ApiModelProperty(value = "评论数量")
|
||||
private Integer commentNum;
|
||||
|
||||
@ApiModelProperty(value = "收藏数量")
|
||||
private Integer collectNum;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browseNum;
|
||||
|
||||
@ApiModelProperty(value = "审核状态 1 待审核 2 同意 3失败")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty(value = "失败原因")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty(value = "是否点赞 1没有 2点赞")
|
||||
private Integer isLike;
|
||||
|
||||
@ApiModelProperty(value = "是否收藏 1没有 2收藏")
|
||||
private Integer isCollect;
|
||||
|
||||
@ApiModelProperty(value = "是否是自己 1不是 2是")
|
||||
private Integer isSelf;
|
||||
|
||||
@ApiModelProperty("地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty("帖子分类名称")
|
||||
private String postTypeName;
|
||||
|
||||
@ApiModelProperty("用户信息")
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ApiModelProperty("描述")
|
||||
private String describes;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.ruoyi.post.controller.resp;
|
||||
|
||||
import com.ruoyi.post.controller.vo.SelectedComment;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author liwenlong
|
||||
* @date 2023/4/17 17:30
|
||||
*/
|
||||
@Data
|
||||
public class PostPageResp {
|
||||
|
||||
@ApiModelProperty(value = "帖子id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "用户类型 1用户")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@ApiModelProperty("封面图")
|
||||
private String coverImage;
|
||||
|
||||
@ApiModelProperty("视频路径(一个)")
|
||||
private String videoUrl;
|
||||
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "帖子内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "分享数量")
|
||||
private Integer shareNum;
|
||||
|
||||
@ApiModelProperty(value = "点赞数量")
|
||||
private Integer likeNum;
|
||||
|
||||
@ApiModelProperty(value = "评论数量")
|
||||
private Integer commentNum;
|
||||
|
||||
@ApiModelProperty(value = "收藏数量")
|
||||
private Integer collectNum;
|
||||
|
||||
@ApiModelProperty(value = "浏览量")
|
||||
private Integer browseNum;
|
||||
|
||||
@ApiModelProperty(value = "审核状态 1 待审核 2 同意 3失败")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty(value = "失败原因")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty(value = "是否点赞 1没有 2点赞")
|
||||
private Integer isLike;
|
||||
|
||||
@ApiModelProperty(value = "是否收藏 1没有 2收藏")
|
||||
private Integer isCollect;
|
||||
|
||||
@ApiModelProperty(value = "是否是自己 1不是 2是")
|
||||
private Integer isSelf;
|
||||
|
||||
@ApiModelProperty("地址")
|
||||
private String address;
|
||||
|
||||
@ApiModelProperty("用户信息")
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ApiModelProperty("精选评论")
|
||||
private SelectedComment selectedComment;
|
||||
|
||||
@ApiModelProperty("是否推荐 1否 2是")
|
||||
private Integer isRecommend;
|
||||
|
||||
@ApiModelProperty("推荐排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("精彩评论id")
|
||||
private Long commentId;
|
||||
|
||||
@ApiModelProperty("描述")
|
||||
private String describes;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.post.controller.vo;
|
||||
|
||||
import com.ruoyi.post.frequency.postcomment.entity.PostComment;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 帖子评论对象 t_post_comment
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SelectedComment
|
||||
{
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty("帖子id")
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty("评论内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty("用户信息")
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ApiModelProperty(value = "是否精选评论 1 不是 2 是")
|
||||
private Integer isSelectedComment = 2;
|
||||
|
||||
public SelectedComment(Integer isSelectedComment,PostComment postComment,UserInfo userInfo) {
|
||||
this.id = postComment.getId();
|
||||
this.userInfo = userInfo;
|
||||
this.postId = postComment.getPostId();
|
||||
this.content = postComment.getContent();
|
||||
this.image = postComment.getImage();
|
||||
this.createTime = postComment.getCreateTime();
|
||||
this.isSelectedComment = isSelectedComment;
|
||||
}
|
||||
|
||||
public SelectedComment() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.ruoyi.post.frequency.posreport.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.post.frequency.posreport.entity.PostReport;
|
||||
import com.ruoyi.post.frequency.posreport.service.PostReportService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 论坛举报Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/posreport")
|
||||
public class PostReportController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private PostReportService postReportService;
|
||||
|
||||
/**
|
||||
* 查询论坛举报列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posreport:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo<PostReport> list(@RequestBody PostReport postReport)
|
||||
{
|
||||
startPage();
|
||||
List<PostReport> list = postReportService.selectPostReportList(postReport);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出论坛举报列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posreport:export')")
|
||||
@Log(title = "论坛举报", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(PostReport postReport)
|
||||
{
|
||||
List<PostReport> list = postReportService.selectPostReportList(postReport);
|
||||
ExcelUtil<PostReport> util = new ExcelUtil<PostReport>(PostReport.class);
|
||||
return util.exportExcel(list, "论坛举报数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取论坛举报详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posreport:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<PostReport> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(postReportService.selectPostReportById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增论坛举报
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posreport:add')")
|
||||
@Log(title = "论坛举报", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PostReport postReport)
|
||||
{
|
||||
return toAjax(postReportService.insertPostReport(postReport));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改论坛举报
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posreport:edit')")
|
||||
@Log(title = "论坛举报", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PostReport postReport)
|
||||
{
|
||||
return toAjax(postReportService.updatePostReport(postReport));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除论坛举报
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posreport:remove')")
|
||||
@Log(title = "论坛举报", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}/{delFlag}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids,@PathVariable Integer delFlag)
|
||||
{
|
||||
return toAjax(postReportService.deletePostReportByIds(ids,delFlag));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 举报处理
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posreport:handle')")
|
||||
@Log(title = "论坛举报", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/handle")
|
||||
public AjaxResult handle(@RequestBody PostReport postReport)
|
||||
{
|
||||
return postReportService.handle(postReport);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.ruoyi.post.frequency.posreport.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 论坛举报对象 t_post_report
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_post_report")
|
||||
public class PostReport extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("论坛id")
|
||||
@Excel(name = "论坛id")
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty("举报原因")
|
||||
@Excel(name = "举报原因")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty("内容")
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
@Excel(name = "图片")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理")
|
||||
@Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty("用户信息")
|
||||
@TableField(exist = false)
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ApiModelProperty("帖子信息")
|
||||
@TableField(exist = false)
|
||||
private Post post;
|
||||
|
||||
@ApiModelProperty("开始时间")
|
||||
@TableField(exist = false)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty("结束时间")
|
||||
@TableField(exist = false)
|
||||
private Date endTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.post.frequency.posreport.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.post.frequency.posreport.entity.PostReport;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 论坛举报Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
public interface PostReportMapper extends BaseMapper<PostReport>
|
||||
{
|
||||
/**
|
||||
* 查询论坛举报
|
||||
*
|
||||
* @param id 论坛举报主键
|
||||
* @return 论坛举报
|
||||
*/
|
||||
public PostReport selectPostReportById(Long id);
|
||||
|
||||
/**
|
||||
* 查询论坛举报列表
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 论坛举报集合
|
||||
*/
|
||||
public List<PostReport> selectPostReportList(PostReport postReport);
|
||||
|
||||
/**
|
||||
* 新增论坛举报
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostReport(PostReport postReport);
|
||||
|
||||
/**
|
||||
* 修改论坛举报
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostReport(PostReport postReport);
|
||||
|
||||
/**
|
||||
* 删除论坛举报
|
||||
*
|
||||
* @param id 论坛举报主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostReportById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除论坛举报
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostReportByIds(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
<?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.ruoyi.post.frequency.posreport.mapper.PostReportMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.post.frequency.posreport.entity.PostReport" id="PostReportResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="userType" column="user_type" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="postId" column="post_id" />
|
||||
<result property="reason" column="reason" />
|
||||
<result property="content" column="content" />
|
||||
<result property="images" column="images" />
|
||||
<result property="result" column="result" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPostReportVo">
|
||||
SELECT
|
||||
t.id,
|
||||
t.create_by,
|
||||
t.create_time,
|
||||
t.update_by,
|
||||
t.update_time,
|
||||
t.del_flag,
|
||||
t.user_type,
|
||||
t.user_id,
|
||||
t.post_id,
|
||||
t.reason,
|
||||
t.content,
|
||||
t.images,
|
||||
t.result,
|
||||
t.remark
|
||||
FROM
|
||||
t_post_report AS t
|
||||
LEFT JOIN t_store s on t.user_id = s.id and t.user_type = 2
|
||||
LEFT JOIN t_customer c on t.user_id = c.id and t.user_type = 1
|
||||
LEFT JOIN t_sale sa on t.user_id = sa.id and t.user_type = 3
|
||||
LEFT JOIN t_post p on t.post_id = p.id
|
||||
</sql>
|
||||
|
||||
<select id="selectPostReportList" parameterType="com.ruoyi.post.frequency.posreport.entity.PostReport" resultMap="PostReportResult">
|
||||
<include refid="selectPostReportVo"/>
|
||||
<where> and t.del_flag != 2
|
||||
<if test="userType != null "> and t.user_type = #{userType}</if>
|
||||
<if test="userId != null "> and t.user_id = #{userId}</if>
|
||||
<if test="postId != null "> and t.post_id = #{postId}</if>
|
||||
<if test="reason != null and reason != ''"> and t.reason = #{reason}</if>
|
||||
<if test="content != null and content != ''"> and t.content = #{content}</if>
|
||||
<if test="images != null and images != ''"> and t.images = #{images}</if>
|
||||
<if test="result != null "> and t.result = #{result}</if>
|
||||
<if test="post != null and post.title != null and post.title != '' ">
|
||||
and p.title like concat('%', #{post.title}, '%')
|
||||
</if>
|
||||
<if test="userInfo != null and userInfo.nickname != null and userInfo.nickname != '' ">
|
||||
and (
|
||||
s.nickname like concat('%', #{userInfo.nickname}, '%')
|
||||
or
|
||||
c.nickname like concat('%', #{userInfo.nickname}, '%')
|
||||
or
|
||||
sa.nickname like concat('%', #{userInfo.nickname}, '%')
|
||||
)
|
||||
|
||||
</if>
|
||||
<if test="userInfo != null and userInfo.mobile != null and userInfo.mobile != '' ">
|
||||
and (
|
||||
s.mobile like concat('%', #{userInfo.mobile}, '%')
|
||||
or
|
||||
c.mobile like concat('%', #{userInfo.mobile}, '%')
|
||||
or
|
||||
sa.mobile like concat('%', #{userInfo.mobile}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="beginTime != null ">
|
||||
and t.create_time >= #{beginTime}
|
||||
|
||||
</if>
|
||||
<if test="endTime != null ">
|
||||
and t.create_time < #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by t.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectPostReportById" parameterType="Long" resultMap="PostReportResult">
|
||||
<include refid="selectPostReportVo"/>
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPostReport" parameterType="com.ruoyi.post.frequency.posreport.entity.PostReport">
|
||||
insert into t_post_report
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="userType != null">user_type,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="postId != null">post_id,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="images != null">images,</if>
|
||||
<if test="result != null">result,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="userType != null">#{userType},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="postId != null">#{postId},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="images != null">#{images},</if>
|
||||
<if test="result != null">#{result},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePostReport" parameterType="com.ruoyi.post.frequency.posreport.entity.PostReport">
|
||||
update t_post_report
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="userType != null">user_type = #{userType},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="postId != null">post_id = #{postId},</if>
|
||||
<if test="reason != null">reason = #{reason},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="images != null">images = #{images},</if>
|
||||
<if test="result != null">result = #{result},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePostReportById" parameterType="Long">
|
||||
delete from t_post_report where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePostReportByIds" parameterType="String">
|
||||
delete from t_post_report where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.post.frequency.posreport.model.param;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 论坛举报对象 t_post_report
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostReportParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("论坛id")
|
||||
@Excel(name = "论坛id")
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty("举报原因")
|
||||
@Excel(name = "举报原因")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty("内容")
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
@Excel(name = "图片")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理")
|
||||
@Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理")
|
||||
private Integer result;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.ruoyi.post.frequency.posreport.model.result;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 论坛举报对象 t_post_report
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostReportResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("论坛id")
|
||||
@Excel(name = "论坛id")
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty("举报原因")
|
||||
@Excel(name = "举报原因")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty("内容")
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
@Excel(name = "图片")
|
||||
private String images;
|
||||
|
||||
@ApiModelProperty("处理结果 1 未处理 2 已处理 3拒绝处理")
|
||||
@Excel(name = "处理结果 1 未处理 2 已处理 3拒绝处理")
|
||||
private Integer result;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.ruoyi.post.frequency.posreport.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.post.controller.req.PostReportReq;
|
||||
import com.ruoyi.post.frequency.posreport.entity.PostReport;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 论坛举报Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
public interface PostReportService extends IService<PostReport>
|
||||
{
|
||||
/**
|
||||
* 查询论坛举报
|
||||
*
|
||||
* @param id 论坛举报主键
|
||||
* @return 论坛举报
|
||||
*/
|
||||
public PostReport selectPostReportById(Long id);
|
||||
|
||||
/**
|
||||
* 查询论坛举报列表
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 论坛举报集合
|
||||
*/
|
||||
public List<PostReport> selectPostReportList(PostReport postReport);
|
||||
|
||||
/**
|
||||
* 新增论坛举报
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostReport(PostReport postReport);
|
||||
|
||||
/**
|
||||
* 修改论坛举报
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostReport(PostReport postReport);
|
||||
|
||||
/**
|
||||
* 批量删除论坛举报
|
||||
*
|
||||
* @param ids 需要删除的论坛举报主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostReportByIds(Long[] ids,Integer delFlag);
|
||||
|
||||
/**
|
||||
* 删除论坛举报信息
|
||||
*
|
||||
* @param id 论坛举报主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostReportById(Long id);
|
||||
|
||||
/**
|
||||
* 举报处理
|
||||
* @param postReport
|
||||
* @return
|
||||
*/
|
||||
AjaxResult handle(PostReport postReport);
|
||||
|
||||
/**
|
||||
* 帖子举报
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
ResponseData postReport(PostReportReq req, UserVo userVo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package com.ruoyi.post.frequency.posreport.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.code.PublicCommon;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.enums.process.ProcessResultEnums;
|
||||
import com.ruoyi.frequency.customer.service.UserService;
|
||||
import com.ruoyi.post.controller.req.PostReportReq;
|
||||
import com.ruoyi.post.frequency.posreport.entity.PostReport;
|
||||
import com.ruoyi.post.frequency.posreport.mapper.PostReportMapper;
|
||||
import com.ruoyi.post.frequency.posreport.service.PostReportService;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.post.frequency.post.service.PostService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 论坛举报Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PostReportServiceImpl extends ServiceImpl<PostReportMapper, PostReport> implements PostReportService
|
||||
{
|
||||
@Autowired
|
||||
private PostReportMapper postReportMapper;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private PostService postService;
|
||||
|
||||
/**
|
||||
* 查询论坛举报
|
||||
*
|
||||
* @param id 论坛举报主键
|
||||
* @return 论坛举报
|
||||
*/
|
||||
@Override
|
||||
public PostReport selectPostReportById(Long id)
|
||||
{
|
||||
PostReport s = postReportMapper.selectPostReportById(id);
|
||||
if (s != null){
|
||||
Set<UserVo> userVoSet = new HashSet<>();
|
||||
userVoSet.add(new UserVo(s.getUserType(),s.getUserId()));
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet,null);
|
||||
|
||||
|
||||
//查询帖子信息
|
||||
Post post = postService.selectPostById(s.getPostId());
|
||||
s.setUserInfo(userMap.get(new UserVo(s.getUserType(),s.getUserId())));
|
||||
s.setPost(post);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询论坛举报列表
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 论坛举报
|
||||
*/
|
||||
@Override
|
||||
public List<PostReport> selectPostReportList(PostReport postReport)
|
||||
{
|
||||
List<PostReport> postReports = postReportMapper.selectPostReportList(postReport);
|
||||
|
||||
if (postReports != null && postReports.size() > 0){
|
||||
|
||||
Set<UserVo> userVoSet = postReports.stream().map(s -> new UserVo(s.getUserType(),s.getUserId())).collect(Collectors.toSet());
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet,null);
|
||||
|
||||
Set<Long> postIds = postReports.stream().map(PostReport::getPostId).collect(Collectors.toSet());
|
||||
|
||||
//查询帖子信息
|
||||
Map<Long, Post> postMap = postService.selectPostMap(postIds);
|
||||
|
||||
postReports.stream().forEach(s ->{
|
||||
s.setUserInfo(userMap.get(new UserVo(s.getUserType(),s.getUserId())));
|
||||
s.setPost(postMap.get(s.getPostId()));
|
||||
});
|
||||
}
|
||||
|
||||
return postReports;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增论坛举报
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPostReport(PostReport postReport)
|
||||
{
|
||||
postReport.setCreateTime(DateUtils.getNowDate());
|
||||
return postReportMapper.insertPostReport(postReport);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改论坛举报
|
||||
*
|
||||
* @param postReport 论坛举报
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePostReport(PostReport postReport)
|
||||
{
|
||||
postReport.setUpdateTime(DateUtils.getNowDate());
|
||||
return postReportMapper.updatePostReport(postReport);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除论坛举报
|
||||
*
|
||||
* @param ids 需要删除的论坛举报主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostReportByIds(Long[] ids,Integer delFlag)
|
||||
{
|
||||
this.lambdaUpdate().set(PostReport::getDelFlag,delFlag).in(PostReport::getId,ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除论坛举报信息
|
||||
*
|
||||
* @param id 论坛举报主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostReportById(Long id)
|
||||
{
|
||||
this.lambdaUpdate().set(PostReport::getDelFlag,PublicCommon.删除).eq(PostReport::getId,id).update();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult handle(PostReport postReport) {
|
||||
|
||||
boolean update = this.lambdaUpdate().set(PostReport::getResult, postReport.getResult())
|
||||
.eq(PostReport::getResult, ProcessResultEnums.PENDING.getCode())
|
||||
.eq(PostReport::getId, postReport.getId()).update();
|
||||
//处理(审核通过)
|
||||
if (update && ObjectUtil.equal(ProcessResultEnums.APPROVED.getCode(), postReport.getResult())) {
|
||||
// PostReport byId = this.getById(postReport.getId());
|
||||
// postService.lambdaUpdate().set(Post::getDelFlag,PublicCommon.禁用).eq(Post::getId,byId.getPostId()).update();
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData postReport(PostReportReq req, UserVo userVo) {
|
||||
PostReport postReport = new PostReport().setPostId(req.getPostId())
|
||||
.setUserType(userVo.getUserType())
|
||||
.setUserId(userVo.getUserId())
|
||||
.setReason(req.getReason())
|
||||
.setContent(req.getContent())
|
||||
.setImages(req.getImages());
|
||||
this.save(postReport);
|
||||
|
||||
return ResponseData.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.post.frequency.posshield.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.post.frequency.posshield.entity.PostShield;
|
||||
import com.ruoyi.post.frequency.posshield.service.PostShieldService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 论坛屏蔽Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/posshield")
|
||||
public class PostShieldController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private PostShieldService postShieldService;
|
||||
|
||||
/**
|
||||
* 查询论坛屏蔽列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posshield:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo<PostShield> list(@RequestBody PostShield postShield)
|
||||
{
|
||||
startPage();
|
||||
List<PostShield> list = postShieldService.selectPostShieldList(postShield);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出论坛屏蔽列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posshield:export')")
|
||||
@Log(title = "论坛屏蔽", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(PostShield postShield)
|
||||
{
|
||||
List<PostShield> list = postShieldService.selectPostShieldList(postShield);
|
||||
ExcelUtil<PostShield> util = new ExcelUtil<PostShield>(PostShield.class);
|
||||
return util.exportExcel(list, "论坛屏蔽数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取论坛屏蔽详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posshield:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<PostShield> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(postShieldService.selectPostShieldById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增论坛屏蔽
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posshield:add')")
|
||||
@Log(title = "论坛屏蔽", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PostShield postShield)
|
||||
{
|
||||
return toAjax(postShieldService.insertPostShield(postShield));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改论坛屏蔽
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posshield:edit')")
|
||||
@Log(title = "论坛屏蔽", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PostShield postShield)
|
||||
{
|
||||
return toAjax(postShieldService.updatePostShield(postShield));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除论坛屏蔽
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:posshield:remove')")
|
||||
@Log(title = "论坛屏蔽", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(postShieldService.deletePostShieldByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.ruoyi.post.frequency.posshield.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 论坛屏蔽对象 t_post_shield
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_post_shield")
|
||||
public class PostShield extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("论坛id")
|
||||
@Excel(name = "论坛id")
|
||||
private Long postId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.post.frequency.posshield.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.post.frequency.posshield.entity.PostShield;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 论坛屏蔽Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
public interface PostShieldMapper extends BaseMapper<PostShield>
|
||||
{
|
||||
/**
|
||||
* 查询论坛屏蔽
|
||||
*
|
||||
* @param id 论坛屏蔽主键
|
||||
* @return 论坛屏蔽
|
||||
*/
|
||||
public PostShield selectPostShieldById(Long id);
|
||||
|
||||
/**
|
||||
* 查询论坛屏蔽列表
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 论坛屏蔽集合
|
||||
*/
|
||||
public List<PostShield> selectPostShieldList(PostShield postShield);
|
||||
|
||||
/**
|
||||
* 新增论坛屏蔽
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostShield(PostShield postShield);
|
||||
|
||||
/**
|
||||
* 修改论坛屏蔽
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostShield(PostShield postShield);
|
||||
|
||||
/**
|
||||
* 删除论坛屏蔽
|
||||
*
|
||||
* @param id 论坛屏蔽主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostShieldById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除论坛屏蔽
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostShieldByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 帖子屏蔽
|
||||
* @param postShield
|
||||
* @param userVo
|
||||
*/
|
||||
int postShield(@Param("req") PostShield postShield,@Param("userVo") UserVo userVo);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?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.ruoyi.post.frequency.posshield.mapper.PostShieldMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.post.frequency.posshield.entity.PostShield" id="PostShieldResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="userType" column="user_type" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="postId" column="post_id" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPostShieldVo">
|
||||
select id, del_flag, create_by, create_time, update_by, update_time, user_type, user_id, post_id, remark from t_post_shield
|
||||
</sql>
|
||||
|
||||
<select id="selectPostShieldList" parameterType="com.ruoyi.post.frequency.posshield.entity.PostShield" resultMap="PostShieldResult">
|
||||
<include refid="selectPostShieldVo"/>
|
||||
<where>
|
||||
<if test="userType != null "> and user_type = #{userType}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="postId != null "> and post_id = #{postId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPostShieldById" parameterType="Long" resultMap="PostShieldResult">
|
||||
<include refid="selectPostShieldVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPostShield" parameterType="com.ruoyi.post.frequency.posshield.entity.PostShield">
|
||||
insert into t_post_shield
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="userType != null">user_type,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="postId != null">post_id,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="userType != null">#{userType},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="postId != null">#{postId},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePostShield" parameterType="com.ruoyi.post.frequency.posshield.entity.PostShield">
|
||||
update t_post_shield
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="userType != null">user_type = #{userType},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="postId != null">post_id = #{postId},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePostShieldById" parameterType="Long">
|
||||
delete from t_post_shield where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePostShieldByIds" parameterType="String">
|
||||
delete from t_post_shield where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="postShield" parameterType="com.ruoyi.post.frequency.posshield.entity.PostShield">
|
||||
insert into t_post_shield
|
||||
(id, create_by, create_time, update_by, update_time, user_type, user_id, post_id)
|
||||
values
|
||||
(#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{userVo.userType}, #{userVo.userId}, #{req.postId})
|
||||
ON DUPLICATE KEY UPDATE
|
||||
del_flag = IF( del_flag = 1, 3, 1 ),
|
||||
update_time = #{req.updateTime},
|
||||
update_by = #{req.updateBy};
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.ruoyi.post.frequency.posshield.model.param;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 论坛屏蔽对象 t_post_shield
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostShieldParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("论坛id")
|
||||
@Excel(name = "论坛id")
|
||||
private Long postId;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.ruoyi.post.frequency.posshield.model.result;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 论坛屏蔽对象 t_post_shield
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostShieldResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("论坛id")
|
||||
@Excel(name = "论坛id")
|
||||
private Long postId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.ruoyi.post.frequency.posshield.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.post.frequency.posshield.entity.PostShield;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 论坛屏蔽Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
public interface PostShieldService extends IService<PostShield>
|
||||
{
|
||||
/**
|
||||
* 查询论坛屏蔽
|
||||
*
|
||||
* @param id 论坛屏蔽主键
|
||||
* @return 论坛屏蔽
|
||||
*/
|
||||
public PostShield selectPostShieldById(Long id);
|
||||
|
||||
/**
|
||||
* 查询论坛屏蔽列表
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 论坛屏蔽集合
|
||||
*/
|
||||
public List<PostShield> selectPostShieldList(PostShield postShield);
|
||||
|
||||
/**
|
||||
* 新增论坛屏蔽
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostShield(PostShield postShield);
|
||||
|
||||
/**
|
||||
* 修改论坛屏蔽
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostShield(PostShield postShield);
|
||||
|
||||
/**
|
||||
* 批量删除论坛屏蔽
|
||||
*
|
||||
* @param ids 需要删除的论坛屏蔽主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostShieldByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除论坛屏蔽信息
|
||||
*
|
||||
* @param id 论坛屏蔽主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostShieldById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子屏蔽
|
||||
* @param id
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
ResponseData postShield(Long postId, UserVo userVo);
|
||||
|
||||
|
||||
/**
|
||||
* 用户屏蔽的帖子ids
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
List<Long> shieldPostList(UserVo userVo);
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.ruoyi.post.frequency.posshield.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.code.PublicCommon;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.post.frequency.posshield.entity.PostShield;
|
||||
import com.ruoyi.post.frequency.posshield.mapper.PostShieldMapper;
|
||||
import com.ruoyi.post.frequency.posshield.service.PostShieldService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.utils.SnowIdUtils;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 论坛屏蔽Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-26
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PostShieldServiceImpl extends ServiceImpl<PostShieldMapper, PostShield> implements PostShieldService
|
||||
{
|
||||
@Autowired
|
||||
private PostShieldMapper postShieldMapper;
|
||||
|
||||
/**
|
||||
* 查询论坛屏蔽
|
||||
*
|
||||
* @param id 论坛屏蔽主键
|
||||
* @return 论坛屏蔽
|
||||
*/
|
||||
@Override
|
||||
public PostShield selectPostShieldById(Long id)
|
||||
{
|
||||
return postShieldMapper.selectPostShieldById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询论坛屏蔽列表
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 论坛屏蔽
|
||||
*/
|
||||
@Override
|
||||
public List<PostShield> selectPostShieldList(PostShield postShield)
|
||||
{
|
||||
return postShieldMapper.selectPostShieldList(postShield);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增论坛屏蔽
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPostShield(PostShield postShield)
|
||||
{
|
||||
postShield.setCreateTime(DateUtils.getNowDate());
|
||||
return postShieldMapper.insertPostShield(postShield);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改论坛屏蔽
|
||||
*
|
||||
* @param postShield 论坛屏蔽
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePostShield(PostShield postShield)
|
||||
{
|
||||
postShield.setUpdateTime(DateUtils.getNowDate());
|
||||
return postShieldMapper.updatePostShield(postShield);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除论坛屏蔽
|
||||
*
|
||||
* @param ids 需要删除的论坛屏蔽主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostShieldByIds(Long[] ids)
|
||||
{
|
||||
this.lambdaUpdate().set(PostShield::getDelFlag,PublicCommon.删除).in(PostShield::getId,ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除论坛屏蔽信息
|
||||
*
|
||||
* @param id 论坛屏蔽主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostShieldById(Long id)
|
||||
{
|
||||
this.lambdaUpdate().set(PostShield::getDelFlag,PublicCommon.删除).eq(PostShield::getId,id).update();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData postShield(Long postId, UserVo userVo) {
|
||||
|
||||
PostShield postShield = new PostShield()
|
||||
.setId(SnowIdUtils.uniqueLong())
|
||||
.setPostId(postId)
|
||||
.setUserType(userVo.getUserType())
|
||||
.setUserId(userVo.getUserId());
|
||||
|
||||
postShield.setUpdateData();
|
||||
|
||||
//帖子屏蔽
|
||||
postShieldMapper.postShield(postShield,userVo);
|
||||
|
||||
return ResponseData.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> shieldPostList(UserVo userVo) {
|
||||
|
||||
//查询屏蔽帖子记录
|
||||
List<PostShield> list = this.list(new QueryWrapper<PostShield>().lambda()
|
||||
.eq(PostShield::getDelFlag, PublicCommon.启用)
|
||||
.eq(PostShield::getUserType, userVo.getUserType())
|
||||
.eq(PostShield::getUserId, userVo.getUserId()));
|
||||
|
||||
return list.stream().map(PostShield::getPostId).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.ruoyi.post.frequency.post.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.post.frequency.post.model.result.PostCount;
|
||||
import com.ruoyi.post.frequency.post.service.PostService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/post")
|
||||
public class PostController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private PostService postService;
|
||||
|
||||
/**
|
||||
* 查询帖子列表
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:post:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo<Post> list(@RequestBody Post post)
|
||||
{
|
||||
startPage();
|
||||
List<Post> list = postService.selectPostList(post);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计
|
||||
*/
|
||||
@PostMapping("/statistics")
|
||||
public AjaxResult statistics(@RequestBody Post post)
|
||||
{
|
||||
PostCount count = postService.statistics(post);
|
||||
return AjaxResult.success(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出帖子列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:post:export')")
|
||||
@Log(title = "帖子", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(Post post)
|
||||
{
|
||||
List<Post> list = postService.selectPostList(post);
|
||||
ExcelUtil<Post> util = new ExcelUtil<Post>(Post.class);
|
||||
return util.exportExcel(list, "帖子数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帖子详细信息
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:post:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<Post> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(postService.selectPostById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增帖子
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:post:add')")
|
||||
@Log(title = "帖子", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Post post)
|
||||
{
|
||||
return toAjax(postService.insertPost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:post:edit')")
|
||||
@Log(title = "帖子", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Post post)
|
||||
{
|
||||
return toAjax(postService.updatePost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帖子
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:post:remove')")
|
||||
@Log(title = "帖子", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(postService.deletePostByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 帖子置顶/取消置顶
|
||||
*/
|
||||
@PostMapping("/topping/{id}")
|
||||
public AjaxResult topping(@PathVariable Long id)
|
||||
{
|
||||
return postService.topping(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.ruoyi.post.frequency.post.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.post.controller.req.PostReleaseReq;
|
||||
import com.ruoyi.post.controller.vo.SelectedComment;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 帖子对象 t_post
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_post")
|
||||
public class Post extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标识 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("帖子分类id")
|
||||
@Excel(name = "帖子分类id")
|
||||
private Long postTypeId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("标题")
|
||||
@Excel(name = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("文字描述(富文本)")
|
||||
@Excel(name = "文字描述(富文本)")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("封面图")
|
||||
@Excel(name = "封面图")
|
||||
private String coverImage;
|
||||
|
||||
@ApiModelProperty("视频路径(一个)")
|
||||
@Excel(name = "视频路径", readConverterExp = "一=个")
|
||||
private String videoUrl;
|
||||
|
||||
@ApiModelProperty("分享数")
|
||||
@Excel(name = "分享数")
|
||||
private Integer shareNum;
|
||||
|
||||
@ApiModelProperty("点赞数")
|
||||
@Excel(name = "点赞数")
|
||||
private Integer likeNum;
|
||||
|
||||
@ApiModelProperty("评论数")
|
||||
@Excel(name = "评论数")
|
||||
private Integer commentNum;
|
||||
|
||||
@ApiModelProperty("收藏数")
|
||||
@Excel(name = "收藏数")
|
||||
private Integer collectNum;
|
||||
|
||||
@ApiModelProperty("浏览数")
|
||||
@Excel(name = "浏览数")
|
||||
private Integer browseNum;
|
||||
|
||||
@ApiModelProperty("状态 1 待审核 2 通过 3 拒绝")
|
||||
@Excel(name = "状态 1 待审核 2 通过 3 拒绝")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty("拒绝原因")
|
||||
@Excel(name = "拒绝原因")
|
||||
private String reason;
|
||||
|
||||
|
||||
@Excel(name = "地址")
|
||||
@ApiModelProperty("地址")
|
||||
private String address;
|
||||
|
||||
|
||||
@ApiModelProperty("精彩评论id")
|
||||
private Long commentId;
|
||||
|
||||
@ApiModelProperty("帖子类型 1 帖子 2资讯")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("描述")
|
||||
private String describes;
|
||||
|
||||
@ApiModelProperty("热度时间")
|
||||
private Date trendsTime;
|
||||
|
||||
@ApiModelProperty("帖子分类名称")
|
||||
@Excel(name = "帖子分类名称")
|
||||
@TableField(exist = false)
|
||||
private String postTypeName;
|
||||
|
||||
@ApiModelProperty("用户信息")
|
||||
@TableField(exist = false)
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ApiModelProperty("精选评论")
|
||||
@TableField(exist = false)
|
||||
private SelectedComment selectedComment;
|
||||
|
||||
@ApiModelProperty("是否推荐 1否 2是")
|
||||
@TableField(exist = false)
|
||||
private Integer isRecommend;
|
||||
|
||||
@ApiModelProperty("开始时间")
|
||||
@TableField(exist = false)
|
||||
private Date beginTime;
|
||||
|
||||
@ApiModelProperty("结束时间")
|
||||
@TableField(exist = false)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty("企业id")
|
||||
@TableField(exist = false)
|
||||
private Long enterpriseId;
|
||||
|
||||
public Post() {
|
||||
}
|
||||
|
||||
public Post(PostReleaseReq req, UserVo userVo) {
|
||||
this.userId = userVo.getUserId();
|
||||
this.userType = userVo.getUserType();
|
||||
this.title = req.getTitle();
|
||||
this.content = req.getContent();
|
||||
this.coverImage = req.getCoverImage();
|
||||
this.videoUrl = req.getVideoUrl();
|
||||
this.postTypeId = req.getPostTypeId();
|
||||
this.address = req.getAddress();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.ruoyi.post.frequency.post.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.post.controller.req.PostPageReq;
|
||||
import com.ruoyi.post.controller.resp.PostDetailResp;
|
||||
import com.ruoyi.post.controller.resp.PostPageResp;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.post.frequency.post.model.result.PostCount;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
public interface PostMapper extends BaseMapper<Post>
|
||||
{
|
||||
/**
|
||||
* 查询帖子
|
||||
*
|
||||
* @param id 帖子主键
|
||||
* @return 帖子
|
||||
*/
|
||||
public Post selectPostById(Long id);
|
||||
|
||||
/**
|
||||
* 查询帖子列表
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 帖子集合
|
||||
*/
|
||||
public List<Post> selectPostList(Post post);
|
||||
|
||||
/**
|
||||
* 新增帖子
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPost(Post post);
|
||||
|
||||
/**
|
||||
* 修改帖子
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePost(Post post);
|
||||
|
||||
/**
|
||||
* 删除帖子
|
||||
*
|
||||
* @param id 帖子主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除帖子
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostByIds(Long[] ids);
|
||||
|
||||
|
||||
/**
|
||||
* 修改帖子统计数量
|
||||
* @param id 帖子id
|
||||
* @param type 数量类型
|
||||
* @param num 数量
|
||||
*/
|
||||
void updateNumPost(@Param("id") Long id, @Param("type") Integer type, @Param("num") int num);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子列表
|
||||
* @param objectPage
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
Page<PostPageResp> postPage(@Param("page")Page<Object> objectPage,@Param("req") PostPageReq req,@Param("userVo") UserVo userVo);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子详情
|
||||
* @param id
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
PostDetailResp postDetail(@Param("id") Long id, @Param("userVo") UserVo userVo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @param type type: 类型 1作品 2 帖子 3投票 4新闻 5活动
|
||||
* @param updateTime
|
||||
* @param objectId
|
||||
* @param userVo
|
||||
*/
|
||||
void updateBrowseRecord(@Param("id") Long id, @Param("type") int type, @Param("updateTime") Date updateTime,@Param("objectId") Long objectId, @Param("userVo") UserVo userVo);
|
||||
|
||||
PostCount statistics(@Param("list") List<Long> postIdList);
|
||||
|
||||
@Update("update t_post set like_num = like_num + #{num} , update_time=now() where id = #{id} and like_num + #{num} >= 0")
|
||||
int updatePostLikeNum(@Param("id")Long id, @Param("num")Integer num);
|
||||
}
|
||||
@@ -0,0 +1,530 @@
|
||||
<?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.ruoyi.post.frequency.post.mapper.PostMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.post.frequency.post.entity.Post" id="PostResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="postTypeId" column="post_type_id" />
|
||||
<result property="userType" column="user_type" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="content" column="content" />
|
||||
<result property="coverImage" column="cover_image" />
|
||||
<result property="videoUrl" column="video_url" />
|
||||
<result property="shareNum" column="share_num" />
|
||||
<result property="likeNum" column="like_num" />
|
||||
<result property="commentNum" column="comment_num" />
|
||||
<result property="collectNum" column="collect_num" />
|
||||
<result property="browseNum" column="browse_num" />
|
||||
<result property="result" column="result" />
|
||||
<result property="reason" column="reason" />
|
||||
<result property="isRecommend" column="isRecommend" />
|
||||
<result property="postTypeName" column="postTypeName" />
|
||||
<result property="describes" column="describes" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPostVo">
|
||||
SELECT
|
||||
t.id,
|
||||
t.del_flag,
|
||||
t.create_by,
|
||||
t.create_time,
|
||||
t.update_by,
|
||||
t.update_time,
|
||||
t.post_type_id,
|
||||
t.user_type,
|
||||
t.user_id,
|
||||
t.title,
|
||||
t.content,
|
||||
t.cover_image,
|
||||
t.video_url,
|
||||
t.share_num,
|
||||
t.like_num,
|
||||
t.comment_num,
|
||||
t.collect_num,
|
||||
t.browse_num,
|
||||
t.answer_num,
|
||||
t.result,
|
||||
t.reason,
|
||||
t.address,
|
||||
t2.`name` postTypeName,
|
||||
case when r.id is null then 1 else 2 end isRecommend,
|
||||
r.sort,
|
||||
t.describes
|
||||
FROM
|
||||
t_post AS t
|
||||
LEFT JOIN t_post_type AS t2 ON t.post_type_id = t2.id
|
||||
left join t_customer c on c.id = t.user_id and t.user_type = 1
|
||||
left join t_store s on s.id = t.user_id and t.user_type = 2
|
||||
left join t_recommend r on r.object_id = t.id and r.type = 2 and r.del_flag = 1
|
||||
left join t_enterprise e on e.id = t.user_id and t.user_type = 4
|
||||
left join t_store s2 on s2.bind_enterprise_id = e.id and t.user_type = 4
|
||||
</sql>
|
||||
|
||||
<select id="selectPostList" parameterType="com.ruoyi.post.frequency.post.entity.Post" resultMap="PostResult">
|
||||
SELECT * from ( <include refid="selectPostVo"/>
|
||||
<where>
|
||||
and t.del_flag != 2
|
||||
<if test="postTypeId != null ">and t.post_type_id = #{postTypeId}</if>
|
||||
<if test="type != null ">and t.type = #{type}</if>
|
||||
<if test="userType != null ">and t.user_type = #{userType}</if>
|
||||
<if test="userId != null "> and t.user_id = #{userId}</if>
|
||||
<if test="title != null and title != ''"> and t.title like concat('%',#{title},'%')</if>
|
||||
<if test="content != null and content != ''"> and t.content = #{content}</if>
|
||||
<if test="coverImage != null and coverImage != ''"> and t.cover_image = #{coverImage}</if>
|
||||
<if test="videoUrl != null and videoUrl != ''"> and t.video_url = #{videoUrl}</if>
|
||||
<if test="shareNum != null "> and t.share_num = #{shareNum}</if>
|
||||
<if test="likeNum != null "> and t.like_num = #{likeNum}</if>
|
||||
<if test="commentNum != null "> and t.comment_num = #{commentNum}</if>
|
||||
<if test="collectNum != null "> and t.collect_num = #{collectNum}</if>
|
||||
<if test="browseNum != null ">and t.browse_num = #{browseNum}</if>
|
||||
<if test="result != null ">and t.result = #{result}</if>
|
||||
<if test="reason != null and reason != ''">and t.reason = #{reason}</if>
|
||||
<if test="userInfo != null and userInfo.nickname!=null and userInfo.nickname!=''">
|
||||
AND (
|
||||
s.nickname LIKE CONCAT('%',#{userInfo.nickname},'%')
|
||||
or
|
||||
c.nickname LIKE CONCAT('%',#{userInfo.nickname},'%')
|
||||
or
|
||||
e.name LIKE CONCAT('%',#{userInfo.nickname},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="userInfo != null and userInfo.mobile!=null and userInfo.mobile!=''">
|
||||
AND (
|
||||
s.mobile LIKE CONCAT('%',#{userInfo.mobile},'%')
|
||||
or
|
||||
c.mobile LIKE CONCAT('%',#{userInfo.mobile},'%')
|
||||
or
|
||||
s2.mobile LIKE CONCAT('%',#{userInfo.mobile},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="beginTime != null ">
|
||||
and t.create_time >= #{beginTime}
|
||||
|
||||
</if>
|
||||
<if test="endTime != null ">
|
||||
and t.create_time < #{endTime}
|
||||
</if>
|
||||
|
||||
<if test="enterpriseId != null and enterpriseId != ''">and e.id = #{enterpriseId}</if>
|
||||
</where>
|
||||
)tt
|
||||
order by tt.isRecommend desc, tt.sort,tt.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectPostById" parameterType="Long" resultMap="PostResult">
|
||||
<include refid="selectPostVo"/>
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPost" parameterType="com.ruoyi.post.frequency.post.entity.Post">
|
||||
insert into t_post
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="postTypeId != null">post_type_id,</if>
|
||||
<if test="userType != null">user_type,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="title != null">title,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="coverImage != null">cover_image,</if>
|
||||
<if test="videoUrl != null">video_url,</if>
|
||||
<if test="shareNum != null">share_num,</if>
|
||||
<if test="likeNum != null">like_num,</if>
|
||||
<if test="commentNum != null">comment_num,</if>
|
||||
<if test="collectNum != null">collect_num,</if>
|
||||
<if test="browseNum != null">browse_num,</if>
|
||||
<if test="result != null">result,</if>
|
||||
<if test="reason != null">reason,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="postTypeId != null">#{postTypeId},</if>
|
||||
<if test="userType != null">#{userType},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="title != null">#{title},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="coverImage != null">#{coverImage},</if>
|
||||
<if test="videoUrl != null">#{videoUrl},</if>
|
||||
<if test="shareNum != null">#{shareNum},</if>
|
||||
<if test="likeNum != null">#{likeNum},</if>
|
||||
<if test="commentNum != null">#{commentNum},</if>
|
||||
<if test="collectNum != null">#{collectNum},</if>
|
||||
<if test="browseNum != null">#{browseNum},</if>
|
||||
<if test="result != null">#{result},</if>
|
||||
<if test="reason != null">#{reason},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePost" parameterType="com.ruoyi.post.frequency.post.entity.Post">
|
||||
update t_post
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="postTypeId != null">post_type_id = #{postTypeId},</if>
|
||||
<if test="userType != null">user_type = #{userType},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="title != null">title = #{title},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="coverImage != null">cover_image = #{coverImage},</if>
|
||||
<if test="videoUrl != null">video_url = #{videoUrl},</if>
|
||||
<if test="shareNum != null">share_num = share_num + #{shareNum},</if>
|
||||
<if test="likeNum != null">like_num = like_num + #{likeNum},</if>
|
||||
<if test="commentNum != null">comment_num = comment_num + #{commentNum},</if>
|
||||
<if test="collectNum != null">collect_num = collect_num + #{collectNum},</if>
|
||||
<if test="browseNum != null">browse_num = browse_num + #{browseNum},</if>
|
||||
<if test="result != null">result = #{result},</if>
|
||||
<if test="reason != null">reason = #{reason},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePostById" parameterType="Long">
|
||||
delete from t_post where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePostByIds" parameterType="String">
|
||||
delete from t_post where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateNumPost">
|
||||
UPDATE t_post
|
||||
<if test="type == 1">
|
||||
SET share_num = share_num + #{num}
|
||||
</if>
|
||||
<if test="type == 2">
|
||||
SET like_num = like_num + #{num}
|
||||
</if>
|
||||
<if test="type == 3">
|
||||
SET comment_num = comment_num + #{num}
|
||||
</if>
|
||||
<if test="type == 4">
|
||||
SET collect_num = collect_num + #{num}
|
||||
</if>
|
||||
<if test="type == 5">
|
||||
SET browse_num = browse_num + #{num}
|
||||
</if>
|
||||
WHERE
|
||||
id = #{id}
|
||||
<if test="type == 1">
|
||||
AND (share_num + #{num}) >= 0
|
||||
</if>
|
||||
<if test="type == 2">
|
||||
AND (like_num + #{num}) >= 0
|
||||
</if>
|
||||
<if test="type == 3">
|
||||
AND (comment_num + #{num}) >= 0
|
||||
</if>
|
||||
<if test="type == 4">
|
||||
AND (collect_num + #{num}) >= 0
|
||||
</if>
|
||||
<if test="type == 5">
|
||||
AND (browse_num + #{num}) >= 0
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<select id="postPage" resultType="com.ruoyi.post.controller.resp.PostPageResp">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
t.id,
|
||||
1 type,
|
||||
t.create_time,
|
||||
t.trends_time,
|
||||
t.user_id,
|
||||
t.user_type,
|
||||
t.title,
|
||||
t.content,
|
||||
t.cover_image,
|
||||
t.video_url,
|
||||
t.share_num,
|
||||
t.like_num,
|
||||
t.comment_num,
|
||||
t.collect_num,
|
||||
t.browse_num,
|
||||
NULL isBuy,
|
||||
NULL price,
|
||||
CASE
|
||||
WHEN (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_post_like fl
|
||||
WHERE
|
||||
fl.del_flag = 1
|
||||
AND fl.type = 1
|
||||
AND fl.user_id = #{userVo.userId}
|
||||
AND fl.user_type = #{userVo.userType}
|
||||
AND fl.object_id = t.id
|
||||
) = 0 THEN
|
||||
1 ELSE 2
|
||||
END isLike,
|
||||
|
||||
CASE
|
||||
WHEN (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_collect c
|
||||
WHERE
|
||||
c.del_flag = 1
|
||||
AND c.type = 2
|
||||
AND c.user_id = #{userVo.userId}
|
||||
AND c.user_type = #{userVo.userType}
|
||||
AND c.object_id = t.id
|
||||
) = 0 THEN
|
||||
1 ELSE 2
|
||||
END isCollect,
|
||||
|
||||
CASE
|
||||
WHEN #{userVo.userType} = t.user_type
|
||||
AND #{userVo.userId} = t.user_id THEN
|
||||
2 ELSE 1
|
||||
END isSelf,
|
||||
t.result,
|
||||
t.address,
|
||||
case when r.id is null then 1 else 2 end isRecommend,
|
||||
r.sort,
|
||||
t.comment_id,
|
||||
t.describes
|
||||
FROM
|
||||
t_post t
|
||||
left join t_customer c on c.id = t.user_id and t.user_type = 1
|
||||
left join t_store s on s.id = t.user_id and t.user_type = 2
|
||||
left join t_recommend r on r.object_id = t.id and r.type = 2 and r.del_flag = 1
|
||||
WHERE
|
||||
t.del_flag = 1
|
||||
AND t.result = 2
|
||||
<if test="req.keyword!=null and req.keyword!=''">
|
||||
AND (
|
||||
t.content LIKE CONCAT('%',#{req.keyword},'%')
|
||||
or
|
||||
s.nickname LIKE CONCAT('%',#{req.keyword},'%')
|
||||
or
|
||||
c.nickname LIKE CONCAT('%',#{req.keyword},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="req.postTypeId!=null and req.postTypeId!=''">
|
||||
AND t.post_type_id = #{req.postTypeId}
|
||||
</if>
|
||||
<if test="req.type!=null and req.type!=''">
|
||||
<if test="req.type == 1">
|
||||
and (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_follow f
|
||||
WHERE
|
||||
f.del_flag = 1
|
||||
AND f.user_id = #{userVo.userId}
|
||||
AND f.user_type = #{userVo.userType}
|
||||
AND f.follower_user_id = t.user_id
|
||||
AND f.follower_user_type = t.user_type
|
||||
) > 0
|
||||
</if>
|
||||
</if>
|
||||
|
||||
<if test="req.blockUserList!=null and req.blockUserList.size() > 0">
|
||||
AND (
|
||||
(t.user_type = 1 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 1,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 2 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 2,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 4 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 4,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="req.shieldUserList!=null and req.shieldUserList.size() > 0">
|
||||
AND (
|
||||
(t.user_type = 1 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 1,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 2 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 2,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 4 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 4,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
)
|
||||
</if>
|
||||
|
||||
<if test="req.shieldPostIdList!=null and req.shieldPostIdList.size() > 0">
|
||||
AND t.id not in
|
||||
<foreach collection="req.shieldPostIdList" item="i" open="(" close=")" separator=",">
|
||||
#{i}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="req.userId!=null and req.userId != ''">
|
||||
AND t.user_id = #{req.userId}
|
||||
</if>
|
||||
|
||||
<choose>
|
||||
<when test="req.postType!=null and req.postType != ''">
|
||||
AND t.type = #{req.postType}
|
||||
</when>
|
||||
<otherwise>
|
||||
AND t.type = 1
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
<if test="req.userType!=null and req.userType != ''">
|
||||
AND t.user_type = #{req.userType}
|
||||
</if>
|
||||
) tt
|
||||
<if test="req.orderSort==null or req.orderSort==''">
|
||||
order by tt.isRecommend desc, tt.sort,tt.trends_time desc
|
||||
</if>
|
||||
<if test="req.orderSort!=null and req.orderSort!=''">
|
||||
order by
|
||||
<if test="req.orderSort==1">
|
||||
tt.create_time desc
|
||||
</if>
|
||||
<if test="req.orderSort==2">
|
||||
tt.like_num desc
|
||||
</if>
|
||||
<if test="req.orderSort==3">
|
||||
tt.comment_num desc
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="postDetail" resultType="com.ruoyi.post.controller.resp.PostDetailResp">
|
||||
SELECT
|
||||
t.id,
|
||||
t.create_time,
|
||||
t.user_type,
|
||||
t.user_id,
|
||||
t.title,
|
||||
t.content,
|
||||
t.cover_image,
|
||||
t.video_url,
|
||||
t.share_num,
|
||||
t.like_num,
|
||||
t.comment_num,
|
||||
t.collect_num,
|
||||
t.browse_num,
|
||||
t.result,
|
||||
t.reason,
|
||||
t.address,
|
||||
CASE
|
||||
|
||||
WHEN (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_post_like fl
|
||||
WHERE
|
||||
fl.del_flag = 1
|
||||
AND fl.type = 1
|
||||
AND fl.user_id = #{userVo.userId}
|
||||
AND fl.user_type = #{userVo.userType}
|
||||
AND fl.object_id = t.id
|
||||
) = 0 THEN
|
||||
1 ELSE 2
|
||||
END isLike,
|
||||
CASE
|
||||
|
||||
WHEN (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_collect c
|
||||
WHERE
|
||||
c.del_flag = 1
|
||||
AND c.type = 2
|
||||
AND c.user_id = #{userVo.userId}
|
||||
AND c.user_type = #{userVo.userType}
|
||||
AND c.object_id = t.id
|
||||
) = 0 THEN
|
||||
1 ELSE 2
|
||||
END isCollect,
|
||||
CASE
|
||||
WHEN #{userVo.userType} = t.user_type
|
||||
AND #{userVo.userId} = t.user_id THEN
|
||||
2 ELSE 1
|
||||
END isSelf,
|
||||
t2.name postTypeName,
|
||||
t.describes
|
||||
FROM
|
||||
t_post t
|
||||
left JOIN t_post_type t2 ON t2.id = t.post_type_id
|
||||
WHERE
|
||||
t.id = #{id}
|
||||
AND t.del_flag = 1
|
||||
</select>
|
||||
|
||||
<update id="updateBrowseRecord">
|
||||
insert into t_browse_record
|
||||
(id, create_time, update_time, type, user_type, user_id, object_id)
|
||||
values
|
||||
(#{id},#{updateTime},#{updateTime},#{type},#{userVo.userType}, #{userVo.userId}, #{objectId})
|
||||
ON DUPLICATE KEY UPDATE
|
||||
update_time = #{updateTime};
|
||||
</update>
|
||||
|
||||
<select id="statistics" parameterType="com.ruoyi.post.frequency.post.entity.Post" resultType="com.ruoyi.post.frequency.post.model.result.PostCount">
|
||||
SELECT
|
||||
COUNT(1) num,
|
||||
COUNT(
|
||||
DISTINCT t.user_id,
|
||||
t.user_type
|
||||
) number,
|
||||
COUNT(DISTINCT c.id) customerNum,
|
||||
COUNT(DISTINCT s.id) storeNum,
|
||||
ifnull(sum(t.like_num), 0) likeNum,
|
||||
ifnull(sum(t.comment_num), 0) commentNum,
|
||||
ifnull(sum(t.collect_num), 0) collectNum,
|
||||
ifnull(sum(t.browse_num), 0) browseNum
|
||||
FROM
|
||||
t_post AS t
|
||||
LEFT JOIN t_customer c ON c.id = t.user_id
|
||||
AND t.user_type = 1
|
||||
LEFT JOIN t_store s ON s.id = t.user_id
|
||||
AND t.user_type = 2
|
||||
where
|
||||
t.id in
|
||||
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.ruoyi.post.frequency.post.model.param;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子对象 t_post
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标识 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("帖子分类id")
|
||||
@Excel(name = "帖子分类id")
|
||||
private Long postTypeId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("标题")
|
||||
@Excel(name = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("文字描述(富文本)")
|
||||
@Excel(name = "文字描述(富文本)")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("封面图")
|
||||
@Excel(name = "封面图")
|
||||
private String coverImage;
|
||||
|
||||
@ApiModelProperty("视频路径(一个)")
|
||||
@Excel(name = "视频路径", readConverterExp = "一=个")
|
||||
private String videoUrl;
|
||||
|
||||
@ApiModelProperty("分享数")
|
||||
@Excel(name = "分享数")
|
||||
private Long shareNum;
|
||||
|
||||
@ApiModelProperty("点赞数")
|
||||
@Excel(name = "点赞数")
|
||||
private Long likeNum;
|
||||
|
||||
@ApiModelProperty("评论数")
|
||||
@Excel(name = "评论数")
|
||||
private Long commentNum;
|
||||
|
||||
@ApiModelProperty("收藏数")
|
||||
@Excel(name = "收藏数")
|
||||
private Long collectNum;
|
||||
|
||||
@ApiModelProperty("浏览数")
|
||||
@Excel(name = "浏览数")
|
||||
private Long browseNum;
|
||||
|
||||
@ApiModelProperty("状态 1 待审核 2 通过 3 拒绝")
|
||||
@Excel(name = "状态 1 待审核 2 通过 3 拒绝")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty("拒绝原因")
|
||||
@Excel(name = "拒绝原因")
|
||||
private String reason;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.post.frequency.post.model.result;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author a
|
||||
* @date 2024/2/19 10:18
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class PostCount {
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty("人数")
|
||||
private Integer number;
|
||||
|
||||
@ApiModelProperty("设计师数量")
|
||||
private Integer customerNum;
|
||||
|
||||
@ApiModelProperty("表现师数量")
|
||||
private Integer storeNum;
|
||||
|
||||
@ApiModelProperty("浏览量")
|
||||
private Integer browseNum;
|
||||
|
||||
@ApiModelProperty("点赞量")
|
||||
private Integer likeNum;
|
||||
|
||||
@ApiModelProperty("评论量")
|
||||
private Integer commentNum;
|
||||
|
||||
@ApiModelProperty("收藏量")
|
||||
private Integer collectNum;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.ruoyi.post.frequency.post.model.result;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子对象 t_post
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标识 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("帖子分类id")
|
||||
@Excel(name = "帖子分类id")
|
||||
private Long postTypeId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("标题")
|
||||
@Excel(name = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty("文字描述(富文本)")
|
||||
@Excel(name = "文字描述(富文本)")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("封面图")
|
||||
@Excel(name = "封面图")
|
||||
private String coverImage;
|
||||
|
||||
@ApiModelProperty("视频路径(一个)")
|
||||
@Excel(name = "视频路径", readConverterExp = "一=个")
|
||||
private String videoUrl;
|
||||
|
||||
@ApiModelProperty("分享数")
|
||||
@Excel(name = "分享数")
|
||||
private Long shareNum;
|
||||
|
||||
@ApiModelProperty("点赞数")
|
||||
@Excel(name = "点赞数")
|
||||
private Long likeNum;
|
||||
|
||||
@ApiModelProperty("评论数")
|
||||
@Excel(name = "评论数")
|
||||
private Long commentNum;
|
||||
|
||||
@ApiModelProperty("收藏数")
|
||||
@Excel(name = "收藏数")
|
||||
private Long collectNum;
|
||||
|
||||
@ApiModelProperty("浏览数")
|
||||
@Excel(name = "浏览数")
|
||||
private Long browseNum;
|
||||
|
||||
@ApiModelProperty("状态 1 待审核 2 通过 3 拒绝")
|
||||
@Excel(name = "状态 1 待审核 2 通过 3 拒绝")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty("拒绝原因")
|
||||
@Excel(name = "拒绝原因")
|
||||
private String reason;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.ruoyi.post.frequency.post.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.post.controller.req.PostPageReq;
|
||||
import com.ruoyi.post.controller.req.PostReleaseReq;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.post.frequency.post.model.result.PostCount;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 帖子Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
public interface PostService extends IService<Post>
|
||||
{
|
||||
/**
|
||||
* 查询帖子
|
||||
*
|
||||
* @param id 帖子主键
|
||||
* @return 帖子
|
||||
*/
|
||||
public Post selectPostById(Long id);
|
||||
|
||||
/**
|
||||
* 查询帖子列表
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 帖子集合
|
||||
*/
|
||||
public List<Post> selectPostList(Post post);
|
||||
|
||||
PostCount statistics(Post post);
|
||||
|
||||
/**
|
||||
* 新增帖子
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPost(Post post);
|
||||
|
||||
/**
|
||||
* 修改帖子
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePost(Post post);
|
||||
|
||||
int updatePostLikeNum(Post post, Integer num);
|
||||
|
||||
/**
|
||||
* 批量删除帖子
|
||||
*
|
||||
* @param ids 需要删除的帖子主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除帖子信息
|
||||
*
|
||||
* @param id 帖子主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostById(Long id);
|
||||
|
||||
/**
|
||||
* 帖子发布
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
ResponseData postRelease(PostReleaseReq req, UserVo userVo);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子列表
|
||||
* @param req
|
||||
* @param userVo 登入用户
|
||||
* @return
|
||||
*/
|
||||
ResponseData postPage(PostPageReq req, UserVo userVo);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子详情
|
||||
* @param postId 帖子id
|
||||
* @param userVo 登入用户
|
||||
* @return
|
||||
*/
|
||||
ResponseData postDetail(Long postId,Integer isAddBrowseNum, UserVo userVo);
|
||||
|
||||
/**
|
||||
* 查询帖子
|
||||
* @param postIds
|
||||
* @return
|
||||
*/
|
||||
Map<Long, Post> selectPostMap(Set<Long> postIds);
|
||||
|
||||
/**
|
||||
* 帖子修改
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
ResponseData postEdit(PostReleaseReq req, UserVo userVo);
|
||||
|
||||
/**
|
||||
* 帖子删除
|
||||
* @param id
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
ResponseData postDelete(Long id, UserVo userVo);
|
||||
|
||||
/**
|
||||
* 帖子置顶/取消置顶
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
AjaxResult topping(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,365 @@
|
||||
package com.ruoyi.post.frequency.post.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.code.DictConstant;
|
||||
import com.ruoyi.code.PublicCommon;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.page.PageResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.enums.process.ProcessResultEnums;
|
||||
import com.ruoyi.enums.user.UserEnums;
|
||||
import com.ruoyi.frequency.customer.service.UserService;
|
||||
import com.ruoyi.frequency.enterprise.entity.Enterprise;
|
||||
import com.ruoyi.frequency.enterprise.service.EnterpriseService;
|
||||
import com.ruoyi.frequency.recommend.service.RecommendService;
|
||||
import com.ruoyi.frequency.store.entity.Store;
|
||||
import com.ruoyi.frequency.store.service.StoreService;
|
||||
import com.ruoyi.post.controller.req.PostPageReq;
|
||||
import com.ruoyi.post.controller.req.PostReleaseReq;
|
||||
import com.ruoyi.post.controller.resp.PostDetailResp;
|
||||
import com.ruoyi.post.controller.resp.PostPageResp;
|
||||
import com.ruoyi.post.controller.vo.SelectedComment;
|
||||
import com.ruoyi.post.frequency.posshield.service.PostShieldService;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.post.frequency.post.mapper.PostMapper;
|
||||
import com.ruoyi.post.frequency.post.model.result.PostCount;
|
||||
import com.ruoyi.post.frequency.post.service.PostService;
|
||||
import com.ruoyi.post.frequency.postcomment.service.PostCommentService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.utils.BusinessUtil;
|
||||
import com.ruoyi.utils.SnowIdUtils;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 帖子Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements PostService {
|
||||
@Autowired
|
||||
private PostMapper postMapper;
|
||||
|
||||
/**
|
||||
* 查询帖子
|
||||
*
|
||||
* @param id 帖子主键
|
||||
* @return 帖子
|
||||
*/
|
||||
@Override
|
||||
public Post selectPostById(Long id) {
|
||||
Post post = postMapper.selectPostById(id);
|
||||
|
||||
if (post != null) {
|
||||
Set<UserVo> userVoSet = new HashSet<>();
|
||||
userVoSet.add(new UserVo(post.getUserType(), post.getUserId()));
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, null);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(post.getCommentId())) {
|
||||
//精彩评论ids
|
||||
List<Long> commentIds = CollectionUtil.toList(post.getCommentId());
|
||||
|
||||
//查询精选评论
|
||||
Map<Long, SelectedComment> selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds, null);
|
||||
|
||||
post.setSelectedComment(selectedCommentMap.get(post.getId()));
|
||||
}
|
||||
|
||||
post.setUserInfo(userMap.get(new UserVo(post.getUserType(), post.getUserId())));
|
||||
|
||||
}
|
||||
|
||||
return post;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private EnterpriseService enterpriseService;
|
||||
|
||||
/**
|
||||
* 查询帖子列表
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 帖子
|
||||
*/
|
||||
@Override
|
||||
public List<Post> selectPostList(Post post) {
|
||||
|
||||
List<Post> posts = postList(post);
|
||||
|
||||
if (!posts.isEmpty()) {
|
||||
Set<UserVo> userVoSet = posts.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet());
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, null);
|
||||
|
||||
//精彩评论ids
|
||||
List<Long> commentIds = posts.stream().filter(s -> ObjectUtil.isNotEmpty(s.getCommentId())).map(Post::getCommentId).collect(Collectors.toList());
|
||||
|
||||
//查询精选评论
|
||||
Map<Long, SelectedComment> selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds, null);
|
||||
|
||||
posts.stream().forEach(s -> {
|
||||
s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId())));
|
||||
s.setSelectedComment(selectedCommentMap.get(s.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
return posts;
|
||||
}
|
||||
|
||||
private List<Post> postList(Post post) {
|
||||
if (SecurityUtils.hasRoleKey("enterprise")) {
|
||||
Enterprise enterprise = enterpriseService.getOne(new QueryWrapper<Enterprise>().lambda().eq(Enterprise::getSysUserId, SecurityUtils.getUserId()));
|
||||
if (enterprise == null) {
|
||||
return null;
|
||||
}
|
||||
post.setEnterpriseId(enterprise.getId());
|
||||
}
|
||||
|
||||
List<Post> posts = postMapper.selectPostList(post);
|
||||
return posts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostCount statistics(Post post) {
|
||||
|
||||
List<Post> posts = postList(post);
|
||||
List<Long> postIdList = posts.stream().map(x -> x.getId()).collect(Collectors.toList());
|
||||
postIdList.add(-1L);
|
||||
return postMapper.statistics(postIdList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增帖子
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPost(Post post) {
|
||||
post.setCreateTime(DateUtils.getNowDate());
|
||||
return postMapper.insert(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePost(Post post) {
|
||||
post.setUpdateTime(DateUtils.getNowDate());
|
||||
return postMapper.updateById(post);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改帖子
|
||||
*
|
||||
* @param post 帖子
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePostLikeNum(Post post, Integer num) {
|
||||
post.setUpdateTime(DateUtils.getNowDate());
|
||||
return postMapper.updatePostLikeNum(post.getId(), num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除帖子
|
||||
*
|
||||
* @param ids 需要删除的帖子主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostByIds(Long[] ids) {
|
||||
this.lambdaUpdate().set(Post::getDelFlag, PublicCommon.删除).in(Post::getId, ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帖子信息
|
||||
*
|
||||
* @param id 帖子主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostById(Long id) {
|
||||
this.lambdaUpdate().set(Post::getDelFlag, PublicCommon.删除).eq(Post::getId, id).update();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult topping(Long id) {
|
||||
|
||||
//自动置顶 1作品 2帖子
|
||||
recommendService.topping(2, id);
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private BusinessUtil businessUtil;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Autowired
|
||||
private RecommendService recommendService;
|
||||
|
||||
@Override
|
||||
public ResponseData postRelease(PostReleaseReq req, UserVo userVo) {
|
||||
|
||||
Post post = new Post(req, userVo);
|
||||
|
||||
//是否需要审核
|
||||
SysDictData post_dict = businessUtil.getDict(DictConstant.帖子审核);
|
||||
|
||||
Optional.ofNullable(post_dict)
|
||||
.filter(s -> s.getDictValue().equals(PublicCommon.Process.不用审核))
|
||||
.ifPresent(p -> post.setResult(ProcessResultEnums.APPROVED.getCode()));
|
||||
|
||||
boolean save = this.save(post);
|
||||
//表现师发布帖子 判断该表现师是否是官方用户
|
||||
if (save && ObjectUtil.equal(UserEnums.store.getCode(), userVo.getUserType())) {
|
||||
Store store = storeService.getById(userVo.getUserId());
|
||||
if (store != null && ObjectUtil.isNotEmpty(store.getIsPlatform()) && store.getIsPlatform() == 2) {
|
||||
//自动置顶 1作品 2帖子
|
||||
recommendService.topping(2, post.getId());
|
||||
}
|
||||
}
|
||||
return ResponseData.success(post.getId());
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private PostCommentService postCommentService;
|
||||
|
||||
@Autowired
|
||||
private PostShieldService postShieldService;
|
||||
|
||||
@Override
|
||||
public ResponseData postPage(PostPageReq req, UserVo userVo) {
|
||||
|
||||
//筛去拉黑与被拉黑用户
|
||||
List<UserVo> blockUserList = userService.blockUserList(userVo);
|
||||
req.setBlockUserList(blockUserList);
|
||||
|
||||
//筛去屏蔽用户
|
||||
List<UserVo> shieldUserList = userService.shieldUserList(userVo);
|
||||
req.setShieldUserList(shieldUserList);
|
||||
|
||||
//筛去屏蔽的帖子
|
||||
List<Long> shieldPostIdList = postShieldService.shieldPostList(userVo);
|
||||
req.setShieldPostIdList(shieldPostIdList);
|
||||
|
||||
|
||||
Page<PostPageResp> page = this.baseMapper.postPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo);
|
||||
|
||||
if (!page.getRecords().isEmpty()) {
|
||||
Set<UserVo> userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet());
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
|
||||
//精彩评论ids
|
||||
List<Long> commentIds = page.getRecords().stream().filter(s -> ObjectUtil.isNotEmpty(s.getCommentId())).map(PostPageResp::getCommentId).collect(Collectors.toList());
|
||||
|
||||
//查询精选评论
|
||||
Map<Long, SelectedComment> selectedCommentMap = postCommentService.getSelectedCommentMap(commentIds, userVo);
|
||||
|
||||
//帖子ids
|
||||
List<Long> postIds = page.getRecords().stream().filter(s -> ObjectUtil.isNotEmpty(s.getId())).map(PostPageResp::getId).collect(Collectors.toList());
|
||||
|
||||
//查询最新评论 帖子id ->最新评论
|
||||
Map<Long, SelectedComment> selectedNewCommentMap = postCommentService.getSelectedNewCommentMap(postIds, userVo);
|
||||
|
||||
|
||||
page.getRecords().stream().forEach(resp -> {
|
||||
resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId())));
|
||||
|
||||
if (selectedCommentMap.get(resp.getCommentId()) != null) {
|
||||
resp.setSelectedComment(selectedCommentMap.get(resp.getCommentId()));
|
||||
} else {
|
||||
//没有精选评论-->查询最新一条评论
|
||||
resp.setSelectedComment(selectedNewCommentMap.get(resp.getId()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return ResponseData.success(new PageResult<>(page));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseData postDetail(Long id, Integer isAddBrowseNum, UserVo userVo) {
|
||||
|
||||
PostDetailResp detailResp = this.baseMapper.postDetail(id, userVo);
|
||||
|
||||
//增加论坛浏览数
|
||||
Optional.ofNullable(detailResp).ifPresent(p -> {
|
||||
|
||||
//是否增加浏览数 1不增加 2 加
|
||||
if (ObjectUtil.equal(2, isAddBrowseNum)) {
|
||||
this.baseMapper.updateNumPost(id, PublicCommon.Post.浏览数, 1);
|
||||
|
||||
this.baseMapper.updateBrowseRecord(SnowIdUtils.uniqueLong(), 2, new Date(), id, userVo);
|
||||
}
|
||||
|
||||
Set<UserVo> userVoSet = new HashSet<>();
|
||||
UserVo user = new UserVo(detailResp.getUserType(), detailResp.getUserId());
|
||||
userVoSet.add(user);
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
detailResp.setUserInfo(userMap.get(user));
|
||||
|
||||
PostPageResp postPageResp = new PostPageResp();
|
||||
BeanUtil.copyProperties(detailResp, postPageResp);
|
||||
}
|
||||
);
|
||||
return ResponseData.success(detailResp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Post> selectPostMap(Set<Long> postIds) {
|
||||
|
||||
List<Post> posts = this.list(new QueryWrapper<Post>().lambda().in(Post::getId, postIds));
|
||||
|
||||
return posts.stream().collect(Collectors.toMap(Post::getId, Function.identity()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData postEdit(PostReleaseReq req, UserVo userVo) {
|
||||
Post post = new Post();
|
||||
BeanUtil.copyProperties(req, post);
|
||||
post.setUpdateData();
|
||||
this.updateById(post);
|
||||
return ResponseData.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData postDelete(Long id, UserVo userVo) {
|
||||
this.lambdaUpdate().set(Post::getDelFlag, PublicCommon.删除).eq(Post::getId, id).update();
|
||||
return ResponseData.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.post.frequency.postcomment.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.post.frequency.postcomment.entity.PostComment;
|
||||
import com.ruoyi.post.frequency.postcomment.service.PostCommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子评论Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/poscomment")
|
||||
public class PostCommentController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private PostCommentService postCommentService;
|
||||
|
||||
/**
|
||||
* 查询帖子评论列表
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:poscomment:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo<PostComment> list(@RequestBody PostComment postComment)
|
||||
{
|
||||
startPage();
|
||||
List<PostComment> list = postCommentService.selectPostCommentList(postComment);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出帖子评论列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poscomment:export')")
|
||||
@Log(title = "帖子评论", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(PostComment postComment)
|
||||
{
|
||||
List<PostComment> list = postCommentService.selectPostCommentList(postComment);
|
||||
ExcelUtil<PostComment> util = new ExcelUtil<PostComment>(PostComment.class);
|
||||
return util.exportExcel(list, "帖子评论数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帖子评论详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poscomment:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<PostComment> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(postCommentService.selectPostCommentById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增帖子评论
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poscomment:add')")
|
||||
@Log(title = "帖子评论", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PostComment postComment)
|
||||
{
|
||||
return toAjax(postCommentService.insertPostComment(postComment));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子评论
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poscomment:edit')")
|
||||
@Log(title = "帖子评论", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PostComment postComment)
|
||||
{
|
||||
return toAjax(postCommentService.updatePostComment(postComment));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帖子评论
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poscomment:remove')")
|
||||
@Log(title = "帖子评论", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}/{delFlag}")
|
||||
public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
|
||||
{
|
||||
return toAjax(postCommentService.deleteCommentByIds(ids,delFlag));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.ruoyi.post.frequency.postcomment.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.post.controller.req.PostCommentReq;
|
||||
import com.ruoyi.utils.SnowIdUtils;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子评论对象 t_post_comment
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_post_comment")
|
||||
public class PostComment extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("评论用户id")
|
||||
@Excel(name = "评论用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("帖子id")
|
||||
@Excel(name = "帖子id")
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty("顶级评论id(对主体的直接评论)")
|
||||
@Excel(name = "顶级评论id(对主体的直接评论)")
|
||||
private Long topId;
|
||||
|
||||
@ApiModelProperty("上级评论id 默认0")
|
||||
@Excel(name = "上级评论id 默认0")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer parentUserType;
|
||||
|
||||
@ApiModelProperty("上级评论用户id")
|
||||
@Excel(name = "上级评论用户id")
|
||||
private Long parentUserId;
|
||||
|
||||
@ApiModelProperty("评论内容")
|
||||
@Excel(name = "评论内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
@Excel(name = "图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty("点赞数")
|
||||
@Excel(name = "点赞数")
|
||||
private Integer likeNum;
|
||||
|
||||
@ApiModelProperty("评论数")
|
||||
@Excel(name = "评论数")
|
||||
private Integer commentNum;
|
||||
|
||||
@ApiModelProperty("上级评论id集合,逗号拼接")
|
||||
@Excel(name = "上级评论id集合,逗号拼接")
|
||||
private String parentIds;
|
||||
|
||||
@ApiModelProperty(value = "用户信息")
|
||||
@TableField(exist = false)
|
||||
private UserInfo userInfo;
|
||||
|
||||
@ApiModelProperty(value = "上级用户用户昵称")
|
||||
@TableField(exist = false)
|
||||
private UserInfo parentUserInfo;
|
||||
|
||||
public PostComment() {
|
||||
}
|
||||
|
||||
public PostComment(PostCommentReq req, UserVo userVo) {
|
||||
this.id = SnowIdUtils.uniqueLong();
|
||||
this.userType = userVo.getUserType();
|
||||
this.userId = userVo.getUserId();
|
||||
this.postId = req.getPostId();
|
||||
this.content = req.getContent();
|
||||
this.image = req.getImage();
|
||||
this.parentId = req.getParentId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.ruoyi.post.frequency.postcomment.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.controller.req.DialoguePageReq;
|
||||
import com.ruoyi.controller.resp.CommentNum;
|
||||
import com.ruoyi.post.controller.req.PostCommentPageReq;
|
||||
import com.ruoyi.post.controller.resp.PostCommentPageResp;
|
||||
import com.ruoyi.post.controller.resp.PostCommentResp;
|
||||
import com.ruoyi.post.frequency.postcomment.entity.PostComment;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子评论Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
public interface PostCommentMapper extends BaseMapper<PostComment>
|
||||
{
|
||||
/**
|
||||
* 查询帖子评论
|
||||
*
|
||||
* @param id 帖子评论主键
|
||||
* @return 帖子评论
|
||||
*/
|
||||
public PostComment selectPostCommentById(Long id);
|
||||
|
||||
/**
|
||||
* 查询帖子评论列表
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 帖子评论集合
|
||||
*/
|
||||
public List<PostComment> selectPostCommentList(PostComment postComment);
|
||||
|
||||
/**
|
||||
* 新增帖子评论
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostComment(PostComment postComment);
|
||||
|
||||
/**
|
||||
* 修改帖子评论
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostComment(PostComment postComment);
|
||||
|
||||
/**
|
||||
* 修改帖子评论
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostCommentNumBatch(@Param("list") List<PostComment> postComment);
|
||||
|
||||
|
||||
/**
|
||||
* 删除帖子评论
|
||||
*
|
||||
* @param id 帖子评论主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostCommentById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除帖子评论
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostCommentByIds(Long[] ids);
|
||||
|
||||
|
||||
/**
|
||||
*获取评论后数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
PostCommentResp getPostCommentResp(@Param("id")Long id,@Param("userVo") UserVo userVo);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子评论列表
|
||||
* @param objectPage
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
Page<PostCommentPageResp> postCommentPage(@Param("page")Page<Object> objectPage, @Param("req") PostCommentPageReq req, @Param("userVo") UserVo userVo);
|
||||
|
||||
List<CommentNum> selectCommentNumList(@Param("commentIds") List<Long> commentIds,@Param("userVoList") List<UserVo> userVoList);
|
||||
|
||||
List<PostComment> selectedNewCommentList(@Param("postIds") List<Long> postIds);
|
||||
|
||||
@Update("update t_post_comment set like_num = like_num + #{num} , update_time=now() where id = #{id}")
|
||||
int updatePostCommentLikeNum(@Param("id") Long id, @Param("num") Integer num);
|
||||
|
||||
List<PostCommentPageResp> postCommentList(@Param("req") PostCommentPageReq req,@Param("userVo") UserVo userVo,@Param("list") List<Long> parentIds);
|
||||
|
||||
Page<PostCommentPageResp> postCommentDialoguePage(@Param("page") Page<Object> objectPage,@Param("req") DialoguePageReq req,@Param("userVo") UserVo userVo);
|
||||
}
|
||||
@@ -0,0 +1,713 @@
|
||||
<?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.ruoyi.post.frequency.postcomment.mapper.PostCommentMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.post.frequency.postcomment.entity.PostComment" id="PostCommentResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="userType" column="user_type"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="postId" column="post_id"/>
|
||||
<result property="topId" column="top_id"/>
|
||||
<result property="parentId" column="parent_id"/>
|
||||
<result property="parentUserType" column="parent_user_type"/>
|
||||
<result property="parentUserId" column="parent_user_id"/>
|
||||
<result property="content" column="content"/>
|
||||
<result property="image" column="image"/>
|
||||
<result property="likeNum" column="like_num"/>
|
||||
<result property="commentNum" column="comment_num"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPostCommentVo">
|
||||
select id,
|
||||
del_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
user_type,
|
||||
user_id,
|
||||
post_id,
|
||||
top_id,
|
||||
parent_id,
|
||||
parent_user_type,
|
||||
parent_user_id,
|
||||
content,
|
||||
image,
|
||||
like_num,
|
||||
comment_num
|
||||
from t_post_comment
|
||||
</sql>
|
||||
|
||||
<select id="selectPostCommentList" parameterType="com.ruoyi.post.frequency.postcomment.entity.PostComment"
|
||||
resultMap="PostCommentResult">
|
||||
<include refid="selectPostCommentVo"/>
|
||||
<where>and del_flag != 2
|
||||
<if test="userType != null ">and user_type = #{userType}</if>
|
||||
<if test="userId != null ">and user_id = #{userId}</if>
|
||||
<if test="postId != null ">and post_id = #{postId}</if>
|
||||
<if test="topId != null ">and top_id = #{topId}</if>
|
||||
<if test="parentId != null ">and parent_id = #{parentId}</if>
|
||||
<if test="parentUserType != null ">and parent_user_type = #{parentUserType}</if>
|
||||
<if test="parentUserId != null ">and parent_user_id = #{parentUserId}</if>
|
||||
<if test="content != null and content != ''">and content = #{content}</if>
|
||||
<if test="image != null and image != ''">and image = #{image}</if>
|
||||
<if test="likeNum != null ">and like_num = #{likeNum}</if>
|
||||
<if test="commentNum != null ">and comment_num = #{commentNum}</if>
|
||||
</where>
|
||||
order by create_time asc
|
||||
</select>
|
||||
|
||||
<select id="selectPostCommentById" parameterType="Long" resultMap="PostCommentResult">
|
||||
<include refid="selectPostCommentVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPostComment" parameterType="com.ruoyi.post.frequency.postcomment.entity.PostComment">
|
||||
insert into t_post_comment
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="userType != null">user_type,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="postId != null">post_id,</if>
|
||||
<if test="topId != null">top_id,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="parentUserType != null">parent_user_type,</if>
|
||||
<if test="parentUserId != null">parent_user_id,</if>
|
||||
<if test="content != null">content,</if>
|
||||
<if test="image != null">image,</if>
|
||||
<if test="likeNum != null">like_num,</if>
|
||||
<if test="commentNum != null">comment_num,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="userType != null">#{userType},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="postId != null">#{postId},</if>
|
||||
<if test="topId != null">#{topId},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="parentUserType != null">#{parentUserType},</if>
|
||||
<if test="parentUserId != null">#{parentUserId},</if>
|
||||
<if test="content != null">#{content},</if>
|
||||
<if test="image != null">#{image},</if>
|
||||
<if test="likeNum != null">#{likeNum},</if>
|
||||
<if test="commentNum != null">#{commentNum},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePostComment" parameterType="com.ruoyi.post.frequency.postcomment.entity.PostComment">
|
||||
update t_post_comment
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="userType != null">user_type = #{userType},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="postId != null">post_id = #{postId},</if>
|
||||
<if test="topId != null">top_id = #{topId},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="parentUserType != null">parent_user_type = #{parentUserType},</if>
|
||||
<if test="parentUserId != null">parent_user_id = #{parentUserId},</if>
|
||||
<if test="content != null">content = #{content},</if>
|
||||
<if test="image != null">image = #{image},</if>
|
||||
<if test="likeNum != null">like_num = like_num + #{likeNum},</if>
|
||||
<if test="commentNum != null">comment_num = comment_num + #{commentNum},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
<if test="likeNum != null">and like_num + #{likeNum}>=0</if>
|
||||
<if test="commentNum != null">and comment_num + #{commentNum} >= 0</if>
|
||||
</update>
|
||||
|
||||
|
||||
<update id="updatePostCommentNumBatch" parameterType="com.ruoyi.post.frequency.postcomment.entity.PostComment">
|
||||
<foreach item="item" index="index" collection="list" separator=";">
|
||||
update t_post_comment
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="item.likeNum != null">like_num = like_num + #{item.likeNum},</if>
|
||||
<if test="item.commentNum != null">comment_num = comment_num + #{item.commentNum},</if>
|
||||
</trim>
|
||||
where id = #{item.id}
|
||||
<if test="item.likeNum != null">and like_num + #{item.likeNum}>=0</if>
|
||||
<if test="item.commentNum != null">and comment_num + #{item.commentNum} >= 0</if>
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deletePostCommentById" parameterType="Long">
|
||||
delete
|
||||
from t_post_comment
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePostCommentByIds" parameterType="String">
|
||||
delete from t_post_comment where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getPostCommentResp" resultType="com.ruoyi.post.controller.resp.PostCommentResp">
|
||||
SELECT t.id,
|
||||
t.top_id,
|
||||
t.create_time,
|
||||
t.user_type,
|
||||
t.user_id,
|
||||
t.parent_id,
|
||||
t.parent_user_type,
|
||||
t.parent_user_id,
|
||||
t.content,
|
||||
t.like_num,
|
||||
t.comment_num,
|
||||
CASE
|
||||
WHEN (SELECT COUNT(1)
|
||||
FROM t_post_like fl
|
||||
WHERE fl.del_flag = 1
|
||||
AND fl.type = 2
|
||||
AND fl.user_id = #{userVo.userId}
|
||||
AND fl.user_type = #{userVo.userType}
|
||||
AND fl.object_id = t.id) = 0 THEN
|
||||
1
|
||||
ELSE 2
|
||||
END isLike,
|
||||
CASE
|
||||
WHEN #{userVo.userType} = t.user_type
|
||||
AND #{userVo.userId} = t.user_id THEN
|
||||
2
|
||||
ELSE 1
|
||||
END isSelf
|
||||
FROM t_post_comment AS t
|
||||
WHERE t.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="postCommentPage" resultType="com.ruoyi.post.controller.resp.PostCommentPageResp">
|
||||
SELECT
|
||||
t.id,
|
||||
t.top_id,
|
||||
t.create_time,
|
||||
t.user_type,
|
||||
t.user_id,
|
||||
t.parent_id,
|
||||
t.parent_user_type,
|
||||
t.parent_user_id,
|
||||
t.image,
|
||||
t.content,
|
||||
t.like_num,
|
||||
t.comment_num,
|
||||
CASE
|
||||
WHEN (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_post_like fl
|
||||
WHERE
|
||||
fl.del_flag = 1
|
||||
AND fl.type = 2
|
||||
AND fl.user_id = #{userVo.userId}
|
||||
AND fl.user_type = #{userVo.userType}
|
||||
AND fl.object_id = t.id
|
||||
) = 0 THEN
|
||||
1 ELSE 2
|
||||
END isLike,
|
||||
CASE
|
||||
WHEN #{userVo.userType} = t.user_type
|
||||
AND #{userVo.userId} = t.user_id THEN
|
||||
2 ELSE 1
|
||||
END isSelf,
|
||||
IF( p.comment_id is not null and t.id = p.comment_id ,2,1) isSelectedComment
|
||||
FROM
|
||||
t_post_comment AS t
|
||||
LEFT JOIN t_post_comment t4 ON t.parent_id = t4.id
|
||||
LEFT JOIN t_post p ON t.post_id = p.id
|
||||
WHERE
|
||||
t.del_flag = 1
|
||||
AND t.post_id = #{req.postId}
|
||||
<if test="req.parentId!=null and req.parentId!=''">
|
||||
AND t.parent_id != 0
|
||||
AND t.top_id = #{req.parentId}
|
||||
</if>
|
||||
<if test="req.parentId==null or req.parentId ==''">
|
||||
AND t.parent_id = 0
|
||||
</if>
|
||||
|
||||
<if test="req.blockUserList!=null and req.blockUserList.size() > 0">
|
||||
AND (
|
||||
(t.user_type = 1 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 1,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 2 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 2,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 4 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 4,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
)
|
||||
</if>
|
||||
<if test="req.shieldUserList!=null and req.shieldUserList.size() > 0">
|
||||
AND (
|
||||
(t.user_type = 1 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 1,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 2 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 2,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 4 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 4,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
)
|
||||
</if>
|
||||
ORDER BY
|
||||
<choose>
|
||||
<when test="req.sortType != null and req.sortType != ''">
|
||||
<if test="req.sortType == 1">
|
||||
<if test="req.isAsc == 1">
|
||||
t.create_time
|
||||
</if>
|
||||
<if test="req.isAsc == 2">
|
||||
t.create_time DESC
|
||||
</if>
|
||||
</if>
|
||||
<if test="req.sortType == 2">
|
||||
<if test="req.isAsc == 1">
|
||||
t.like_num
|
||||
</if>
|
||||
<if test="req.isAsc == 2">
|
||||
t.like_num DESC
|
||||
</if>
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
t.like_num DESC ,t.create_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="selectCommentNumList" resultType="com.ruoyi.controller.resp.CommentNum">
|
||||
SELECT
|
||||
t.top_id post_id,
|
||||
COUNT(t.id) commentNum
|
||||
FROM
|
||||
t_post_comment AS t
|
||||
LEFT JOIN t_post_comment t4 ON t.parent_id = t4.id
|
||||
WHERE
|
||||
t.del_flag = 1
|
||||
AND t.parent_id != 0
|
||||
AND t.top_id in
|
||||
<foreach item="id" collection="commentIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND (
|
||||
(t.user_type = 1 and t.user_id in
|
||||
<foreach collection="userVoList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 1,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 2 and t.user_id in
|
||||
<foreach collection="userVoList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 2,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 4 and t.user_id in
|
||||
<foreach collection="userVoList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 4,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
)
|
||||
GROUP BY t.top_id
|
||||
</select>
|
||||
|
||||
<select id="selectedNewCommentList" resultType="com.ruoyi.post.frequency.postcomment.entity.PostComment">
|
||||
SELECT
|
||||
tt2.*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
t.post_id,
|
||||
MAX( t.create_time ) create_time
|
||||
FROM
|
||||
t_post_comment AS t
|
||||
WHERE
|
||||
t.del_flag = 1
|
||||
AND t.parent_id = 0
|
||||
GROUP BY
|
||||
t.post_id
|
||||
) tt
|
||||
LEFT JOIN t_post_comment tt2 ON tt2.create_time = tt.create_time
|
||||
AND tt2.post_id = tt.post_id
|
||||
AND tt2.parent_id = 0
|
||||
WHERE
|
||||
tt2.del_flag = 1
|
||||
AND tt2.post_id IN
|
||||
<foreach item="id" collection="postIds" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="postCommentList" resultType="com.ruoyi.post.controller.resp.PostCommentPageResp">
|
||||
SELECT
|
||||
t.id,
|
||||
t.top_id,
|
||||
t.create_time,
|
||||
t.user_type,
|
||||
t.user_id,
|
||||
t.parent_id,
|
||||
t.parent_user_type,
|
||||
t.parent_user_id,
|
||||
t.image,
|
||||
t.content,
|
||||
t.like_num,
|
||||
t.comment_num,
|
||||
CASE
|
||||
WHEN (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_post_like fl
|
||||
WHERE
|
||||
fl.del_flag = 1
|
||||
AND fl.type = 2
|
||||
AND fl.user_id = #{userVo.userId}
|
||||
AND fl.user_type = #{userVo.userType}
|
||||
AND fl.object_id = t.id
|
||||
) = 0 THEN
|
||||
1 ELSE 2
|
||||
END isLike,
|
||||
CASE
|
||||
WHEN #{userVo.userType} = t.user_type
|
||||
AND #{userVo.userId} = t.user_id THEN
|
||||
2 ELSE 1
|
||||
END isSelf,
|
||||
IF( p.comment_id is not null and t.id = p.comment_id ,2,1) isSelectedComment
|
||||
FROM
|
||||
t_post_comment AS t
|
||||
LEFT JOIN t_post_comment t4 ON t.parent_id = t4.id
|
||||
LEFT JOIN t_post p ON t.post_id = p.id
|
||||
WHERE
|
||||
t.del_flag = 1
|
||||
AND t.post_id = #{req.postId}
|
||||
<if test="req.parentId!=null and req.parentId!=''">
|
||||
AND t.parent_id != 0
|
||||
AND t.top_id = #{req.parentId}
|
||||
</if>
|
||||
<if test="req.parentId==null or req.parentId ==''">
|
||||
AND t.parent_id != 0
|
||||
</if>
|
||||
|
||||
<if test="req.blockUserList!=null and req.blockUserList.size() > 0">
|
||||
AND (
|
||||
(t.user_type = 1 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 1,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 2 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 2,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 4 and t.user_id not in
|
||||
<foreach collection="req.blockUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 4,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
)
|
||||
</if>
|
||||
<if test="req.shieldUserList!=null and req.shieldUserList.size() > 0">
|
||||
AND (
|
||||
(t.user_type = 1 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 1,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 2 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 2,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
or
|
||||
(t.user_type = 4 and t.user_id not in
|
||||
<foreach collection="req.shieldUserList" item="userVo" open="(" close=")" separator=",">
|
||||
IF(#{userVo.userType} = 4,#{userVo.userId},'')
|
||||
</foreach>)
|
||||
)
|
||||
</if>
|
||||
AND ( SELECT COUNT(*) FROM t_post_comment AS sub WHERE sub.parent_id = t.parent_id AND sub.like_num >=
|
||||
t.like_num AND sub.create_time <= t.create_time ) <= 10
|
||||
AND t.parent_id in
|
||||
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
ORDER BY
|
||||
t.like_num DESC ,t.create_time
|
||||
</select>
|
||||
|
||||
<!-- <select id="postCommentDialoguePage" resultType="com.ruoyi.post.controller.resp.PostCommentPageResp">-->
|
||||
|
||||
<!-- (SELECT-->
|
||||
<!-- t.id,-->
|
||||
<!-- t.create_time,-->
|
||||
<!-- t.user_type,-->
|
||||
<!-- t.user_id,-->
|
||||
<!-- t.parent_id,-->
|
||||
<!-- t.parent_user_type,-->
|
||||
<!-- t.parent_user_id,-->
|
||||
<!-- t.image,-->
|
||||
<!-- t.content,-->
|
||||
<!-- t.like_num,-->
|
||||
<!-- t.comment_num,-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN (-->
|
||||
<!-- SELECT-->
|
||||
<!-- COUNT( 1 )-->
|
||||
<!-- FROM-->
|
||||
<!-- t_post_like fl-->
|
||||
<!-- WHERE-->
|
||||
<!-- fl.del_flag = 1-->
|
||||
<!-- AND fl.type = 2-->
|
||||
<!-- AND fl.user_id = #{userVo.userId}-->
|
||||
<!-- AND fl.user_type = #{userVo.userType}-->
|
||||
<!-- AND fl.object_id = t.id-->
|
||||
<!-- ) = 0 THEN-->
|
||||
<!-- 1 ELSE 2-->
|
||||
<!-- END isLike,-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN #{userVo.userType} = t.user_type-->
|
||||
<!-- AND #{userVo.userId} = t.user_id THEN-->
|
||||
<!-- 2 ELSE 1-->
|
||||
<!-- END isSelf,-->
|
||||
<!-- IF( p.comment_id is not null and t.id = p.comment_id ,2,1) isSelectedComment-->
|
||||
<!-- FROM-->
|
||||
<!-- t_post_comment AS t-->
|
||||
<!-- LEFT JOIN t_post_comment t4 ON t.parent_id = t4.id-->
|
||||
<!-- LEFT JOIN t_post p ON t.post_id = p.id-->
|
||||
<!-- WHERE-->
|
||||
<!-- t.id = #{req.commentId}-->
|
||||
<!-- )-->
|
||||
<!-- UNION ALL-->
|
||||
<!-- (-->
|
||||
<!-- SELECT-->
|
||||
<!-- t.id,-->
|
||||
<!-- t.create_time,-->
|
||||
<!-- t.user_type,-->
|
||||
<!-- t.user_id,-->
|
||||
<!-- t.parent_id,-->
|
||||
<!-- t.parent_user_type,-->
|
||||
<!-- t.parent_user_id,-->
|
||||
<!-- t.image,-->
|
||||
<!-- t.content,-->
|
||||
<!-- t.like_num,-->
|
||||
<!-- t.comment_num,-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN (-->
|
||||
<!-- SELECT-->
|
||||
<!-- COUNT( 1 )-->
|
||||
<!-- FROM-->
|
||||
<!-- t_post_like fl-->
|
||||
<!-- WHERE-->
|
||||
<!-- fl.del_flag = 1-->
|
||||
<!-- AND fl.type = 2-->
|
||||
<!-- AND fl.user_id = #{userVo.userId}-->
|
||||
<!-- AND fl.user_type = #{userVo.userType}-->
|
||||
<!-- AND fl.object_id = t.id-->
|
||||
<!-- ) = 0 THEN-->
|
||||
<!-- 1 ELSE 2-->
|
||||
<!-- END isLike,-->
|
||||
<!-- CASE-->
|
||||
<!-- WHEN #{userVo.userType} = t.user_type-->
|
||||
<!-- AND #{userVo.userId} = t.user_id THEN-->
|
||||
<!-- 2 ELSE 1-->
|
||||
<!-- END isSelf,-->
|
||||
<!-- IF( p.comment_id is not null and t.id = p.comment_id ,2,1) isSelectedComment-->
|
||||
<!-- FROM-->
|
||||
<!-- t_post_comment AS t-->
|
||||
<!-- LEFT JOIN t_post_comment t4 ON t.parent_id = t4.id-->
|
||||
<!-- LEFT JOIN t_post p ON t.post_id = p.id-->
|
||||
<!-- LEFT JOIN t_post_comment pc ON pc.id = #{req.commentId}-->
|
||||
<!-- WHERE-->
|
||||
<!-- t.del_flag = 1-->
|
||||
<!-- AND t.id != #{req.commentId}-->
|
||||
<!-- AND (-->
|
||||
<!-- (t.user_type = pc.user_type and t.user_id = pc.user_id )-->
|
||||
<!-- or-->
|
||||
<!-- (t.user_type = pc.parent_user_type and t.user_id = pc.parent_user_id )-->
|
||||
<!-- or-->
|
||||
<!-- (t.parent_user_type = pc.user_type and t.parent_user_id = pc.user_id )-->
|
||||
<!-- or-->
|
||||
<!-- (t.parent_user_type = pc.parent_user_type and t.parent_user_id = pc.parent_user_id )-->
|
||||
<!-- )-->
|
||||
<!-- <if test="req.parentId!=null and req.parentId!=''">-->
|
||||
<!-- AND t.parent_id != 0-->
|
||||
<!-- AND t.top_id = #{req.parentId}-->
|
||||
<!-- </if>-->
|
||||
<!-- ORDER BY-->
|
||||
<!-- <choose>-->
|
||||
<!-- <when test="req.sortType != null and req.sortType != ''">-->
|
||||
<!-- <if test="req.sortType == 1">-->
|
||||
<!-- t.create_time DESC-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="req.sortType == 2">-->
|
||||
<!-- <if test="req.isAse == 1">-->
|
||||
<!-- t.like_num-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="req.isAse == 2">-->
|
||||
<!-- t.like_num DESC-->
|
||||
<!-- </if>-->
|
||||
<!-- </if>-->
|
||||
<!-- </when>-->
|
||||
<!-- <otherwise>-->
|
||||
<!-- t.like_num DESC ,t.create_time-->
|
||||
<!-- </otherwise>-->
|
||||
<!-- </choose>-->
|
||||
<!-- )-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="postCommentDialoguePage" resultType="com.ruoyi.post.controller.resp.PostCommentPageResp">
|
||||
(SELECT
|
||||
t.id,
|
||||
1 sort,
|
||||
t.create_time,
|
||||
t.user_type,
|
||||
t.user_id,
|
||||
t.parent_id,
|
||||
t.parent_user_type,
|
||||
t.parent_user_id,
|
||||
t.image,
|
||||
t.content,
|
||||
t.like_num,
|
||||
t.comment_num,
|
||||
CASE
|
||||
WHEN (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_post_like fl
|
||||
WHERE
|
||||
fl.del_flag = 1
|
||||
AND fl.type = 2
|
||||
AND fl.user_id = #{userVo.userId}
|
||||
AND fl.user_type = #{userVo.userType}
|
||||
AND fl.object_id = t.id
|
||||
) = 0 THEN
|
||||
1 ELSE 2
|
||||
END isLike,
|
||||
CASE
|
||||
WHEN #{userVo.userType} = t.user_type
|
||||
AND #{userVo.userId} = t.user_id THEN
|
||||
2 ELSE 1
|
||||
END isSelf,
|
||||
IF( p.comment_id is not null and t.id = p.comment_id ,2,1) isSelectedComment
|
||||
FROM
|
||||
t_post_comment AS t
|
||||
LEFT JOIN t_post_comment t4 ON t.parent_id = t4.id
|
||||
LEFT JOIN t_post p ON t.post_id = p.id
|
||||
WHERE
|
||||
t.id = #{req.commentId}
|
||||
)
|
||||
UNION ALL
|
||||
(
|
||||
SELECT
|
||||
t.id,
|
||||
2 sort,
|
||||
t.create_time,
|
||||
t.user_type,
|
||||
t.user_id,
|
||||
t.parent_id,
|
||||
t.parent_user_type,
|
||||
t.parent_user_id,
|
||||
t.image,
|
||||
t.content,
|
||||
t.like_num,
|
||||
t.comment_num,
|
||||
CASE
|
||||
WHEN (
|
||||
SELECT
|
||||
COUNT( 1 )
|
||||
FROM
|
||||
t_post_like fl
|
||||
WHERE
|
||||
fl.del_flag = 1
|
||||
AND fl.type = 2
|
||||
AND fl.user_id = #{userVo.userId}
|
||||
AND fl.user_type = #{userVo.userType}
|
||||
AND fl.object_id = t.id
|
||||
) = 0 THEN
|
||||
1 ELSE 2
|
||||
END isLike,
|
||||
CASE
|
||||
WHEN #{userVo.userType} = t.user_type
|
||||
AND #{userVo.userId} = t.user_id THEN
|
||||
2 ELSE 1
|
||||
END isSelf,
|
||||
IF( p.comment_id is not null and t.id = p.comment_id ,2,1) isSelectedComment
|
||||
FROM
|
||||
t_post_comment AS t
|
||||
LEFT JOIN t_post_comment t4 ON t.parent_id = t4.id
|
||||
LEFT JOIN t_post p ON t.post_id = p.id
|
||||
LEFT JOIN t_post_comment pc ON pc.id = #{req.commentId}
|
||||
WHERE
|
||||
t.del_flag = 1
|
||||
AND t.id != #{req.commentId}
|
||||
AND (
|
||||
(t.user_type = pc.user_type and t.user_id = pc.user_id )
|
||||
or
|
||||
(t.user_type = pc.parent_user_type and t.user_id = pc.parent_user_id )
|
||||
or
|
||||
(t.parent_user_type = pc.user_type and t.parent_user_id = pc.user_id )
|
||||
or
|
||||
(t.parent_user_type = pc.parent_user_type and t.parent_user_id = pc.parent_user_id )
|
||||
)
|
||||
<if test="req.parentId!=null and req.parentId!=''">
|
||||
AND t.parent_id != 0
|
||||
AND t.top_id = #{req.parentId}
|
||||
</if>
|
||||
)
|
||||
ORDER BY
|
||||
<choose>
|
||||
<when test="req.sortType != null and req.sortType != ''">
|
||||
<if test="req.sortType == 1">
|
||||
sort,create_time DESC
|
||||
<if test="req.isAsc == 1">
|
||||
sort,create_time
|
||||
</if>
|
||||
<if test="req.isAsc == 2">
|
||||
sort,create_time DESC
|
||||
</if>
|
||||
</if>
|
||||
<if test="req.sortType == 2">
|
||||
<if test="req.isAsc == 1">
|
||||
sort,like_num
|
||||
</if>
|
||||
<if test="req.isAsc == 2">
|
||||
sort, like_num DESC
|
||||
</if>
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
sort, like_num DESC ,create_time
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.ruoyi.post.frequency.postcomment.model.param;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子评论对象 t_post_comment
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostCommentParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("评论用户id")
|
||||
@Excel(name = "评论用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("帖子id")
|
||||
@Excel(name = "帖子id")
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty("顶级评论id(对主体的直接评论)")
|
||||
@Excel(name = "顶级评论id(对主体的直接评论)")
|
||||
private Long topId;
|
||||
|
||||
@ApiModelProperty("上级评论id 默认0")
|
||||
@Excel(name = "上级评论id 默认0")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer parentUserType;
|
||||
|
||||
@ApiModelProperty("上级评论用户id")
|
||||
@Excel(name = "上级评论用户id")
|
||||
private Long parentUserId;
|
||||
|
||||
@ApiModelProperty("评论内容")
|
||||
@Excel(name = "评论内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
@Excel(name = "图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty("点赞数")
|
||||
@Excel(name = "点赞数")
|
||||
private Long likeNum;
|
||||
|
||||
@ApiModelProperty("评论数")
|
||||
@Excel(name = "评论数")
|
||||
private Long commentNum;
|
||||
|
||||
@ApiModelProperty("上级评论id集合,逗号拼接")
|
||||
@Excel(name = "上级评论id集合,逗号拼接")
|
||||
private String parentIds;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.ruoyi.post.frequency.postcomment.model.result;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子评论对象 t_post_comment
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostCommentResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除状态 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("评论用户id")
|
||||
@Excel(name = "评论用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("帖子id")
|
||||
@Excel(name = "帖子id")
|
||||
private Long postId;
|
||||
|
||||
@ApiModelProperty("顶级评论id(对主体的直接评论)")
|
||||
@Excel(name = "顶级评论id(对主体的直接评论)")
|
||||
private Long topId;
|
||||
|
||||
@ApiModelProperty("上级评论id 默认0")
|
||||
@Excel(name = "上级评论id 默认0")
|
||||
private Long parentId;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
@Excel(name = "用户类型")
|
||||
private Integer parentUserType;
|
||||
|
||||
@ApiModelProperty("上级评论用户id")
|
||||
@Excel(name = "上级评论用户id")
|
||||
private Long parentUserId;
|
||||
|
||||
@ApiModelProperty("评论内容")
|
||||
@Excel(name = "评论内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty("图片")
|
||||
@Excel(name = "图片")
|
||||
private String image;
|
||||
|
||||
@ApiModelProperty("点赞数")
|
||||
@Excel(name = "点赞数")
|
||||
private Long likeNum;
|
||||
|
||||
@ApiModelProperty("评论数")
|
||||
@Excel(name = "评论数")
|
||||
private Long commentNum;
|
||||
|
||||
@ApiModelProperty("上级评论id集合,逗号拼接")
|
||||
@Excel(name = "上级评论id集合,逗号拼接")
|
||||
private String parentIds;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.ruoyi.post.frequency.postcomment.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.common.page.PageResult;
|
||||
import com.ruoyi.controller.req.DialoguePageReq;
|
||||
import com.ruoyi.post.controller.req.DeleteCommentReq;
|
||||
import com.ruoyi.post.controller.req.PostCommentPageReq;
|
||||
import com.ruoyi.post.controller.req.PostCommentReq;
|
||||
import com.ruoyi.post.controller.resp.PostCommentPageResp;
|
||||
import com.ruoyi.post.controller.resp.PostCommentResp;
|
||||
import com.ruoyi.post.controller.vo.SelectedComment;
|
||||
import com.ruoyi.post.frequency.postcomment.entity.PostComment;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 帖子评论Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
public interface PostCommentService extends IService<PostComment>
|
||||
{
|
||||
/**
|
||||
* 查询帖子评论
|
||||
*
|
||||
* @param id 帖子评论主键
|
||||
* @return 帖子评论
|
||||
*/
|
||||
public PostComment selectPostCommentById(Long id);
|
||||
|
||||
/**
|
||||
* 查询帖子评论列表
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 帖子评论集合
|
||||
*/
|
||||
public List<PostComment> selectPostCommentList(PostComment postComment);
|
||||
|
||||
/**
|
||||
* 新增帖子评论
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostComment(PostComment postComment);
|
||||
|
||||
/**
|
||||
* 修改帖子评论
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostComment(PostComment postComment);
|
||||
|
||||
int updatePostCommentBatch(List<PostComment> postCommentList);
|
||||
|
||||
int updatePostCommentLikeNum(PostComment postComment, Integer num);
|
||||
|
||||
/**
|
||||
* 批量删除帖子评论
|
||||
*
|
||||
* @param ids 需要删除的帖子评论主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostCommentByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除帖子评论信息
|
||||
*
|
||||
* @param id 帖子评论主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostCommentById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子评论
|
||||
* @param req
|
||||
* @param userVo 登入用户
|
||||
* @return
|
||||
*/
|
||||
ResponseData postComment(PostCommentReq req, UserVo userVo);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子评论列表
|
||||
* @param req
|
||||
* @param userVo 登入用户
|
||||
* @return
|
||||
*/
|
||||
ResponseData postCommentPage(PostCommentPageReq req, UserVo userVo);
|
||||
|
||||
/**
|
||||
* 删除评论
|
||||
* @param req
|
||||
* @param userVo 登入用户
|
||||
* @return
|
||||
*/
|
||||
ResponseData deleteComment(DeleteCommentReq req, UserVo userVo);
|
||||
|
||||
|
||||
/**
|
||||
* 查询精选评论
|
||||
* @param commentIds 精彩评论ids
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
Map<Long, SelectedComment> getSelectedCommentMap(List<Long> commentIds, UserVo userVo);
|
||||
|
||||
/**
|
||||
* 查询最新评论
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
Map<Long, SelectedComment> getSelectedNewCommentMap(List<Long> postIds, UserVo userVo);
|
||||
|
||||
ResponseData<PostCommentResp> postCommentDetail(Long id, UserVo userVo);
|
||||
|
||||
ResponseData<PageResult<Page<PostCommentPageResp>>> postCommentDialoguePage(DialoguePageReq req, UserVo userVo);
|
||||
|
||||
int deleteCommentByIds(Long[] ids, Integer delFlag);
|
||||
}
|
||||
@@ -0,0 +1,574 @@
|
||||
package com.ruoyi.post.frequency.postcomment.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.code.PublicCommon;
|
||||
import com.ruoyi.common.page.PageResult;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.controller.req.DialoguePageReq;
|
||||
import com.ruoyi.controller.resp.CommentNum;
|
||||
import com.ruoyi.enums.message.InteractionMessageEnums;
|
||||
import com.ruoyi.frequency.customer.service.UserService;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService;
|
||||
import com.ruoyi.post.controller.req.DeleteCommentReq;
|
||||
import com.ruoyi.post.controller.req.PostCommentPageReq;
|
||||
import com.ruoyi.post.controller.req.PostCommentReq;
|
||||
import com.ruoyi.post.controller.resp.PostCommentPageResp;
|
||||
import com.ruoyi.post.controller.resp.PostCommentResp;
|
||||
import com.ruoyi.post.controller.vo.SelectedComment;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.post.frequency.post.mapper.PostMapper;
|
||||
import com.ruoyi.post.frequency.post.service.PostService;
|
||||
import com.ruoyi.post.frequency.postcomment.entity.PostComment;
|
||||
import com.ruoyi.post.frequency.postcomment.mapper.PostCommentMapper;
|
||||
import com.ruoyi.post.frequency.postcomment.service.PostCommentService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.utils.BusinessUtil;
|
||||
import com.ruoyi.vo.UserInfo;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 帖子评论Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostComment> implements PostCommentService {
|
||||
@Autowired
|
||||
private PostCommentMapper postCommentMapper;
|
||||
|
||||
/**
|
||||
* 查询帖子评论
|
||||
*
|
||||
* @param id 帖子评论主键
|
||||
* @return 帖子评论
|
||||
*/
|
||||
@Override
|
||||
public PostComment selectPostCommentById(Long id) {
|
||||
PostComment postComment = postCommentMapper.selectPostCommentById(id);
|
||||
|
||||
if (postComment != null) {
|
||||
Set<UserVo> userVoSet = new HashSet<>();
|
||||
userVoSet.add(new UserVo(postComment.getUserType(), postComment.getUserId()));
|
||||
userVoSet.add(new UserVo(postComment.getParentUserType(), postComment.getParentUserId()));
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, null);
|
||||
|
||||
postComment.setUserInfo(userMap.get(new UserVo(postComment.getUserType(), postComment.getUserId())));
|
||||
postComment.setParentUserInfo(userMap.get(new UserVo(postComment.getParentUserType(), postComment.getParentUserId())));
|
||||
}
|
||||
|
||||
return postComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询帖子评论列表
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 帖子评论
|
||||
*/
|
||||
@Override
|
||||
public List<PostComment> selectPostCommentList(PostComment postComment) {
|
||||
List<PostComment> postComments = postCommentMapper.selectPostCommentList(postComment);
|
||||
|
||||
if (!postComments.isEmpty()) {
|
||||
Set<UserVo> userVoSet = postComments.stream().map(s -> new UserVo(s.getUserType(), s.getUserId())).collect(Collectors.toSet());
|
||||
Set<UserVo> parentUserVoSet = postComments.stream().map(s -> new UserVo(s.getParentUserType(), s.getParentUserId())).collect(Collectors.toSet());
|
||||
|
||||
userVoSet.addAll(parentUserVoSet);
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, null);
|
||||
|
||||
postComments.stream().forEach(s -> {
|
||||
s.setUserInfo(userMap.get(new UserVo(s.getUserType(), s.getUserId())));
|
||||
s.setParentUserInfo(userMap.get(new UserVo(s.getParentUserType(), s.getParentUserId())));
|
||||
});
|
||||
}
|
||||
|
||||
return postComments;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增帖子评论
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPostComment(PostComment postComment) {
|
||||
postComment.setCreateTime(DateUtils.getNowDate());
|
||||
return postCommentMapper.insertPostComment(postComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子评论
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePostComment(PostComment postComment) {
|
||||
postComment.setUpdateTime(DateUtils.getNowDate());
|
||||
return postCommentMapper.updatePostComment(postComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子评论
|
||||
*
|
||||
* @param postCommentList 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePostCommentBatch(List<PostComment> postCommentList) {
|
||||
postCommentList.stream().forEach(postComment -> {
|
||||
postComment.setUpdateTime(DateUtils.getNowDate());
|
||||
});
|
||||
|
||||
return postCommentMapper.updatePostCommentNumBatch(postCommentList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改帖子评论
|
||||
*
|
||||
* @param postComment 帖子评论
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePostCommentLikeNum(PostComment postComment, Integer num) {
|
||||
return postCommentMapper.updatePostCommentLikeNum(postComment.getId(), num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除帖子评论
|
||||
*
|
||||
* @param ids 需要删除的帖子评论主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostCommentByIds(Long[] ids) {
|
||||
this.lambdaUpdate().set(PostComment::getDelFlag, PublicCommon.删除).in(PostComment::getId, ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帖子评论信息
|
||||
*
|
||||
* @param id 帖子评论主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostCommentById(Long id) {
|
||||
this.lambdaUpdate().set(PostComment::getDelFlag, PublicCommon.删除).eq(PostComment::getId, id).update();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private PostService postService;
|
||||
|
||||
@Override
|
||||
public ResponseData postComment(PostCommentReq req, UserVo userVo) {
|
||||
|
||||
//帖子评论
|
||||
PostComment postComment = new PostComment(req, userVo);
|
||||
|
||||
|
||||
//帖子-->评论
|
||||
if (ObjectUtil.isEmpty(req.getParentId()) || ObjectUtil.equal(0L, req.getParentId())) {
|
||||
//顶级评论id
|
||||
postComment.setTopId(postComment.getId());
|
||||
|
||||
Post post = postService.getById(req.getPostId());
|
||||
} else {
|
||||
//查询上级评论
|
||||
PostComment parentPostComment = this.getById(req.getParentId());
|
||||
|
||||
//评论用户
|
||||
postComment.setParentUserId(parentPostComment.getUserId())
|
||||
.setParentUserType(parentPostComment.getUserType());
|
||||
|
||||
postComment.setTopId(parentPostComment.getTopId());
|
||||
|
||||
//上级id
|
||||
if (ObjectUtil.isNotEmpty(parentPostComment.getParentIds())) {
|
||||
postComment.setParentIds(parentPostComment.getParentIds() + "," + parentPostComment.getId());
|
||||
} else {
|
||||
postComment.setParentIds(parentPostComment.getId() + "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.save(postComment);
|
||||
|
||||
//1 帖子 2 帖子评论
|
||||
Integer type = ObjectUtil.equal(0L, req.getParentId()) || ObjectUtil.isEmpty(req.getParentId()) ? 1 : 2;
|
||||
|
||||
//修改评论数(只要针对这个贴子下的评论 帖子评论数都要+1)
|
||||
postMapper.updateNumPost(postComment.getPostId(), PublicCommon.Post.评论数, 1);
|
||||
//修改热度时间
|
||||
postMapper.update(new Post().setTrendsTime(new Date()), new LambdaUpdateWrapper<Post>().eq(Post::getId, postComment.getPostId()));
|
||||
|
||||
//帖子评论 所有上级评论数+1
|
||||
if (ObjectUtil.equal(2, type)) {
|
||||
//上级评论ids
|
||||
List<String> pids = Arrays.stream(postComment.getParentIds().split(",")).collect(Collectors.toList());
|
||||
|
||||
List<PostComment> postComments = pids.stream().map(id -> new PostComment().setId(Long.valueOf(id)).setCommentNum(1)).collect(Collectors.toList());
|
||||
|
||||
this.updatePostCommentBatch(postComments);
|
||||
}
|
||||
|
||||
//返回结果
|
||||
PostCommentResp commentResp = baseMapper.getPostCommentResp(postComment.getId(), userVo);
|
||||
|
||||
if (commentResp != null) {
|
||||
|
||||
UserVo parentUserVo = new UserVo(postComment.getParentUserType(), postComment.getParentUserId());
|
||||
|
||||
Set<UserVo> userVoSet = CollectionUtil.newHashSet(userVo, parentUserVo);
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
|
||||
commentResp.setUserInfo(userMap.get(userVo));
|
||||
|
||||
commentResp.setParentUserInfo(userMap.get(parentUserVo));
|
||||
}
|
||||
|
||||
//给自己的评论不需要推送消息
|
||||
pushMessage(req, userVo, true);
|
||||
return ResponseData.success(commentResp);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private InteractionMessageRecordService interactionMessageRecordService;
|
||||
|
||||
/**
|
||||
* 推送消息
|
||||
*
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @param isPush
|
||||
*/
|
||||
private void pushMessage(PostCommentReq req, UserVo userVo, Boolean isPush) {
|
||||
|
||||
InteractionMessageEnums enums = ObjectUtil.equal(0L, req.getParentId()) ? InteractionMessageEnums.COMMENT_POST : InteractionMessageEnums.REPLY_POST_COMMENT;
|
||||
|
||||
//帖子id
|
||||
Long postId = null;
|
||||
|
||||
//接收消息用户
|
||||
UserVo sendUserVo = null;
|
||||
|
||||
if (ObjectUtil.equal(0L, req.getParentId())) {
|
||||
//评论帖子
|
||||
postId = req.getPostId();
|
||||
//帖子
|
||||
Post post = postService.getById(postId);
|
||||
sendUserVo = new UserVo(post.getUserType(), post.getUserId());
|
||||
} else {
|
||||
//回复评论
|
||||
PostComment postComment = this.getById(req.getParentId());
|
||||
postId = postComment.getPostId();
|
||||
sendUserVo = new UserVo(postComment.getUserType(), postComment.getUserId());
|
||||
}
|
||||
//互动消息
|
||||
interactionMessageRecordService.addInteractionMessage(userVo, sendUserVo, PublicCommon.InteractionMessage.评论, postId, isPush, enums);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData postCommentPage(PostCommentPageReq req, UserVo userVo) {
|
||||
|
||||
//筛去拉黑与被拉黑用户
|
||||
List<UserVo> blockUserList = userService.blockUserList(userVo);
|
||||
req.setBlockUserList(blockUserList);
|
||||
|
||||
//筛去屏蔽用户
|
||||
List<UserVo> shieldUserList = userService.shieldUserList(userVo);
|
||||
req.setShieldUserList(shieldUserList);
|
||||
|
||||
Page<PostCommentPageResp> page = this.baseMapper.postCommentPage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo);
|
||||
|
||||
if (!page.getRecords().isEmpty()) {
|
||||
Set<UserVo> userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet());
|
||||
Set<UserVo> parentUserVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId())).collect(Collectors.toSet());
|
||||
|
||||
userVoSet.addAll(parentUserVoSet);
|
||||
|
||||
List<PostCommentPageResp> postCommentList = twoCommentList(req, userVo, page);
|
||||
|
||||
postCommentList.stream().forEach(postPageResp -> {
|
||||
userVoSet.add(new UserVo(postPageResp.getUserType(), postPageResp.getUserId()));
|
||||
userVoSet.add(new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId()));
|
||||
});
|
||||
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
|
||||
List<UserVo> userVoList = CollectionUtil.addAllIfNotContains(blockUserList, shieldUserList);
|
||||
|
||||
Map<Long, Integer> commentNumMap = getCommentNumMap(userVoList, page.getRecords());
|
||||
|
||||
postCommentList.stream().forEach(resp -> {
|
||||
resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId())));
|
||||
resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId())));
|
||||
});
|
||||
//获取二级评论
|
||||
Map<Long, List<PostCommentPageResp>> map = postCommentList.stream().collect(Collectors.groupingBy(PostCommentPageResp::getParentId));
|
||||
;
|
||||
|
||||
|
||||
page.getRecords().stream().forEach(resp -> {
|
||||
resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId())));
|
||||
resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId())));
|
||||
if (commentNumMap.get(resp.getId()) != null) {
|
||||
resp.setCommentNum(resp.getCommentNum() - commentNumMap.get(resp.getId()));
|
||||
}
|
||||
|
||||
//二级评论
|
||||
resp.setChildrenList(map.get(resp.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
return ResponseData.success(new PageResult<>(page));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二级评论ID
|
||||
*
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
private List<PostCommentPageResp> twoCommentList(PostCommentPageReq req, UserVo userVo, Page<PostCommentPageResp> page) {
|
||||
|
||||
Map<Long, List<PostCommentPageResp>> map = new HashMap<>();
|
||||
|
||||
if (ObjectUtil.isEmpty(req.getParentId())) {
|
||||
//一级评论ID
|
||||
List<Long> parentIds = page.getRecords().stream().map(PostCommentPageResp::getId).collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtil.isEmpty(parentIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//查询二级评论
|
||||
List<PostCommentPageResp> postCommentList = this.baseMapper.postCommentList(req, userVo, parentIds);
|
||||
|
||||
return postCommentList;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private Map<Long, Integer> getCommentNumMap(List<UserVo> userVoList, List<PostCommentPageResp> respList) {
|
||||
|
||||
if (userVoList.size() == 0) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
List<Long> commentIds = respList.stream().map(PostCommentPageResp::getId).collect(Collectors.toList());
|
||||
//查询用户对应评论的数量 key一级评论id value 隐藏数量
|
||||
List<CommentNum> commentNums = postCommentMapper.selectCommentNumList(commentIds, userVoList);
|
||||
|
||||
Map<Long, Integer> commentNumMap = new HashMap<>();
|
||||
commentNums.stream().forEach(s -> {
|
||||
commentNumMap.put(s.getPostId(), s.getCommentNum());
|
||||
});
|
||||
return commentNumMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData deleteComment(DeleteCommentReq req, UserVo userVo) {
|
||||
|
||||
boolean update = this.lambdaUpdate().set(PostComment::getDelFlag, PublicCommon.删除)
|
||||
.eq(PostComment::getUserType, userVo.getUserType())
|
||||
.eq(PostComment::getUserId, userVo.getUserId())
|
||||
.eq(PostComment::getId, req.getId())
|
||||
.eq(PostComment::getDelFlag, PublicCommon.启用).update();
|
||||
|
||||
if (update) {
|
||||
afterDeleteComment(req.getId());
|
||||
}
|
||||
return ResponseData.success();
|
||||
}
|
||||
|
||||
private void afterDeleteComment(Long objectId) {
|
||||
|
||||
PostComment postComment = this.getById(objectId);
|
||||
|
||||
//1 帖子 2 帖子评论
|
||||
Integer type = ObjectUtil.equal(0L, postComment.getParentId()) ? 1 : 2;
|
||||
|
||||
Integer num = -(postComment.getCommentNum() + 1);
|
||||
//帖子评论 上级数量
|
||||
if (ObjectUtil.equal(2, type)) {
|
||||
//当前评论上级ids
|
||||
List<String> pids = Arrays.stream(postComment.getParentIds()
|
||||
.split(",")).collect(Collectors.toList());
|
||||
num = -1 * pids.size();
|
||||
|
||||
//上级评论数都要减去当前删除评论数 + 1(本身评论)
|
||||
List<PostComment> postComments = pids.stream().map(id -> new PostComment().setId(Long.valueOf(id)).setCommentNum(-1 * (postComment.getCommentNum() + 1))).collect(Collectors.toList());
|
||||
|
||||
this.updatePostCommentBatch(postComments);
|
||||
|
||||
}
|
||||
//删除当前评论所有下级评论
|
||||
this.lambdaUpdate().set(PostComment::getDelFlag, PublicCommon.删除)
|
||||
.like(PostComment::getParentIds, objectId)
|
||||
.eq(PostComment::getDelFlag, PublicCommon.启用).update();
|
||||
|
||||
|
||||
//修改评论数
|
||||
postMapper.updateNumPost(postComment.getPostId(), PublicCommon.Post.评论数, num);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int deleteCommentByIds(Long[] ids, Integer delFlag) {
|
||||
|
||||
if (PublicCommon.删除.equals(delFlag)) {
|
||||
for (Long objectId : ids) {
|
||||
afterDeleteComment(objectId);
|
||||
}
|
||||
}
|
||||
|
||||
this.lambdaUpdate().set(PostComment::getDelFlag, delFlag).in(PostComment::getId, ids).update();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private BusinessUtil businessUtil;
|
||||
|
||||
@Override
|
||||
public Map<Long, SelectedComment> getSelectedCommentMap(List<Long> commentIds, UserVo userVo) {
|
||||
|
||||
Map<Long, SelectedComment> map = new HashMap<>();
|
||||
|
||||
if (CollectionUtil.isEmpty(commentIds)) {
|
||||
return map;
|
||||
}
|
||||
|
||||
List<PostComment> postComments = this.lambdaQuery().in(PostComment::getId, commentIds).eq(PostComment::getParentId, 0L).eq(PostComment::getDelFlag, PublicCommon.启用).list();
|
||||
|
||||
Set<UserVo> userVoSet = postComments.stream().map(postComment -> new UserVo(postComment.getUserType(), postComment.getUserId())).collect(Collectors.toSet());
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
|
||||
postComments.stream().forEach(postComment -> {
|
||||
map.put(postComment.getId(), new SelectedComment(2, postComment, userMap.get(new UserVo(postComment.getUserType(), postComment.getUserId()))));
|
||||
});
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, SelectedComment> getSelectedNewCommentMap(List<Long> postIds, UserVo userVo) {
|
||||
Map<Long, SelectedComment> map = new HashMap<>();
|
||||
|
||||
if (CollectionUtil.isEmpty(postIds)) {
|
||||
return map;
|
||||
}
|
||||
|
||||
List<PostComment> postComments = postCommentMapper.selectedNewCommentList(postIds);
|
||||
|
||||
Set<UserVo> userVoSet = postComments.stream().map(postComment -> new UserVo(postComment.getUserType(), postComment.getUserId())).collect(Collectors.toSet());
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
|
||||
postComments.stream().forEach(postComment -> {
|
||||
map.put(postComment.getPostId(), new SelectedComment(1, postComment, userMap.get(new UserVo(postComment.getUserType(), postComment.getUserId()))));
|
||||
});
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private PostMapper postMapper;
|
||||
|
||||
/**
|
||||
* 修改评论数
|
||||
*
|
||||
* @param objectId 评论主体id
|
||||
* @param type 1帖子 2 帖子评论
|
||||
* @param num
|
||||
*/
|
||||
private void updatePostCommentNum(Long objectId, Integer type, Integer num) {
|
||||
|
||||
switch (type) {
|
||||
case 1:
|
||||
postMapper.updateNumPost(objectId, PublicCommon.Post.评论数, num);
|
||||
break;
|
||||
case 2:
|
||||
this.updatePostComment(new PostComment().setId(objectId).setCommentNum(num));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseData<PostCommentResp> postCommentDetail(Long id, UserVo userVo) {
|
||||
//返回结果
|
||||
PostCommentResp commentResp = baseMapper.getPostCommentResp(id, userVo);
|
||||
|
||||
if (commentResp != null) {
|
||||
|
||||
UserVo parentUserVo = new UserVo(commentResp.getParentUserType(), commentResp.getParentUserId());
|
||||
UserVo user = new UserVo(commentResp.getUserType(), commentResp.getUserId());
|
||||
|
||||
Set<UserVo> userVoSet = CollectionUtil.newHashSet(user, parentUserVo);
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
|
||||
commentResp.setUserInfo(userMap.get(user));
|
||||
|
||||
commentResp.setParentUserInfo(userMap.get(parentUserVo));
|
||||
}
|
||||
|
||||
return ResponseData.success(commentResp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData<PageResult<Page<PostCommentPageResp>>> postCommentDialoguePage(DialoguePageReq req, UserVo userVo) {
|
||||
Page<PostCommentPageResp> page = this.baseMapper.postCommentDialoguePage(new Page<>(req.getPageNo(), req.getPageSize()), req, userVo);
|
||||
|
||||
if (!page.getRecords().isEmpty()) {
|
||||
Set<UserVo> userVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getUserType(), postPageResp.getUserId())).collect(Collectors.toSet());
|
||||
Set<UserVo> parentUserVoSet = page.getRecords().stream().map(postPageResp -> new UserVo(postPageResp.getParentUserType(), postPageResp.getParentUserId())).collect(Collectors.toSet());
|
||||
|
||||
userVoSet.addAll(parentUserVoSet);
|
||||
|
||||
//查询用户信息
|
||||
Map<UserVo, UserInfo> userMap = userService.selectUserInfoMap(userVoSet, userVo);
|
||||
|
||||
page.getRecords().stream().forEach(resp -> {
|
||||
resp.setUserInfo(userMap.get(new UserVo(resp.getUserType(), resp.getUserId())));
|
||||
resp.setParentUserInfo(userMap.get(new UserVo(resp.getParentUserType(), resp.getParentUserId())));
|
||||
});
|
||||
}
|
||||
|
||||
return ResponseData.success(new PageResult<>(page));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.post.frequency.postlike.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.post.frequency.postlike.entity.PostLike;
|
||||
import com.ruoyi.post.frequency.postlike.service.PostLikeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子点赞Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/poslike")
|
||||
public class PostLikeController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private PostLikeService postLikeService;
|
||||
|
||||
/**
|
||||
* 查询帖子点赞列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poslike:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo<PostLike> list(@RequestBody PostLike postLike)
|
||||
{
|
||||
startPage();
|
||||
List<PostLike> list = postLikeService.selectPostLikeList(postLike);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出帖子点赞列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poslike:export')")
|
||||
@Log(title = "帖子点赞", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(PostLike postLike)
|
||||
{
|
||||
List<PostLike> list = postLikeService.selectPostLikeList(postLike);
|
||||
ExcelUtil<PostLike> util = new ExcelUtil<PostLike>(PostLike.class);
|
||||
return util.exportExcel(list, "帖子点赞数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帖子点赞详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poslike:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<PostLike> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(postLikeService.selectPostLikeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增帖子点赞
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poslike:add')")
|
||||
@Log(title = "帖子点赞", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PostLike postLike)
|
||||
{
|
||||
return toAjax(postLikeService.insertPostLike(postLike));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子点赞
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poslike:edit')")
|
||||
@Log(title = "帖子点赞", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PostLike postLike)
|
||||
{
|
||||
return toAjax(postLikeService.updatePostLike(postLike));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帖子点赞
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:poslike:remove')")
|
||||
@Log(title = "帖子点赞", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(postLikeService.deletePostLikeByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.ruoyi.post.frequency.postlike.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.utils.SnowIdUtils;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子点赞对象 t_post_like
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_post_like")
|
||||
public class PostLike extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("类型 1 帖子2 帖子评论 ")
|
||||
@Excel(name = "类型 1 帖子2 帖子评论 ")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("用户类型 1 用户 ")
|
||||
@Excel(name = "用户类型 1 用户 ")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("帖子id/帖子评论id")
|
||||
@Excel(name = "帖子id/帖子评论id")
|
||||
private Long objectId;
|
||||
|
||||
|
||||
public PostLike() {
|
||||
}
|
||||
|
||||
public PostLike(Integer type, Long objectId) {
|
||||
this.id = SnowIdUtils.uniqueLong();
|
||||
this.type = type;
|
||||
this.objectId = objectId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.ruoyi.post.frequency.postlike.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.post.frequency.postlike.entity.PostLike;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子点赞Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
public interface PostLikeMapper extends BaseMapper<PostLike>
|
||||
{
|
||||
/**
|
||||
* 查询帖子点赞
|
||||
*
|
||||
* @param id 帖子点赞主键
|
||||
* @return 帖子点赞
|
||||
*/
|
||||
public PostLike selectPostLikeById(Long id);
|
||||
|
||||
/**
|
||||
* 查询帖子点赞列表
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 帖子点赞集合
|
||||
*/
|
||||
public List<PostLike> selectPostLikeList(PostLike postLike);
|
||||
|
||||
/**
|
||||
* 新增帖子点赞
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostLike(PostLike postLike);
|
||||
|
||||
/**
|
||||
* 修改帖子点赞
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostLike(PostLike postLike);
|
||||
|
||||
/**
|
||||
* 删除帖子点赞
|
||||
*
|
||||
* @param id 帖子点赞主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostLikeById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除帖子点赞
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostLikeByIds(Long[] ids);
|
||||
|
||||
|
||||
/**
|
||||
* 帖子点赞
|
||||
* @param postLike
|
||||
* @param userVo
|
||||
*/
|
||||
void postLike(@Param("req") PostLike postLike,@Param("userVo") UserVo userVo);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?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.ruoyi.post.frequency.postlike.mapper.PostLikeMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.post.frequency.postlike.entity.PostLike" id="PostLikeResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="type" column="type" />
|
||||
<result property="userType" column="user_type" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="objectId" column="object_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPostLikeVo">
|
||||
select id, create_by, create_time, update_by, update_time, del_flag, type, user_type, user_id, object_id from t_post_like
|
||||
</sql>
|
||||
|
||||
<select id="selectPostLikeList" parameterType="com.ruoyi.post.frequency.postlike.entity.PostLike" resultMap="PostLikeResult">
|
||||
<include refid="selectPostLikeVo"/>
|
||||
<where>
|
||||
<if test="type != null "> and type = #{type}</if>
|
||||
<if test="userType != null "> and user_type = #{userType}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="objectId != null "> and object_id = #{objectId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPostLikeById" parameterType="Long" resultMap="PostLikeResult">
|
||||
<include refid="selectPostLikeVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPostLike" parameterType="com.ruoyi.post.frequency.postlike.entity.PostLike">
|
||||
insert into t_post_like
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="userType != null">user_type,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="objectId != null">object_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="userType != null">#{userType},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="objectId != null">#{objectId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePostLike" parameterType="com.ruoyi.post.frequency.postlike.entity.PostLike">
|
||||
update t_post_like
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="userType != null">user_type = #{userType},</if>
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="objectId != null">object_id = #{objectId},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePostLikeById" parameterType="Long">
|
||||
delete from t_post_like where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePostLikeByIds" parameterType="String">
|
||||
delete from t_post_like where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="postLike" parameterType="com.ruoyi.post.controller.req.PostLikeReq">
|
||||
insert into t_post_like
|
||||
(id, create_by, create_time, update_by, update_time, type, user_type, user_id, object_id)
|
||||
values
|
||||
(#{req.id},#{req.updateBy},#{req.updateTime},#{req.updateBy},#{req.updateTime},#{req.type},#{userVo.userType}, #{userVo.userId}, #{req.objectId})
|
||||
ON DUPLICATE KEY UPDATE
|
||||
del_flag = IF( del_flag = 1, 3, 1 ),
|
||||
update_time = #{req.updateTime},
|
||||
update_by = #{req.updateBy};
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ruoyi.post.frequency.postlike.model.param;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子点赞对象 t_post_like
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostLikeParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("类型 1 帖子2 帖子评论 ")
|
||||
@Excel(name = "类型 1 帖子2 帖子评论 ")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("用户类型 1 用户 ")
|
||||
@Excel(name = "用户类型 1 用户 ")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("帖子id/帖子评论id")
|
||||
@Excel(name = "帖子id/帖子评论id")
|
||||
private Long objectId;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.ruoyi.post.frequency.postlike.model.result;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子点赞对象 t_post_like
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostLikeResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标志 1正常 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("类型 1 帖子2 帖子评论 ")
|
||||
@Excel(name = "类型 1 帖子2 帖子评论 ")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("用户类型 1 用户 ")
|
||||
@Excel(name = "用户类型 1 用户 ")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
@Excel(name = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("帖子id/帖子评论id")
|
||||
@Excel(name = "帖子id/帖子评论id")
|
||||
private Long objectId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.ruoyi.post.frequency.postlike.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.post.controller.req.PostLikeReq;
|
||||
import com.ruoyi.post.frequency.postlike.entity.PostLike;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子点赞Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
public interface PostLikeService extends IService<PostLike>
|
||||
{
|
||||
/**
|
||||
* 查询帖子点赞
|
||||
*
|
||||
* @param id 帖子点赞主键
|
||||
* @return 帖子点赞
|
||||
*/
|
||||
public PostLike selectPostLikeById(Long id);
|
||||
|
||||
/**
|
||||
* 查询帖子点赞列表
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 帖子点赞集合
|
||||
*/
|
||||
public List<PostLike> selectPostLikeList(PostLike postLike);
|
||||
|
||||
/**
|
||||
* 新增帖子点赞
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostLike(PostLike postLike);
|
||||
|
||||
/**
|
||||
* 修改帖子点赞
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostLike(PostLike postLike);
|
||||
|
||||
/**
|
||||
* 批量删除帖子点赞
|
||||
*
|
||||
* @param ids 需要删除的帖子点赞主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostLikeByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除帖子点赞信息
|
||||
*
|
||||
* @param id 帖子点赞主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostLikeById(Long id);
|
||||
|
||||
/**
|
||||
* 帖子点赞
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @return
|
||||
*/
|
||||
ResponseData postLike(PostLikeReq req, UserVo userVo);
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.ruoyi.post.frequency.postlike.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.code.DictConstant;
|
||||
import com.ruoyi.code.PublicCommon;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.enums.message.InteractionMessageEnums;
|
||||
import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService;
|
||||
import com.ruoyi.post.controller.req.PostLikeReq;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.post.frequency.post.service.PostService;
|
||||
import com.ruoyi.post.frequency.postcomment.entity.PostComment;
|
||||
import com.ruoyi.post.frequency.postcomment.service.PostCommentService;
|
||||
import com.ruoyi.post.frequency.postlike.entity.PostLike;
|
||||
import com.ruoyi.post.frequency.postlike.mapper.PostLikeMapper;
|
||||
import com.ruoyi.post.frequency.postlike.service.PostLikeService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import com.ruoyi.utils.BusinessUtil;
|
||||
import com.ruoyi.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子点赞Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-09
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PostLikeServiceImpl extends ServiceImpl<PostLikeMapper, PostLike> implements PostLikeService {
|
||||
@Autowired
|
||||
private PostLikeMapper postLikeMapper;
|
||||
|
||||
/**
|
||||
* 查询帖子点赞
|
||||
*
|
||||
* @param id 帖子点赞主键
|
||||
* @return 帖子点赞
|
||||
*/
|
||||
@Override
|
||||
public PostLike selectPostLikeById(Long id) {
|
||||
return postLikeMapper.selectPostLikeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询帖子点赞列表
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 帖子点赞
|
||||
*/
|
||||
@Override
|
||||
public List<PostLike> selectPostLikeList(PostLike postLike) {
|
||||
return postLikeMapper.selectPostLikeList(postLike);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增帖子点赞
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPostLike(PostLike postLike) {
|
||||
postLike.setCreateTime(DateUtils.getNowDate());
|
||||
return postLikeMapper.insertPostLike(postLike);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子点赞
|
||||
*
|
||||
* @param postLike 帖子点赞
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePostLike(PostLike postLike) {
|
||||
postLike.setUpdateTime(DateUtils.getNowDate());
|
||||
return postLikeMapper.updatePostLike(postLike);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除帖子点赞
|
||||
*
|
||||
* @param ids 需要删除的帖子点赞主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostLikeByIds(Long[] ids) {
|
||||
this.lambdaUpdate().set(PostLike::getDelFlag, PublicCommon.删除).in(PostLike::getId, ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帖子点赞信息
|
||||
*
|
||||
* @param id 帖子点赞主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostLikeById(Long id) {
|
||||
this.lambdaUpdate().set(PostLike::getDelFlag, PublicCommon.删除).eq(PostLike::getId, id).update();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private PostService postService;
|
||||
|
||||
@Autowired
|
||||
private PostCommentService postCommentService;
|
||||
|
||||
@Autowired
|
||||
private BusinessUtil businessUtil;
|
||||
|
||||
@Override
|
||||
public ResponseData postLike(PostLikeReq req, UserVo userVo) {
|
||||
|
||||
PostLike postLike = new PostLike(req.getType(), req.getObjectId());
|
||||
|
||||
//更新帖子点赞记录
|
||||
postLikeMapper.postLike(postLike, userVo);
|
||||
|
||||
postLike = postLikeMapper.selectOne(new QueryWrapper<PostLike>().lambda()
|
||||
.eq(PostLike::getObjectId, req.getObjectId())
|
||||
.eq(PostLike::getType, req.getType())
|
||||
.eq(PostLike::getUserType, userVo.getUserType())
|
||||
.eq(PostLike::getUserId, userVo.getUserId()));
|
||||
|
||||
//是否点赞
|
||||
Boolean isLike = postLike.getDelFlag().equals(PublicCommon.启用);
|
||||
|
||||
//1 帖子 2帖子评论
|
||||
updatePostLikeNum(req.getType(), req.getObjectId(), isLike);
|
||||
|
||||
//精彩评论 1 帖子 2 帖子评论
|
||||
if (isLike && req.getType() == 2) {
|
||||
//点赞量基础量(超过)
|
||||
Integer likeNum = Integer.valueOf(businessUtil.getDict(DictConstant.点赞好评基础量).getDictValue());
|
||||
|
||||
PostComment postComment = postCommentService.getById(req.getObjectId());
|
||||
|
||||
Post post = postService.getById(postComment.getPostId());
|
||||
|
||||
if (ObjectUtil.isEmpty(post.getCommentId()) && postComment.getParentId() == 0L && postComment.getLikeNum() >= likeNum) {
|
||||
postService.lambdaUpdate().set(Post::getCommentId, postComment.getId())
|
||||
.eq(Post::getId, postComment.getPostId()).update();
|
||||
}
|
||||
}
|
||||
|
||||
//推送消息
|
||||
pushMessage(req, userVo, isLike);
|
||||
return ResponseData.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送消息
|
||||
*
|
||||
* @param req
|
||||
* @param userVo
|
||||
* @param isLike
|
||||
*/
|
||||
private void pushMessage(PostLikeReq req, UserVo userVo, Boolean isLike) {
|
||||
|
||||
InteractionMessageEnums enums = ObjectUtil.equal(1, req.getType()) ? InteractionMessageEnums.LIKE_POST : InteractionMessageEnums.LIKE_POST_COMMENT;
|
||||
|
||||
//帖子id
|
||||
Long postId = null;
|
||||
|
||||
//接收消息用户
|
||||
UserVo sendUserVo = null;
|
||||
|
||||
switch (req.getType()) {
|
||||
case 1:
|
||||
//帖子点赞
|
||||
postId = req.getObjectId();
|
||||
Post post = postService.getById(postId);
|
||||
sendUserVo = new UserVo(post.getUserType(), post.getUserId());
|
||||
break;
|
||||
case 2:
|
||||
//评论点赞
|
||||
PostComment postComment = postCommentService.getById(req.getObjectId());
|
||||
postId = postComment.getPostId();
|
||||
sendUserVo = new UserVo(postComment.getUserType(), postComment.getUserId());
|
||||
break;
|
||||
}
|
||||
|
||||
//互动消息
|
||||
interactionMessageRecordService.addInteractionMessage(userVo, sendUserVo, PublicCommon.InteractionMessage.点赞, postId, isLike, enums);
|
||||
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private InteractionMessageRecordService interactionMessageRecordService;
|
||||
|
||||
|
||||
/**
|
||||
* 更新帖子点赞数据
|
||||
*
|
||||
* @param type 1 帖子 2帖子评论
|
||||
* @param objectId 帖子id/评论id
|
||||
* @param isLike 是否点赞
|
||||
*/
|
||||
private void updatePostLikeNum(Integer type, Long objectId, Boolean isLike) {
|
||||
|
||||
//点赞 +1 ,取消点赞 -1
|
||||
Integer num = isLike ? 1 : -1;
|
||||
|
||||
switch (type) {
|
||||
case 1:
|
||||
postService.updatePostLikeNum(new Post().setId(objectId), num);
|
||||
break;
|
||||
case 2:
|
||||
postCommentService.updatePostComment(new PostComment().setId(objectId).setLikeNum(num));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.ruoyi.post.frequency.posttype.controller;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.post.frequency.posttype.entity.PostType;
|
||||
import com.ruoyi.post.frequency.posttype.service.PostTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子分类Controller
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/frequency/postype")
|
||||
public class PostTypeController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private PostTypeService postTypeService;
|
||||
|
||||
/**
|
||||
* 查询帖子分类列表
|
||||
*/
|
||||
// @PreAuthorize("@ss.hasPermi('frequency:postype:list')")
|
||||
@PostMapping("/list")
|
||||
public TableDataInfo<PostType> list(@RequestBody PostType postType)
|
||||
{
|
||||
startPage();
|
||||
List<PostType> list = postTypeService.selectPostTypeList(postType);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出帖子分类列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:postype:export')")
|
||||
@Log(title = "帖子分类", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(PostType postType)
|
||||
{
|
||||
List<PostType> list = postTypeService.selectPostTypeList(postType);
|
||||
ExcelUtil<PostType> util = new ExcelUtil<PostType>(PostType.class);
|
||||
return util.exportExcel(list, "帖子分类数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帖子分类详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:postype:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult<PostType> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(postTypeService.selectPostTypeById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增帖子分类
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:postype:add')")
|
||||
@Log(title = "帖子分类", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PostType postType)
|
||||
{
|
||||
return toAjax(postTypeService.insertPostType(postType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子分类
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:postype:edit')")
|
||||
@Log(title = "帖子分类", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PostType postType)
|
||||
{
|
||||
return toAjax(postTypeService.updatePostType(postType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帖子分类
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('frequency:postype:remove')")
|
||||
@Log(title = "帖子分类", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}/{delFlag}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids,@PathVariable Integer delFlag)
|
||||
{
|
||||
return toAjax(postTypeService.deletePostTypeByIds(ids,delFlag));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.ruoyi.post.frequency.posttype.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子分类对象 t_post_type
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-10
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_post_type")
|
||||
public class PostType extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标识 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("分类名称")
|
||||
@Excel(name = "分类名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
@Excel(name = "排序")
|
||||
private Long sort;
|
||||
|
||||
@ApiModelProperty("用户类型")
|
||||
private Integer userType;
|
||||
|
||||
@ApiModelProperty("帖子类型 1 帖子 2资讯")
|
||||
private Integer type;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.post.frequency.posttype.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.post.frequency.posttype.entity.PostType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子分类Mapper接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-10
|
||||
*/
|
||||
public interface PostTypeMapper extends BaseMapper<PostType>
|
||||
{
|
||||
/**
|
||||
* 查询帖子分类
|
||||
*
|
||||
* @param id 帖子分类主键
|
||||
* @return 帖子分类
|
||||
*/
|
||||
public PostType selectPostTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 查询帖子分类列表
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 帖子分类集合
|
||||
*/
|
||||
public List<PostType> selectPostTypeList(PostType postType);
|
||||
|
||||
/**
|
||||
* 新增帖子分类
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostType(PostType postType);
|
||||
|
||||
/**
|
||||
* 修改帖子分类
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostType(PostType postType);
|
||||
|
||||
/**
|
||||
* 删除帖子分类
|
||||
*
|
||||
* @param id 帖子分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除帖子分类
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostTypeByIds(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?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.ruoyi.post.frequency.posttype.mapper.PostTypeMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.post.frequency.posttype.entity.PostType" id="PostTypeResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="name" column="name" />
|
||||
<result property="sort" column="sort" />
|
||||
<result property="userType" column="user_type" />
|
||||
<result property="type" column="type" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPostTypeVo">
|
||||
select id, del_flag, create_by, create_time, update_by, update_time, name, sort,user_type,type from t_post_type
|
||||
</sql>
|
||||
|
||||
<select id="selectPostTypeList" parameterType="com.ruoyi.post.frequency.posttype.entity.PostType" resultMap="PostTypeResult">
|
||||
<include refid="selectPostTypeVo"/>
|
||||
<where> and del_flag != 2
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="sort != null "> and sort = #{sort}</if>
|
||||
<if test="userType != null "> and user_type = #{userType}</if>
|
||||
<if test="type != null "> and type = #{type}</if>
|
||||
</where>
|
||||
order by sort
|
||||
</select>
|
||||
|
||||
<select id="selectPostTypeById" parameterType="Long" resultMap="PostTypeResult">
|
||||
<include refid="selectPostTypeVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPostType" parameterType="com.ruoyi.post.frequency.posttype.entity.PostType">
|
||||
insert into t_post_type
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="sort != null">sort,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="sort != null">#{sort},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePostType" parameterType="com.ruoyi.post.frequency.posttype.entity.PostType">
|
||||
update t_post_type
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="sort != null">sort = #{sort},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePostTypeById" parameterType="Long">
|
||||
delete from t_post_type where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePostTypeByIds" parameterType="String">
|
||||
delete from t_post_type where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.ruoyi.post.frequency.posttype.model.param;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子分类对象 t_post_type
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-10
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostTypeParam extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标识 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("分类名称")
|
||||
@Excel(name = "分类名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
@Excel(name = "排序")
|
||||
private Long sort;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.post.frequency.posttype.model.result;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 帖子分类对象 t_post_type
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-10
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PostTypeResult extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("租户号")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("删除标识 1 正常 2 删除 3 禁用")
|
||||
private Integer delFlag;
|
||||
|
||||
@ApiModelProperty("分类名称")
|
||||
@Excel(name = "分类名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
@Excel(name = "排序")
|
||||
private Long sort;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.post.frequency.posttype.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.post.controller.req.PostTypeListReq;
|
||||
import com.ruoyi.post.frequency.posttype.entity.PostType;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 帖子分类Service接口
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-10
|
||||
*/
|
||||
public interface PostTypeService extends IService<PostType>
|
||||
{
|
||||
/**
|
||||
* 查询帖子分类
|
||||
*
|
||||
* @param id 帖子分类主键
|
||||
* @return 帖子分类
|
||||
*/
|
||||
public PostType selectPostTypeById(Long id);
|
||||
|
||||
/**
|
||||
* 查询帖子分类列表
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 帖子分类集合
|
||||
*/
|
||||
public List<PostType> selectPostTypeList(PostType postType);
|
||||
|
||||
/**
|
||||
* 新增帖子分类
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPostType(PostType postType);
|
||||
|
||||
/**
|
||||
* 修改帖子分类
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePostType(PostType postType);
|
||||
|
||||
/**
|
||||
* 批量删除帖子分类
|
||||
*
|
||||
* @param ids 需要删除的帖子分类主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostTypeByIds(Long[] ids,Integer delFlag);
|
||||
|
||||
/**
|
||||
* 删除帖子分类信息
|
||||
*
|
||||
* @param id 帖子分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostTypeById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 获取帖子分类列表
|
||||
* @return
|
||||
*/
|
||||
ResponseData postTypeList(PostTypeListReq req);
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.ruoyi.post.frequency.posttype.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.code.PublicCommon;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.post.controller.req.PostTypeListReq;
|
||||
import com.ruoyi.post.frequency.post.entity.Post;
|
||||
import com.ruoyi.post.frequency.post.service.PostService;
|
||||
import com.ruoyi.post.frequency.posttype.entity.PostType;
|
||||
import com.ruoyi.post.frequency.posttype.mapper.PostTypeMapper;
|
||||
import com.ruoyi.post.frequency.posttype.service.PostTypeService;
|
||||
import com.ruoyi.response.ResponseData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.sf.jsqlparser.util.validation.metadata.NamedObject.user;
|
||||
|
||||
/**
|
||||
* 帖子分类Service业务层处理
|
||||
*
|
||||
* @author liwenlong
|
||||
* @date 2023-10-10
|
||||
*/
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PostTypeServiceImpl extends ServiceImpl<PostTypeMapper, PostType> implements PostTypeService
|
||||
{
|
||||
@Autowired
|
||||
private PostTypeMapper postTypeMapper;
|
||||
|
||||
/**
|
||||
* 查询帖子分类
|
||||
*
|
||||
* @param id 帖子分类主键
|
||||
* @return 帖子分类
|
||||
*/
|
||||
@Override
|
||||
public PostType selectPostTypeById(Long id)
|
||||
{
|
||||
return postTypeMapper.selectPostTypeById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询帖子分类列表
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 帖子分类
|
||||
*/
|
||||
@Override
|
||||
public List<PostType> selectPostTypeList(PostType postType)
|
||||
{
|
||||
return postTypeMapper.selectPostTypeList(postType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增帖子分类
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPostType(PostType postType)
|
||||
{
|
||||
postType.setCreateTime(DateUtils.getNowDate());
|
||||
return postTypeMapper.insert(postType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帖子分类
|
||||
*
|
||||
* @param postType 帖子分类
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePostType(PostType postType)
|
||||
{
|
||||
postType.setUpdateTime(DateUtils.getNowDate());
|
||||
return postTypeMapper.updateById(postType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除帖子分类
|
||||
*
|
||||
* @param ids 需要删除的帖子分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostTypeByIds(Long[] ids,Integer delFlag)
|
||||
{
|
||||
this.lambdaUpdate().set(PostType::getDelFlag,delFlag).in(PostType::getId,ids).update();
|
||||
return ids.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帖子分类信息
|
||||
*
|
||||
* @param id 帖子分类主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostTypeById(Long id)
|
||||
{
|
||||
this.lambdaUpdate().set(PostType::getDelFlag,PublicCommon.删除).eq(PostType::getId,id).update();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseData postTypeList(PostTypeListReq req) {
|
||||
|
||||
List<PostType> list = this.list(new QueryWrapper<PostType>().lambda()
|
||||
.eq(ObjectUtil.isNotEmpty(req.getUserType()),PostType::getUserType,req.getUserType())
|
||||
.eq(ObjectUtil.isNotEmpty(req.getType()),PostType::getType,req.getType())
|
||||
.eq(PostType::getDelFlag,PublicCommon.启用).orderByAsc(PostType::getSort));
|
||||
|
||||
return ResponseData.success(list);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user