fix comment page
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
package com.imyeyu.api.modules.blog.entity;
|
package com.imyeyu.api.modules.blog.entity;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyView;
|
import com.imyeyu.api.modules.common.entity.CommentReply;
|
||||||
import com.imyeyu.spring.annotation.table.AutoUUID;
|
import com.imyeyu.spring.annotation.table.AutoUUID;
|
||||||
import com.imyeyu.spring.annotation.table.Id;
|
import com.imyeyu.spring.annotation.table.Id;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -32,5 +32,5 @@ public class CommentRemindQueue {
|
|||||||
|
|
||||||
private Long replyId;
|
private Long replyId;
|
||||||
|
|
||||||
private CommentReplyView reply;
|
private CommentReply reply;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,12 +37,16 @@ public class CommentRemindQueueServiceImplement extends AbstractEntityService<Co
|
|||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void destroyByUserId(Long userId) {
|
public void destroyByUserId(Long userId) {
|
||||||
mapper.destroyByUserId(userId);
|
CommentRemindQueue example = new CommentRemindQueue();
|
||||||
|
example.setUserId(userId);
|
||||||
|
mapper.deleteAllByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void destroyByReplyId(Long replyId) {
|
public void destroyByReplyId(Long replyId) {
|
||||||
mapper.destroyByReplyId(replyId);
|
CommentRemindQueue example = new CommentRemindQueue();
|
||||||
|
example.setReplyId(replyId);
|
||||||
|
mapper.destroyAllByExample(example);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,13 +8,10 @@ import com.imyeyu.api.modules.common.entity.Comment;
|
|||||||
import com.imyeyu.api.modules.common.entity.CommentReply;
|
import com.imyeyu.api.modules.common.entity.CommentReply;
|
||||||
import com.imyeyu.api.modules.common.service.CommentReplyService;
|
import com.imyeyu.api.modules.common.service.CommentReplyService;
|
||||||
import com.imyeyu.api.modules.common.service.CommentService;
|
import com.imyeyu.api.modules.common.service.CommentService;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyPage;
|
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyView;
|
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentView;
|
|
||||||
import com.imyeyu.api.modules.git.vo.issue.CommentPage;
|
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
import com.imyeyu.spring.bean.CaptchaData;
|
import com.imyeyu.spring.bean.CaptchaData;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -51,8 +48,8 @@ public class CommentController {
|
|||||||
|
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public PageResult<CommentView> list(@Valid @RequestBody CommentPage commentPage) {
|
public PageResult<Comment> list(@Valid @RequestBody Page<Comment> page) {
|
||||||
return service.pageByBizId(commentPage);
|
return service.page(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,9 +74,14 @@ public class CommentController {
|
|||||||
*/
|
*/
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequestMapping("/reply/list")
|
@RequestMapping("/reply/list")
|
||||||
public PageResult<CommentReplyView> pageCommentReplies(@Valid @RequestBody CommentReplyPage page) {
|
public PageResult<CommentReply> pageReplies(@Valid @RequestBody Page<CommentReply> page) {
|
||||||
// 通用接口,只允许查询评论的回复
|
// 通用接口,只允许查询评论的回复
|
||||||
page.setBizType(CommentReplyPage.BizType.COMMENT);
|
CommentReply example = new CommentReply();
|
||||||
return replyService.pageByBizType(page);
|
if (page.getEqualsExample() != null) {
|
||||||
|
example.setCommentId(page.getEqualsExample().getCommentId());
|
||||||
|
}
|
||||||
|
page.setEqualsExample(example);
|
||||||
|
page.setLikesExample(null);
|
||||||
|
return replyService.page(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,12 +11,14 @@ import com.imyeyu.api.modules.common.entity.Task;
|
|||||||
import com.imyeyu.api.modules.common.entity.Template;
|
import com.imyeyu.api.modules.common.entity.Template;
|
||||||
import com.imyeyu.api.modules.common.entity.Version;
|
import com.imyeyu.api.modules.common.entity.Version;
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
|
import com.imyeyu.api.modules.common.service.ClipboardService;
|
||||||
import com.imyeyu.api.modules.common.service.FeedbackService;
|
import com.imyeyu.api.modules.common.service.FeedbackService;
|
||||||
import com.imyeyu.api.modules.common.service.SettingService;
|
import com.imyeyu.api.modules.common.service.SettingService;
|
||||||
import com.imyeyu.api.modules.common.service.TaskService;
|
import com.imyeyu.api.modules.common.service.TaskService;
|
||||||
import com.imyeyu.api.modules.common.service.TempFileService;
|
import com.imyeyu.api.modules.common.service.TempFileService;
|
||||||
import com.imyeyu.api.modules.common.service.TemplateService;
|
import com.imyeyu.api.modules.common.service.TemplateService;
|
||||||
import com.imyeyu.api.modules.common.service.VersionService;
|
import com.imyeyu.api.modules.common.service.VersionService;
|
||||||
|
import com.imyeyu.api.modules.common.vo.ClipboardRequest;
|
||||||
import com.imyeyu.api.modules.common.vo.FeedbackRequest;
|
import com.imyeyu.api.modules.common.vo.FeedbackRequest;
|
||||||
import com.imyeyu.api.modules.common.vo.TempFileResponse;
|
import com.imyeyu.api.modules.common.vo.TempFileResponse;
|
||||||
import com.imyeyu.api.modules.system.util.ResourceHandler;
|
import com.imyeyu.api.modules.system.util.ResourceHandler;
|
||||||
@ -45,6 +47,7 @@ import lombok.Cleanup;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.tika.Tika;
|
import org.apache.tika.Tika;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.data.mongodb.gridfs.GridFsResource;
|
import org.springframework.data.mongodb.gridfs.GridFsResource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -55,6 +58,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@ -89,6 +93,7 @@ public class CommonController {
|
|||||||
private final TemplateService templateService;
|
private final TemplateService templateService;
|
||||||
private final TempFileService tempFileService;
|
private final TempFileService tempFileService;
|
||||||
private final AttachmentService attachmentService;
|
private final AttachmentService attachmentService;
|
||||||
|
private final ClipboardService clipboardService;
|
||||||
|
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
private final Yaml yaml;
|
private final Yaml yaml;
|
||||||
@ -102,6 +107,45 @@ public class CommonController {
|
|||||||
return "IT WORKING! " + TimiSpring.getRequestIP();
|
return "IT WORKING! " + TimiSpring.getRequestIP();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取共享剪切板内容
|
||||||
|
*
|
||||||
|
* @param id 会话 ID
|
||||||
|
* @return 剪切板内容
|
||||||
|
*/
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@GetMapping("/clipboard/{id}")
|
||||||
|
public String clipboardGet(@Valid @NotBlank @PathVariable("id") String id) {
|
||||||
|
return clipboardService.getContent(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置共享剪切板内容
|
||||||
|
*
|
||||||
|
* @param id 会话 ID
|
||||||
|
* @param request 请求内容
|
||||||
|
*/
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@PostMapping("/clipboard/{id}")
|
||||||
|
public void clipboardSet(@Valid @NotBlank @PathVariable("id") String id, @Valid @RequestBody ClipboardRequest request) {
|
||||||
|
clipboardService.setContent(id, request.getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订阅共享剪切板实时更新
|
||||||
|
*
|
||||||
|
* @param id 会话 ID
|
||||||
|
* @return SSE 发射器
|
||||||
|
*/
|
||||||
|
@AOPLog
|
||||||
|
@IgnoreGlobalReturn
|
||||||
|
@GetMapping(value = "/clipboard/stream/{id}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||||
|
public SseEmitter clipboardStream(@Valid @NotBlank @PathVariable("id") String id) {
|
||||||
|
return clipboardService.subscribe(id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取验证码
|
* 获取验证码
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
package com.imyeyu.api.modules.common.controller;
|
package com.imyeyu.api.modules.common.controller;
|
||||||
|
|
||||||
import com.imyeyu.java.TimiJava;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
|
||||||
import com.imyeyu.api.annotation.CaptchaValid;
|
import com.imyeyu.api.annotation.CaptchaValid;
|
||||||
import com.imyeyu.api.annotation.EnableSetting;
|
import com.imyeyu.api.annotation.EnableSetting;
|
||||||
import com.imyeyu.api.bean.CaptchaFrom;
|
import com.imyeyu.api.bean.CaptchaFrom;
|
||||||
import com.imyeyu.api.modules.common.bean.SettingKey;
|
import com.imyeyu.api.modules.common.bean.SettingKey;
|
||||||
|
import com.imyeyu.api.modules.common.entity.Comment;
|
||||||
import com.imyeyu.api.modules.common.entity.CommentReply;
|
import com.imyeyu.api.modules.common.entity.CommentReply;
|
||||||
import com.imyeyu.api.modules.common.entity.UserConfig;
|
import com.imyeyu.api.modules.common.entity.UserConfig;
|
||||||
import com.imyeyu.api.modules.common.entity.UserPrivacy;
|
import com.imyeyu.api.modules.common.entity.UserPrivacy;
|
||||||
@ -15,10 +14,6 @@ import com.imyeyu.api.modules.common.service.UserConfigService;
|
|||||||
import com.imyeyu.api.modules.common.service.UserPrivacyService;
|
import com.imyeyu.api.modules.common.service.UserPrivacyService;
|
||||||
import com.imyeyu.api.modules.common.service.UserProfileService;
|
import com.imyeyu.api.modules.common.service.UserProfileService;
|
||||||
import com.imyeyu.api.modules.common.service.UserService;
|
import com.imyeyu.api.modules.common.service.UserService;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyPage;
|
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyView;
|
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentView;
|
|
||||||
import com.imyeyu.api.modules.common.vo.comment.UserCommentPage;
|
|
||||||
import com.imyeyu.api.modules.common.vo.user.EmailVerifyCallbackRequest;
|
import com.imyeyu.api.modules.common.vo.user.EmailVerifyCallbackRequest;
|
||||||
import com.imyeyu.api.modules.common.vo.user.LoginRequest;
|
import com.imyeyu.api.modules.common.vo.user.LoginRequest;
|
||||||
import com.imyeyu.api.modules.common.vo.user.LoginResponse;
|
import com.imyeyu.api.modules.common.vo.user.LoginResponse;
|
||||||
@ -27,11 +22,14 @@ import com.imyeyu.api.modules.common.vo.user.UpdatePasswordByKeyRequest;
|
|||||||
import com.imyeyu.api.modules.common.vo.user.UpdatePasswordRequest;
|
import com.imyeyu.api.modules.common.vo.user.UpdatePasswordRequest;
|
||||||
import com.imyeyu.api.modules.common.vo.user.UserRequest;
|
import com.imyeyu.api.modules.common.vo.user.UserRequest;
|
||||||
import com.imyeyu.api.modules.common.vo.user.UserView;
|
import com.imyeyu.api.modules.common.vo.user.UserView;
|
||||||
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||||
import com.imyeyu.spring.annotation.RequestSingleParam;
|
import com.imyeyu.spring.annotation.RequestSingleParam;
|
||||||
import com.imyeyu.spring.annotation.RequiredToken;
|
import com.imyeyu.spring.annotation.RequiredToken;
|
||||||
import com.imyeyu.spring.bean.CaptchaData;
|
import com.imyeyu.spring.bean.CaptchaData;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import com.imyeyu.utils.Time;
|
import com.imyeyu.utils.Time;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
@ -266,9 +264,11 @@ public class UserController implements TimiJava {
|
|||||||
@RequiredToken
|
@RequiredToken
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@PostMapping("/comment/list")
|
@PostMapping("/comment/list")
|
||||||
public PageResult<CommentView> listComment(@Valid @RequestBody UserCommentPage page) {
|
public PageResult<Comment> listComment(@Valid @RequestBody Page<Comment> page) {
|
||||||
page.setUserId(service.getLoginUser().getId());
|
Comment example = new Comment();
|
||||||
return commentService.pageByUserId(page);
|
example.setUserId(service.getLoginUser().getId());
|
||||||
|
page.setEqualsExample(example);
|
||||||
|
return commentService.page(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@ -287,9 +287,11 @@ public class UserController implements TimiJava {
|
|||||||
@RequiredToken
|
@RequiredToken
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@PostMapping("/comment/reply/list")
|
@PostMapping("/comment/reply/list")
|
||||||
public PageResult<CommentReplyView> listCommentReply(@Valid @RequestBody CommentReplyPage page) {
|
public PageResult<CommentReply> listCommentReply(@Valid @RequestBody Page<CommentReply> page) {
|
||||||
page.setBizId(service.getLoginUser().getId());
|
CommentReply example = new CommentReply();
|
||||||
return commentReplyService.pageByBizType(page);
|
example.setReceiverId(service.getLoginUser().getId());
|
||||||
|
page.setEqualsExample(example);
|
||||||
|
return commentReplyService.page(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
package com.imyeyu.api.modules.common.entity;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.blog.entity.Article;
|
||||||
|
import com.imyeyu.api.modules.blog.service.implement.ArticleServiceImplement;
|
||||||
|
import com.imyeyu.api.modules.common.bean.CommentSupport;
|
||||||
|
import com.imyeyu.api.modules.common.vo.user.UserView;
|
||||||
|
import com.imyeyu.api.modules.git.bean.gitea.Repository;
|
||||||
|
import com.imyeyu.api.modules.git.service.implement.IssueServiceImplement;
|
||||||
|
import com.imyeyu.api.modules.git.service.implement.MergeServiceImplement;
|
||||||
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
|
import com.imyeyu.spring.entity.Entity;
|
||||||
import com.imyeyu.spring.service.GettableService;
|
import com.imyeyu.spring.service.GettableService;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -7,11 +16,8 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import com.imyeyu.api.modules.blog.service.implement.ArticleServiceImplement;
|
|
||||||
import com.imyeyu.api.modules.common.bean.CommentSupport;
|
import java.util.List;
|
||||||
import com.imyeyu.api.modules.git.service.implement.IssueServiceImplement;
|
|
||||||
import com.imyeyu.api.modules.git.service.implement.MergeServiceImplement;
|
|
||||||
import com.imyeyu.spring.entity.Entity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评论
|
* 评论
|
||||||
@ -64,4 +70,24 @@ public class Comment extends Entity {
|
|||||||
|
|
||||||
/** 发送用户 IP */
|
/** 发送用户 IP */
|
||||||
private String ip;
|
private String ip;
|
||||||
|
|
||||||
|
/** 回复数量 */
|
||||||
|
@Transient
|
||||||
|
private long repliesLength;
|
||||||
|
|
||||||
|
/** 发送用户 */
|
||||||
|
@Transient
|
||||||
|
private UserView user;
|
||||||
|
|
||||||
|
/** 关联文章 */
|
||||||
|
@Transient
|
||||||
|
private Article article;
|
||||||
|
|
||||||
|
/** 关联仓库 */
|
||||||
|
@Transient
|
||||||
|
private Repository repository;
|
||||||
|
|
||||||
|
/** 回复列表 */
|
||||||
|
@Transient
|
||||||
|
private List<CommentReply> replies;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
package com.imyeyu.api.modules.common.entity;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.common.vo.user.UserView;
|
||||||
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
|
import com.imyeyu.spring.entity.Entity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import com.imyeyu.spring.entity.Entity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评论回复
|
* 评论回复
|
||||||
@ -42,4 +44,16 @@ public class CommentReply extends Entity {
|
|||||||
|
|
||||||
/** 被回复用户忽略该回复的时间 */
|
/** 被回复用户忽略该回复的时间 */
|
||||||
private Long ignoredAt;
|
private Long ignoredAt;
|
||||||
|
|
||||||
|
/** 所属评论 */
|
||||||
|
@Transient
|
||||||
|
private Comment comment;
|
||||||
|
|
||||||
|
/** 发送用户 */
|
||||||
|
@Transient
|
||||||
|
private UserView sender;
|
||||||
|
|
||||||
|
/** 回复用户 */
|
||||||
|
@Transient
|
||||||
|
private UserView receiver;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,9 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
package com.imyeyu.api.modules.common.mapper;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.Comment;
|
import com.imyeyu.api.modules.common.entity.Comment;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentView;
|
|
||||||
import com.imyeyu.spring.bean.Page;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
import org.apache.ibatis.annotations.Update;
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评论
|
* 评论
|
||||||
*
|
*
|
||||||
@ -18,30 +12,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface CommentMapper extends BaseMapper<Comment, Long> {
|
public interface CommentMapper extends BaseMapper<Comment, Long> {
|
||||||
|
|
||||||
@Override
|
|
||||||
long countByPage(Page page);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
List<Comment> selectByPage(Page page);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM comment WHERE id = #{id}" + NOT_DELETE)
|
|
||||||
Comment select(Long id);
|
|
||||||
|
|
||||||
@Update("UPDATE comment SET deleted_at = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000) WHERE id = #{id}")
|
|
||||||
@Override
|
|
||||||
void delete(Long id);
|
|
||||||
|
|
||||||
@Select("SELECT COUNT(1) FROM comment WHERE biz_type = #{bizType} AND biz_id = #{bizId}" + NOT_DELETE)
|
|
||||||
long count(Comment.BizType bizType, Long bizId);
|
|
||||||
|
|
||||||
long countAll(Comment.BizType bizType, Long bizId);
|
long countAll(Comment.BizType bizType, Long bizId);
|
||||||
|
|
||||||
List<CommentView> list(Comment.BizType bizType, Long bizId, Long offset, long limit, LinkedHashMap<String, OrderType> orderMap);
|
|
||||||
|
|
||||||
long countByUserId(Long userId);
|
|
||||||
|
|
||||||
List<CommentView> listByUserId(Long userId, Long offset, long limit, LinkedHashMap<String, OrderType> orderMap);
|
|
||||||
|
|
||||||
@Update("UPDATE comment SET deleted_at = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000) WHERE user_id = #{userId} ")
|
@Update("UPDATE comment SET deleted_at = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000) WHERE user_id = #{userId} ")
|
||||||
void deleteByUserId(Long userId);
|
void deleteByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package com.imyeyu.api.modules.common.mapper;
|
|||||||
|
|
||||||
import com.imyeyu.api.modules.blog.entity.CommentRemindQueue;
|
import com.imyeyu.api.modules.blog.entity.CommentRemindQueue;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Delete;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,10 +16,4 @@ public interface CommentRemindQueueMapper extends BaseMapper<CommentRemindQueue,
|
|||||||
|
|
||||||
@Select("SELECT * FROM comment_remind_queue WHERE user_id = #{userId}")
|
@Select("SELECT * FROM comment_remind_queue WHERE user_id = #{userId}")
|
||||||
List<CommentRemindQueue> listByUserId(Long userId);
|
List<CommentRemindQueue> listByUserId(Long userId);
|
||||||
|
|
||||||
@Delete("DELETE FROM comment_remind_queue WHERE user_id = #{userId}")
|
|
||||||
void destroyByUserId(Long userId);
|
|
||||||
|
|
||||||
@Delete("DELETE FROM comment_remind_queue WHERE reply_id = #{replyId}")
|
|
||||||
void destroyByReplyId(Long replyId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,13 +2,7 @@ package com.imyeyu.api.modules.common.mapper;
|
|||||||
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.CommentReply;
|
import com.imyeyu.api.modules.common.entity.CommentReply;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyPage;
|
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyView;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
import org.apache.ibatis.annotations.Update;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评论回复
|
* 评论回复
|
||||||
@ -17,19 +11,4 @@ import java.util.List;
|
|||||||
* @since 2021-08-24 10:36
|
* @since 2021-08-24 10:36
|
||||||
*/
|
*/
|
||||||
public interface CommentReplyMapper extends BaseMapper<CommentReply, Long> {
|
public interface CommentReplyMapper extends BaseMapper<CommentReply, Long> {
|
||||||
|
|
||||||
@Select("SELECT * FROM comment_reply WHERE sender_id = #{senderId}" + NOT_DELETE)
|
|
||||||
List<CommentReply> listAllBySenderId(Long senderId);
|
|
||||||
|
|
||||||
@Select("SELECT COUNT(1) FROM comment_reply WHERE ${bizType.column} = #{bizId}" + NOT_DELETE)
|
|
||||||
long countByBizType(CommentReplyPage.BizType bizType, Long bizId);
|
|
||||||
|
|
||||||
@Select("SELECT * FROM comment_reply WHERE ${bizType.column} = #{bizId} AND ignored_at IS NULL" + NOT_DELETE + PAGE)
|
|
||||||
List<CommentReplyView> listByBizType(CommentReplyPage.BizType bizType, Long bizId, Long offset, long limit);
|
|
||||||
|
|
||||||
@Update("UPDATE comment_reply SET deleted_at = " + UNIX_TIME + " WHERE sender_id = #{userId} OR receiver_id = #{userId}")
|
|
||||||
void deleteByUserId(Long userId);
|
|
||||||
|
|
||||||
@Update("UPDATE comment_reply SET deleted_at = " + UNIX_TIME + " WHERE comment_id = #{commentId}")
|
|
||||||
void deleteByCommentId(Long commentId);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,7 @@
|
|||||||
package com.imyeyu.api.modules.common.service;
|
package com.imyeyu.api.modules.common.service;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.CommentReply;
|
import com.imyeyu.api.modules.common.entity.CommentReply;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyPage;
|
import com.imyeyu.spring.service.BaseService;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyView;
|
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
|
||||||
import com.imyeyu.spring.service.CreatableService;
|
|
||||||
import com.imyeyu.spring.service.DeletableService;
|
|
||||||
import com.imyeyu.spring.service.GettableService;
|
|
||||||
import com.imyeyu.spring.service.UpdatableService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评论回复服务
|
* 评论回复服务
|
||||||
@ -15,7 +9,5 @@ import com.imyeyu.spring.service.UpdatableService;
|
|||||||
* @author 夜雨
|
* @author 夜雨
|
||||||
* @since 2021-08-24 10:33
|
* @since 2021-08-24 10:33
|
||||||
*/
|
*/
|
||||||
public interface CommentReplyService extends CreatableService<CommentReply>, GettableService<CommentReply, Long>, UpdatableService<CommentReply>, DeletableService<Long> {
|
public interface CommentReplyService extends BaseService<CommentReply, Long> {
|
||||||
|
|
||||||
PageResult<CommentReplyView> pageByBizType(CommentReplyPage page);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,7 @@
|
|||||||
package com.imyeyu.api.modules.common.service;
|
package com.imyeyu.api.modules.common.service;
|
||||||
|
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Comment;
|
import com.imyeyu.api.modules.common.entity.Comment;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentView;
|
import com.imyeyu.spring.service.BaseService;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.UserCommentPage;
|
|
||||||
import com.imyeyu.api.modules.git.vo.issue.CommentPage;
|
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
|
||||||
import com.imyeyu.spring.service.CreatableService;
|
|
||||||
import com.imyeyu.spring.service.DeletableService;
|
|
||||||
import com.imyeyu.spring.service.GettableService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评论服务
|
* 评论服务
|
||||||
@ -16,16 +9,5 @@ import com.imyeyu.spring.service.GettableService;
|
|||||||
* @author 夜雨
|
* @author 夜雨
|
||||||
* @since 2021-02-23 21:32
|
* @since 2021-02-23 21:32
|
||||||
*/
|
*/
|
||||||
public interface CommentService extends CreatableService<Comment>, GettableService<Comment, Long>, DeletableService<Long> {
|
public interface CommentService extends BaseService<Comment, Long> {
|
||||||
|
|
||||||
PageResult<CommentView> pageByBizId(CommentPage page);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户评论页面
|
|
||||||
*
|
|
||||||
* @param userCommentPage 页面参数
|
|
||||||
* @return 页面列表
|
|
||||||
* @throws TimiException 服务异常
|
|
||||||
*/
|
|
||||||
PageResult<CommentView> pageByUserId(UserCommentPage userCommentPage);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,8 @@
|
|||||||
package com.imyeyu.api.modules.common.service.implement;
|
package com.imyeyu.api.modules.common.service.implement;
|
||||||
|
|
||||||
import com.imyeyu.java.TimiJava;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiCode;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
|
||||||
import com.imyeyu.api.TimiServerAPI;
|
import com.imyeyu.api.TimiServerAPI;
|
||||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||||
import com.imyeyu.api.modules.blog.entity.Article;
|
|
||||||
import com.imyeyu.api.modules.blog.entity.CommentRemindQueue;
|
import com.imyeyu.api.modules.blog.entity.CommentRemindQueue;
|
||||||
import com.imyeyu.api.modules.blog.service.ArticleService;
|
|
||||||
import com.imyeyu.api.modules.blog.service.CommentRemindQueueService;
|
import com.imyeyu.api.modules.blog.service.CommentRemindQueueService;
|
||||||
import com.imyeyu.api.modules.common.bean.CommentSupport;
|
import com.imyeyu.api.modules.common.bean.CommentSupport;
|
||||||
import com.imyeyu.api.modules.common.entity.Comment;
|
import com.imyeyu.api.modules.common.entity.Comment;
|
||||||
@ -21,23 +16,21 @@ import com.imyeyu.api.modules.common.service.CommentService;
|
|||||||
import com.imyeyu.api.modules.common.service.EmailQueueService;
|
import com.imyeyu.api.modules.common.service.EmailQueueService;
|
||||||
import com.imyeyu.api.modules.common.service.UserConfigService;
|
import com.imyeyu.api.modules.common.service.UserConfigService;
|
||||||
import com.imyeyu.api.modules.common.service.UserService;
|
import com.imyeyu.api.modules.common.service.UserService;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyPage;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyView;
|
import com.imyeyu.java.bean.timi.TimiCode;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentView;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.api.modules.git.service.RepositoryService;
|
|
||||||
import com.imyeyu.spring.TimiSpring;
|
import com.imyeyu.spring.TimiSpring;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
import com.imyeyu.spring.service.GettableService;
|
import com.imyeyu.spring.service.GettableService;
|
||||||
import com.imyeyu.utils.Time;
|
import com.imyeyu.utils.Time;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,8 +45,6 @@ public class CommentReplyServiceImplement extends AbstractEntityService<CommentR
|
|||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final CommentService commentService;
|
private final CommentService commentService;
|
||||||
private final ArticleService articleService;
|
|
||||||
private final RepositoryService repositoryService;
|
|
||||||
private final UserConfigService userConfigService;
|
private final UserConfigService userConfigService;
|
||||||
private final EmailQueueService emailQueueService;
|
private final EmailQueueService emailQueueService;
|
||||||
private final CommentRemindQueueService commentRemindQueueService;
|
private final CommentRemindQueueService commentRemindQueueService;
|
||||||
@ -65,11 +56,23 @@ public class CommentReplyServiceImplement extends AbstractEntityService<CommentR
|
|||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Long crId) {
|
public PageResult<CommentReply> page(Page<CommentReply> page) {
|
||||||
super.delete(crId);
|
PageResult<CommentReply> result = super.page(page);
|
||||||
commentRemindQueueService.destroyByReplyId(crId);
|
for (CommentReply reply : result.getList()) {
|
||||||
|
Comment comment = commentService.get(reply.getCommentId());
|
||||||
|
if (TimiJava.isNotEmpty(comment.getUserId())) {
|
||||||
|
comment.setUser(userService.view(comment.getUserId()));
|
||||||
|
}
|
||||||
|
reply.setComment(comment);
|
||||||
|
if (TimiJava.isNotEmpty(reply.getSenderId())) {
|
||||||
|
reply.setSender(userService.view(reply.getSenderId()));
|
||||||
|
}
|
||||||
|
if (TimiJava.isNotEmpty(reply.getReceiverId())) {
|
||||||
|
reply.setReceiver(userService.view(reply.getReceiverId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@ -160,37 +163,10 @@ public class CommentReplyServiceImplement extends AbstractEntityService<CommentR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public PageResult<CommentReplyView> pageByBizType(CommentReplyPage page) {
|
public void delete(Long crId) {
|
||||||
PageResult<CommentReplyView> result = new PageResult<>();
|
super.delete(crId);
|
||||||
List<CommentReplyView> list = mapper.listByBizType(page.getBizType(), page.getBizId(), page.getOffset(), page.getLimit());
|
commentRemindQueueService.destroyByReplyId(crId);
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
CommentReplyView reply = list.get(i);
|
|
||||||
CommentView comment = new CommentView();
|
|
||||||
BeanUtils.copyProperties(commentService.get(reply.getCommentId()), comment);
|
|
||||||
if (TimiJava.isNotEmpty(comment.getUserId())) {
|
|
||||||
comment.setUser(userService.view(comment.getUserId()));
|
|
||||||
}
|
|
||||||
switch (comment.getBizType()) {
|
|
||||||
case ARTICLE -> {
|
|
||||||
Article article = articleService.get(comment.getBizId());
|
|
||||||
article.setData(null);
|
|
||||||
article.setExtendData(null);
|
|
||||||
comment.setArticle(article);
|
|
||||||
}
|
|
||||||
// case GIT_ISSUE, GIT_MERGE -> comment.setRepository(repositoryService.get(comment.getBizId()));
|
|
||||||
}
|
|
||||||
reply.setComment(comment);
|
|
||||||
|
|
||||||
if (TimiJava.isNotEmpty(reply.getSenderId())) {
|
|
||||||
reply.setSender(userService.view(reply.getSenderId()));
|
|
||||||
}
|
|
||||||
if (TimiJava.isNotEmpty(reply.getReceiverId())) {
|
|
||||||
reply.setReceiver(userService.view(reply.getReceiverId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.setList(list);
|
|
||||||
result.setTotal(mapper.countByBizType(page.getBizType(), page.getBizId()));
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
package com.imyeyu.api.modules.common.service.implement;
|
package com.imyeyu.api.modules.common.service.implement;
|
||||||
|
|
||||||
import com.imyeyu.java.TimiJava;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiCode;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
|
||||||
import com.imyeyu.api.TimiServerAPI;
|
import com.imyeyu.api.TimiServerAPI;
|
||||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||||
import com.imyeyu.api.modules.blog.entity.Article;
|
import com.imyeyu.api.modules.blog.entity.CommentRemindQueue;
|
||||||
import com.imyeyu.api.modules.blog.service.ArticleService;
|
|
||||||
import com.imyeyu.api.modules.common.bean.CommentSupport;
|
import com.imyeyu.api.modules.common.bean.CommentSupport;
|
||||||
import com.imyeyu.api.modules.common.entity.Comment;
|
import com.imyeyu.api.modules.common.entity.Comment;
|
||||||
import com.imyeyu.api.modules.common.entity.CommentReply;
|
import com.imyeyu.api.modules.common.entity.CommentReply;
|
||||||
@ -16,12 +12,11 @@ import com.imyeyu.api.modules.common.mapper.CommentRemindQueueMapper;
|
|||||||
import com.imyeyu.api.modules.common.mapper.CommentReplyMapper;
|
import com.imyeyu.api.modules.common.mapper.CommentReplyMapper;
|
||||||
import com.imyeyu.api.modules.common.service.CommentService;
|
import com.imyeyu.api.modules.common.service.CommentService;
|
||||||
import com.imyeyu.api.modules.common.service.UserService;
|
import com.imyeyu.api.modules.common.service.UserService;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyView;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentView;
|
import com.imyeyu.java.bean.timi.TimiCode;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.UserCommentPage;
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.api.modules.git.service.RepositoryService;
|
|
||||||
import com.imyeyu.api.modules.git.vo.issue.CommentPage;
|
|
||||||
import com.imyeyu.spring.TimiSpring;
|
import com.imyeyu.spring.TimiSpring;
|
||||||
|
import com.imyeyu.spring.bean.Page;
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
@ -31,7 +26,6 @@ import org.springframework.context.annotation.Lazy;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,8 +39,6 @@ import java.util.List;
|
|||||||
public class CommentServiceImplement extends AbstractEntityService<Comment, Long> implements CommentService {
|
public class CommentServiceImplement extends AbstractEntityService<Comment, Long> implements CommentService {
|
||||||
|
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final ArticleService articleService;
|
|
||||||
private final RepositoryService repositoryService;
|
|
||||||
|
|
||||||
private final CommentMapper mapper;
|
private final CommentMapper mapper;
|
||||||
private final CommentReplyMapper replyMapper;
|
private final CommentReplyMapper replyMapper;
|
||||||
@ -57,6 +49,36 @@ public class CommentServiceImplement extends AbstractEntityService<Comment, Long
|
|||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<Comment> page(Page<Comment> page) {
|
||||||
|
PageResult<Comment> result = super.page(page);
|
||||||
|
for (Comment comment : result.getList()) {
|
||||||
|
if (TimiJava.isNotEmpty(comment.getUserId())) {
|
||||||
|
comment.setUser(userService.view(comment.getUserId()));
|
||||||
|
}
|
||||||
|
Page<CommentReply> replyPage = new Page<>();
|
||||||
|
replyPage.setIndex(0);
|
||||||
|
replyPage.setSize(6);
|
||||||
|
{
|
||||||
|
CommentReply exampleReply = new CommentReply();
|
||||||
|
exampleReply.setCommentId(comment.getId());
|
||||||
|
replyPage.setEqualsExample(exampleReply);
|
||||||
|
}
|
||||||
|
PageResult<CommentReply> replyResult = replyMapper.selectPageResult(replyPage);
|
||||||
|
comment.setReplies(replyResult.getList());
|
||||||
|
comment.setRepliesLength(replyResult.getTotal());
|
||||||
|
for (CommentReply reply : replyResult.getList()) {
|
||||||
|
if (TimiJava.isNotEmpty(reply.getSenderId())) {
|
||||||
|
reply.setSender(userService.view(reply.getSenderId()));
|
||||||
|
}
|
||||||
|
if (TimiJava.isNotEmpty(reply.getReceiverId())) {
|
||||||
|
reply.setReceiver(userService.view(reply.getReceiverId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void create(Comment comment) {
|
public void create(Comment comment) {
|
||||||
@ -83,77 +105,31 @@ public class CommentServiceImplement extends AbstractEntityService<Comment, Long
|
|||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@Override
|
@Override
|
||||||
public void delete(Long cId) {
|
public void delete(Long commentId) {
|
||||||
User user = userService.getLoginUser();
|
User user = userService.getLoginUser();
|
||||||
|
|
||||||
Comment comment = get(cId);
|
Comment comment = get(commentId);
|
||||||
if (!comment.getUserId().equals(user.getId())) {
|
if (!comment.getUserId().equals(user.getId())) {
|
||||||
throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("token.illegal");
|
throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("token.illegal");
|
||||||
}
|
}
|
||||||
List<CommentReply> replies = replyMapper.listAllBySenderId(user.getId());
|
{
|
||||||
for (int i = 0; i < replies.size(); i++) {
|
// 移除被回复者的回复提醒队列
|
||||||
// 移出被回复者的回复提醒队列
|
CommentReply example = new CommentReply();
|
||||||
remindQueueMapper.destroyByReplyId(replies.get(i).getId());
|
example.setSenderId(user.getId());
|
||||||
}
|
List<CommentReply> replies = replyMapper.selectAllByExample(example);
|
||||||
replyMapper.deleteByCommentId(cId);
|
for (CommentReply reply : replies) {
|
||||||
super.delete(cId);
|
CommentRemindQueue destroyRemindExample = new CommentRemindQueue();
|
||||||
}
|
destroyRemindExample.setReplyId(reply.getReplyId());
|
||||||
|
remindQueueMapper.destroyAllByExample(destroyRemindExample);
|
||||||
@Override
|
|
||||||
public PageResult<CommentView> pageByBizId(CommentPage page) {
|
|
||||||
if (page.getOrderMap() == null) {
|
|
||||||
page.setOrderMap(new LinkedHashMap<>());
|
|
||||||
}
|
|
||||||
if (page.getOrderMap().isEmpty()) {
|
|
||||||
page.getOrderMap().put("createdAt", BaseMapper.OrderType.DESC);
|
|
||||||
}
|
|
||||||
List<CommentView> list = mapper.list(page.getBizType(), page.getBizId(), page.getOffset(), page.getLimit(), page.getOrderMap());
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
CommentView comment = list.get(i);
|
|
||||||
if (TimiJava.isNotEmpty(comment.getUserId())) {
|
|
||||||
comment.setUser(userService.view(comment.getUserId()));
|
|
||||||
}
|
|
||||||
List<CommentReplyView> replies = comment.getReplies();
|
|
||||||
for (int j = 0; j < replies.size(); j++) {
|
|
||||||
CommentReplyView reply = replies.get(j);
|
|
||||||
if (TimiJava.isNotEmpty(reply.getSenderId())) {
|
|
||||||
reply.setSender(userService.view(reply.getSenderId()));
|
|
||||||
}
|
|
||||||
if (TimiJava.isNotEmpty(reply.getReceiverId())) {
|
|
||||||
reply.setReceiver(userService.view(reply.getReceiverId()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PageResult<CommentView> result = new PageResult<>();
|
{
|
||||||
result.setList(list);
|
// 删除回复
|
||||||
result.setTotal(mapper.count(page.getBizType(), page.getBizId()));
|
CommentReply example = new CommentReply();
|
||||||
return result;
|
example.setCommentId(commentId);
|
||||||
}
|
replyMapper.deleteAllByExample(example);
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<CommentView> pageByUserId(UserCommentPage page) {
|
|
||||||
if (page.getOrderMap() == null) {
|
|
||||||
page.setOrderMap(new LinkedHashMap<>());
|
|
||||||
}
|
}
|
||||||
if (page.getOrderMap().isEmpty()) {
|
// 删除评论
|
||||||
page.getOrderMap().put("createdAt", BaseMapper.OrderType.DESC);
|
super.delete(commentId);
|
||||||
}
|
|
||||||
PageResult<CommentView> result = new PageResult<>();
|
|
||||||
result.setList(mapper.listByUserId(page.getUserId(), page.getOffset(), page.getLimit(), page.getOrderMap()));
|
|
||||||
result.setTotal(mapper.countByUserId(page.getUserId()));
|
|
||||||
|
|
||||||
for (int i = 0; i < result.getList().size(); i++) {
|
|
||||||
CommentView view = result.getList().get(i);
|
|
||||||
switch (view.getBizType()) {
|
|
||||||
case ARTICLE -> {
|
|
||||||
Article article = articleService.get(view.getBizId());
|
|
||||||
article.setData(null);
|
|
||||||
article.setExtendData(null);
|
|
||||||
view.setArticle(article);
|
|
||||||
}
|
|
||||||
// case GIT_ISSUE, GIT_MERGE -> view.setRepository(repositoryService.get(view.getBizId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
package com.imyeyu.api.modules.common.service.implement;
|
package com.imyeyu.api.modules.common.service.implement;
|
||||||
|
|
||||||
import com.imyeyu.java.TimiJava;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiCode;
|
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
|
||||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||||
import com.imyeyu.api.modules.blog.util.UserToken;
|
import com.imyeyu.api.modules.blog.util.UserToken;
|
||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
|
import com.imyeyu.api.modules.common.entity.CommentReply;
|
||||||
import com.imyeyu.api.modules.common.entity.EmailQueue;
|
import com.imyeyu.api.modules.common.entity.EmailQueue;
|
||||||
import com.imyeyu.api.modules.common.entity.User;
|
import com.imyeyu.api.modules.common.entity.User;
|
||||||
import com.imyeyu.api.modules.common.entity.UserConfig;
|
import com.imyeyu.api.modules.common.entity.UserConfig;
|
||||||
@ -29,7 +27,11 @@ import com.imyeyu.api.modules.common.vo.user.UserView;
|
|||||||
import com.imyeyu.api.modules.git.entity.Developer;
|
import com.imyeyu.api.modules.git.entity.Developer;
|
||||||
import com.imyeyu.api.modules.git.service.DeveloperService;
|
import com.imyeyu.api.modules.git.service.DeveloperService;
|
||||||
import com.imyeyu.api.modules.minecraft.service.PlayerService;
|
import com.imyeyu.api.modules.minecraft.service.PlayerService;
|
||||||
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiCode;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
import com.imyeyu.spring.TimiSpring;
|
import com.imyeyu.spring.TimiSpring;
|
||||||
|
import com.imyeyu.spring.bean.Logic;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
import com.imyeyu.spring.util.Redis;
|
import com.imyeyu.spring.util.Redis;
|
||||||
@ -360,8 +362,13 @@ public class UserServiceImplement extends AbstractEntityService<User, Long> impl
|
|||||||
}
|
}
|
||||||
// 删除评论
|
// 删除评论
|
||||||
commentMapper.deleteByUserId(user.getId());
|
commentMapper.deleteByUserId(user.getId());
|
||||||
// 删除回复
|
{
|
||||||
commentReplyMapper.deleteByUserId(user.getId());
|
// 删除回复
|
||||||
|
CommentReply example = new CommentReply();
|
||||||
|
example.setSenderId(user.getId());
|
||||||
|
example.setReceiverId(user.getId());
|
||||||
|
commentReplyMapper.deleteAllByExample(example, Logic.OR);
|
||||||
|
}
|
||||||
// 删除账号
|
// 删除账号
|
||||||
delete(user.getId());
|
delete(user.getId());
|
||||||
// 清除登录会话
|
// 清除登录会话
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import com.imyeyu.api.modules.common.entity.User;
|
|||||||
import com.imyeyu.api.modules.common.service.CommentReplyService;
|
import com.imyeyu.api.modules.common.service.CommentReplyService;
|
||||||
import com.imyeyu.api.modules.common.service.EmailQueueService;
|
import com.imyeyu.api.modules.common.service.EmailQueueService;
|
||||||
import com.imyeyu.api.modules.common.service.UserService;
|
import com.imyeyu.api.modules.common.service.UserService;
|
||||||
import com.imyeyu.api.modules.common.vo.comment.CommentReplyView;
|
|
||||||
import com.imyeyu.spring.util.Redis;
|
import com.imyeyu.spring.util.Redis;
|
||||||
import com.imyeyu.utils.Text;
|
import com.imyeyu.utils.Text;
|
||||||
import com.imyeyu.utils.Time;
|
import com.imyeyu.utils.Time;
|
||||||
@ -175,9 +174,7 @@ public class EmailTask implements TimiJava {
|
|||||||
for (CommentRemindQueue remind : reminds) {
|
for (CommentRemindQueue remind : reminds) {
|
||||||
// 回复
|
// 回复
|
||||||
CommentReply reply = commentReplyService.get(remind.getReplyId());
|
CommentReply reply = commentReplyService.get(remind.getReplyId());
|
||||||
CommentReplyView replyView = new CommentReplyView();
|
remind.setReply(reply);
|
||||||
BeanUtils.copyProperties(reply, replyView);
|
|
||||||
remind.setReply(replyView);
|
|
||||||
if (TimiJava.isNotEmpty(remind.getReply().getSenderId())) {
|
if (TimiJava.isNotEmpty(remind.getReply().getSenderId())) {
|
||||||
// 发送者
|
// 发送者
|
||||||
remind.getReply().setSender(userService.view(remind.getReply().getSenderId()));
|
remind.getReply().setSender(userService.view(remind.getReply().getSenderId()));
|
||||||
|
|||||||
@ -1,41 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.vo.comment;
|
|
||||||
|
|
||||||
import com.imyeyu.spring.bean.Page;
|
|
||||||
import jakarta.validation.constraints.Min;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2023-07-15 09:03
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CommentReplyPage extends Page {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2025-04-17 23:29
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum BizType {
|
|
||||||
|
|
||||||
COMMENT("comment_id"),
|
|
||||||
|
|
||||||
SENDER("sender_id"),
|
|
||||||
|
|
||||||
RECEIVER("receiver_id");
|
|
||||||
|
|
||||||
final String column;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BizType bizType;
|
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private Long bizId;
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.vo.comment;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.CommentReply;
|
|
||||||
import com.imyeyu.api.modules.common.vo.user.UserView;
|
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2024-03-05 17:48
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CommentReplyView extends CommentReply {
|
|
||||||
|
|
||||||
/** 所属评论 */
|
|
||||||
@Transient
|
|
||||||
private CommentView comment;
|
|
||||||
|
|
||||||
/** 发送用户 */
|
|
||||||
@Transient
|
|
||||||
private UserView sender;
|
|
||||||
|
|
||||||
/** 回复用户 */
|
|
||||||
@Transient
|
|
||||||
private UserView receiver;
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.vo.comment;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.blog.entity.Article;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Comment;
|
|
||||||
import com.imyeyu.api.modules.common.vo.user.UserView;
|
|
||||||
import com.imyeyu.api.modules.git.bean.gitea.Repository;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2024-02-29 16:37
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CommentView extends Comment {
|
|
||||||
|
|
||||||
/** 回复数量 */
|
|
||||||
private int repliesLength;
|
|
||||||
|
|
||||||
/** 发送用户 */
|
|
||||||
private UserView user;
|
|
||||||
|
|
||||||
/** 关联文章 */
|
|
||||||
private Article article;
|
|
||||||
|
|
||||||
/** 关联仓库 */
|
|
||||||
private Repository repository;
|
|
||||||
|
|
||||||
/** 回复列表 */
|
|
||||||
private List<CommentReplyView> replies;
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.vo.comment;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.Min;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import com.imyeyu.spring.bean.Page;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2023-07-15 14:13
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class UserCommentPage extends Page {
|
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private Long userId;
|
|
||||||
}
|
|
||||||
@ -1,21 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.git.vo.issue;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.Comment;
|
|
||||||
import com.imyeyu.spring.bean.Page;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2024-02-28 14:27
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CommentPage extends Page<Comment> {
|
|
||||||
|
|
||||||
private Comment.BizType bizType;
|
|
||||||
|
|
||||||
private long bizId;
|
|
||||||
}
|
|
||||||
@ -2,101 +2,7 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.imyeyu.api.modules.common.mapper.CommentMapper">
|
<mapper namespace="com.imyeyu.api.modules.common.mapper.CommentMapper">
|
||||||
<sql id="table">comment</sql>
|
<sql id="table">comment</sql>
|
||||||
<!-- 主评论 -->
|
<select id="countAll" resultType="long">
|
||||||
<select id="selectByPage" resultMap="selectResult">
|
|
||||||
SELECT
|
|
||||||
-- 主评论
|
|
||||||
comment.id,
|
|
||||||
comment.biz_type,
|
|
||||||
comment.biz_id,
|
|
||||||
comment.user_id,
|
|
||||||
comment.nick,
|
|
||||||
comment.content,
|
|
||||||
comment.created_at,
|
|
||||||
|
|
||||||
-- 回复数量
|
|
||||||
reply_count.reply_length,
|
|
||||||
|
|
||||||
-- 回复
|
|
||||||
reply.id AS reply_id,
|
|
||||||
reply.comment_id,
|
|
||||||
reply.sender_id,
|
|
||||||
reply.sender_nick,
|
|
||||||
reply.receiver_id,
|
|
||||||
reply.receiver_nick,
|
|
||||||
reply.content AS reply_content,
|
|
||||||
reply.created_at AS reply_created_at
|
|
||||||
FROM (
|
|
||||||
-- 查询主评论
|
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
<include refid="table" />
|
|
||||||
WHERE
|
|
||||||
biz_type = #{bizType}
|
|
||||||
AND biz_id = #{bizId}
|
|
||||||
AND deleted_at IS NULL
|
|
||||||
ORDER BY
|
|
||||||
created_at ${orderMap.createdAt}
|
|
||||||
LIMIT
|
|
||||||
#{offset}, #{limit}
|
|
||||||
) AS comment
|
|
||||||
LEFT JOIN (
|
|
||||||
-- 查询前 6 条回复(时间升序)
|
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM (
|
|
||||||
SELECT
|
|
||||||
comment_reply.*,
|
|
||||||
ROW_NUMBER() OVER (
|
|
||||||
PARTITION BY comment_id
|
|
||||||
ORDER BY created_at ASC
|
|
||||||
) AS seq
|
|
||||||
FROM
|
|
||||||
comment_reply
|
|
||||||
WHERE
|
|
||||||
deleted_at IS NULL
|
|
||||||
) AS reply
|
|
||||||
WHERE
|
|
||||||
seq < 7
|
|
||||||
) AS reply
|
|
||||||
ON
|
|
||||||
reply.comment_id = comment.id
|
|
||||||
LEFT JOIN(
|
|
||||||
-- 统计回复总数
|
|
||||||
SELECT
|
|
||||||
comment_id AS id,
|
|
||||||
COUNT(*) AS reply_length
|
|
||||||
FROM
|
|
||||||
comment_reply
|
|
||||||
WHERE
|
|
||||||
deleted_at IS NULL
|
|
||||||
GROUP BY
|
|
||||||
comment_id
|
|
||||||
) AS reply_count
|
|
||||||
ON
|
|
||||||
reply_count.id = comment.id
|
|
||||||
</select>
|
|
||||||
<resultMap id="selectResult" type="com.imyeyu.api.modules.common.vo.comment.CommentView">
|
|
||||||
<id property="id" column="id" />
|
|
||||||
<result property="userId" column="user_id" />
|
|
||||||
<result property="nick" column="nick" />
|
|
||||||
<result property="content" column="content" />
|
|
||||||
<result property="repliesLength" column="reply_length" />
|
|
||||||
<result property="createdAt" column="created_at" />
|
|
||||||
<!-- 关联回复 -->
|
|
||||||
<collection property="replies" ofType="com.imyeyu.api.modules.common.vo.comment.CommentReplyView">
|
|
||||||
<id property="id" column="reply_id" />
|
|
||||||
<result property="commentId" column="comment_id" />
|
|
||||||
<result property="senderId" column="sender_id" />
|
|
||||||
<result property="senderNick" column="sender_nick" />
|
|
||||||
<result property="receiverId" column="receiver_id" />
|
|
||||||
<result property="receiverNick" column="receiver_nick" />
|
|
||||||
<result property="content" column="reply_content" />
|
|
||||||
<result property="createdAt" column="reply_created_at" />
|
|
||||||
</collection>
|
|
||||||
</resultMap>
|
|
||||||
<select id="countByPage" resultType="long">
|
|
||||||
SELECT
|
SELECT
|
||||||
SUM(result.total_comment + result.total_reply)
|
SUM(result.total_comment + result.total_reply)
|
||||||
FROM (
|
FROM (
|
||||||
@ -116,28 +22,4 @@
|
|||||||
AND comment_reply.deleted_at IS NULL
|
AND comment_reply.deleted_at IS NULL
|
||||||
) AS result
|
) AS result
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<sql id="byUserIdCondition">
|
|
||||||
FROM
|
|
||||||
<include refid="table" />
|
|
||||||
WHERE
|
|
||||||
user_id = #{userId}
|
|
||||||
AND deleted_at IS NULL
|
|
||||||
</sql>
|
|
||||||
<select id="countByUserId" resultType="long">
|
|
||||||
SELECT COUNT(1) <include refid="byUserIdCondition" />
|
|
||||||
</select>
|
|
||||||
<select id="listByUserId" resultType="com.imyeyu.api.modules.common.vo.comment.CommentView">
|
|
||||||
SELECT
|
|
||||||
id,
|
|
||||||
biz_type,
|
|
||||||
biz_id,
|
|
||||||
content,
|
|
||||||
created_at
|
|
||||||
<include refid="byUserIdCondition" />
|
|
||||||
ORDER BY
|
|
||||||
created_at ${orderMap.createdAt}
|
|
||||||
LIMIT
|
|
||||||
#{offset}, #{limit}
|
|
||||||
</select>
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user