删除评论相关接口修改
This commit is contained in:
parent
d0bf164268
commit
8cc77bc227
@ -355,6 +355,12 @@ public class DynamicRestController extends BaseController {
|
|||||||
dynamicService.deleteBlacklist(cmd);
|
dynamicService.deleteBlacklist(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增待审核动态
|
||||||
|
*/
|
||||||
|
@PostMapping("/approval")
|
||||||
|
public void addApprovalDynamic(DynamicContentAddCmd cmd) {
|
||||||
|
dynamicService.addApprovalDynamic(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.red.circle.other.app.command.dynamic.add;
|
|||||||
import com.red.circle.common.business.core.enums.ApprovalStatusEnum;
|
import com.red.circle.common.business.core.enums.ApprovalStatusEnum;
|
||||||
import com.red.circle.common.business.core.enums.DataApprovalTypeEnum;
|
import com.red.circle.common.business.core.enums.DataApprovalTypeEnum;
|
||||||
import com.red.circle.common.business.core.enums.DynamicEventTypeEnum;
|
import com.red.circle.common.business.core.enums.DynamicEventTypeEnum;
|
||||||
|
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||||
import com.red.circle.common.business.enums.PhotoApprovalStatusEnum;
|
import com.red.circle.common.business.enums.PhotoApprovalStatusEnum;
|
||||||
import com.red.circle.component.redis.service.RedisService;
|
import com.red.circle.component.redis.service.RedisService;
|
||||||
import com.red.circle.external.inner.endpoint.message.ImAccountClient;
|
import com.red.circle.external.inner.endpoint.message.ImAccountClient;
|
||||||
@ -18,6 +19,7 @@ import com.red.circle.mq.rocket.business.producer.CensorMqMessage;
|
|||||||
import com.red.circle.mq.rocket.business.producer.DynamicMqMessage;
|
import com.red.circle.mq.rocket.business.producer.DynamicMqMessage;
|
||||||
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
import com.red.circle.mq.rocket.business.producer.TaskMqMessage;
|
||||||
import com.red.circle.other.app.dto.cmd.dynamic.DynamicContentAddCmd;
|
import com.red.circle.other.app.dto.cmd.dynamic.DynamicContentAddCmd;
|
||||||
|
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
|
||||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||||
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
|
||||||
import com.red.circle.other.domain.model.user.UserConsumptionLevel;
|
import com.red.circle.other.domain.model.user.UserConsumptionLevel;
|
||||||
@ -33,6 +35,8 @@ import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentSer
|
|||||||
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicPictureService;
|
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicPictureService;
|
||||||
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicTagService;
|
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicTagService;
|
||||||
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicTimelineService;
|
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicTimelineService;
|
||||||
|
import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService;
|
||||||
|
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
||||||
import com.red.circle.other.inner.asserts.DynamicErrorCode;
|
import com.red.circle.other.inner.asserts.DynamicErrorCode;
|
||||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||||
import com.red.circle.tool.core.date.TimestampUtils;
|
import com.red.circle.tool.core.date.TimestampUtils;
|
||||||
@ -81,6 +85,8 @@ public class DynamicContentAddCmdExe {
|
|||||||
private final ApprovalDynamicContentService approvalDynamicContentService;
|
private final ApprovalDynamicContentService approvalDynamicContentService;
|
||||||
private final TaskMqMessage taskMqMessage;
|
private final TaskMqMessage taskMqMessage;
|
||||||
private final UserAccountCommon userAccountCommon;
|
private final UserAccountCommon userAccountCommon;
|
||||||
|
private final AdministratorService administratorService;
|
||||||
|
private final AdministratorAuthService administratorAuthService;
|
||||||
|
|
||||||
public Long execute(DynamicContentAddCmd cmd) {
|
public Long execute(DynamicContentAddCmd cmd) {
|
||||||
|
|
||||||
@ -97,9 +103,6 @@ public class DynamicContentAddCmdExe {
|
|||||||
if (CollectionUtils.isEmpty(cmd.getPictures())) {
|
if (CollectionUtils.isEmpty(cmd.getPictures())) {
|
||||||
return contentId;
|
return contentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
addApprovalDynamic(cmd, contentId);
|
|
||||||
|
|
||||||
sendViolationContentMq(cmd);
|
sendViolationContentMq(cmd);
|
||||||
return contentId;
|
return contentId;
|
||||||
|
|
||||||
@ -113,10 +116,17 @@ public class DynamicContentAddCmdExe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addApprovalDynamic(DynamicContentAddCmd cmd, Long contentId) {
|
public void addApprovalDynamic(DynamicContentAddCmd cmd) {
|
||||||
|
// 验证管理员权限
|
||||||
|
ViolationTypeEnum violationTypeEnum = ViolationTypeEnum.DELETE_CONTENT;
|
||||||
|
ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION,
|
||||||
|
administratorService.existsAdmin(cmd.getReqUserId()) &&
|
||||||
|
administratorAuthService.existsAuth(cmd.requiredReqUserId(), violationTypeEnum.name()));
|
||||||
|
|
||||||
|
|
||||||
ApprovalDynamicContent dynamicContent = new ApprovalDynamicContent();
|
ApprovalDynamicContent dynamicContent = new ApprovalDynamicContent();
|
||||||
dynamicContent.setUserId(cmd.getReqUserId());
|
dynamicContent.setUserId(cmd.getReqUserId());
|
||||||
dynamicContent.setDynamicId(contentId);
|
dynamicContent.setDynamicId(Long.parseLong(cmd.getContent()));
|
||||||
dynamicContent.setApproveStatus(ApprovalStatusEnum.PENDING.name());
|
dynamicContent.setApproveStatus(ApprovalStatusEnum.PENDING.name());
|
||||||
dynamicContent.setSysOrigin(cmd.requireReqSysOrigin());
|
dynamicContent.setSysOrigin(cmd.requireReqSysOrigin());
|
||||||
dynamicContent.setCreateTime(TimestampUtils.now());
|
dynamicContent.setCreateTime(TimestampUtils.now());
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.red.circle.other.app.command.dynamic.delete;
|
|||||||
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
|
||||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||||
|
import com.red.circle.other.app.enums.violation.ViolationTypeEnum;
|
||||||
import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService;
|
import com.red.circle.other.infra.database.cache.service.other.DynamicCacheService;
|
||||||
import com.red.circle.other.infra.database.mongo.service.dynamic.DynamicPopularService;
|
import com.red.circle.other.infra.database.mongo.service.dynamic.DynamicPopularService;
|
||||||
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicComment;
|
import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicComment;
|
||||||
@ -10,6 +11,8 @@ import com.red.circle.other.infra.database.rds.entity.dynamic.DynamicContent;
|
|||||||
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentLikeService;
|
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentLikeService;
|
||||||
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentService;
|
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicCommentService;
|
||||||
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService;
|
import com.red.circle.other.infra.database.rds.service.dynamic.DynamicContentService;
|
||||||
|
import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService;
|
||||||
|
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
||||||
import com.red.circle.other.inner.asserts.DynamicErrorCode;
|
import com.red.circle.other.inner.asserts.DynamicErrorCode;
|
||||||
import com.red.circle.tool.core.num.NumUtils;
|
import com.red.circle.tool.core.num.NumUtils;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -33,18 +36,25 @@ public class DynamicCommentDelCmdExe {
|
|||||||
private final DynamicCommentService dynamicCommentService;
|
private final DynamicCommentService dynamicCommentService;
|
||||||
private final DynamicPopularService dynamicPopularService;
|
private final DynamicPopularService dynamicPopularService;
|
||||||
private final DynamicCommentLikeService dynamicCommentLikeService;
|
private final DynamicCommentLikeService dynamicCommentLikeService;
|
||||||
|
private final AdministratorService administratorService;
|
||||||
|
private final AdministratorAuthService administratorAuthService;
|
||||||
|
|
||||||
public Long execute(AppIdLongCmd cmd) {
|
public Long execute(AppIdLongCmd cmd) {
|
||||||
|
|
||||||
DynamicComment comment = dynamicCommentService.getById(cmd.getId());
|
DynamicComment comment = dynamicCommentService.getById(cmd.getId());
|
||||||
ResponseAssert.notNull(DynamicErrorCode.COMMENT_DELETED, comment);
|
ResponseAssert.notNull(DynamicErrorCode.COMMENT_DELETED, comment);
|
||||||
|
|
||||||
// DynamicContent content = getContentServiceById(comment);
|
//自己和管理员才能删除
|
||||||
// ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION, isEqualsCommon(cmd, comment)
|
ViolationTypeEnum violationTypeEnum = ViolationTypeEnum.DELETE_COMMENT;
|
||||||
// || isEqualsContent(cmd, content));
|
if (!Objects.equals(cmd.getReqUserId(), comment.getCreateUser())) {
|
||||||
|
ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION,
|
||||||
|
administratorService.existsAdmin(cmd.getReqUserId()) &&
|
||||||
|
administratorAuthService.existsAuth(cmd.requiredReqUserId(), violationTypeEnum.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//评论点赞数量
|
//评论点赞数量
|
||||||
if (Objects.isNull(comment.getRootCommentId())) {
|
if (Objects.nonNull(comment.getRootCommentId())) {
|
||||||
return deleteAllComment(cmd, comment);
|
return deleteAllComment(cmd, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,8 +37,8 @@ public class DynamicContentDelCmdExe {
|
|||||||
|
|
||||||
DynamicContent dynamicContent = dynamicContentService.getById(cmd.getId());
|
DynamicContent dynamicContent = dynamicContentService.getById(cmd.getId());
|
||||||
ResponseAssert.notNull(DynamicErrorCode.CONTENT_IS_NULL, dynamicContent);
|
ResponseAssert.notNull(DynamicErrorCode.CONTENT_IS_NULL, dynamicContent);
|
||||||
// ResponseAssert.isTrue(CommonErrorCode.NOT_ACCEPT_REQUEST,
|
ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION,
|
||||||
// Objects.equals(dynamicContent.getCreateUser(), cmd.getReqUserId()));
|
Objects.equals(dynamicContent.getCreateUser(), cmd.getReqUserId()));
|
||||||
|
|
||||||
dynamicContent.setDel(Boolean.TRUE);
|
dynamicContent.setDel(Boolean.TRUE);
|
||||||
dynamicContent.setUpdateUser(cmd.getReqUserId());
|
dynamicContent.setUpdateUser(cmd.getReqUserId());
|
||||||
|
|||||||
@ -57,14 +57,14 @@ public class ApprovalDynamicContentStrategy implements ApprovalStrategy {
|
|||||||
process(param, dynamicMap);
|
process(param, dynamicMap);
|
||||||
|
|
||||||
//发送消息标记
|
//发送消息标记
|
||||||
dynamicMessageService.mapByUserIdsByContentId(getUserIds(contents))
|
// dynamicMessageService.mapByUserIdsByContentId(getUserIds(contents))
|
||||||
.forEach((key, list) -> newsletterClient
|
// .forEach((key, list) -> newsletterClient
|
||||||
.send(new NewsletterResultCmd()
|
// .send(new NewsletterResultCmd()
|
||||||
.setUserIds(List.of(key))
|
// .setUserIds(List.of(key))
|
||||||
.setEvent(NewsletterEvent.DYNAMIC_MESSAGE_QUANTITY)
|
// .setEvent(NewsletterEvent.DYNAMIC_MESSAGE_QUANTITY)
|
||||||
.setData(list.size())
|
// .setData(list.size())
|
||||||
)
|
// )
|
||||||
);
|
// );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -201,4 +201,9 @@ public class DynamicServiceImpl implements DynamicService {
|
|||||||
dynamicBlacklistDelCmdExe.execute(cmd);
|
dynamicBlacklistDelCmdExe.execute(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addApprovalDynamic(DynamicContentAddCmd cmd) {
|
||||||
|
dynamicContentAddCmdExe.addApprovalDynamic(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -155,4 +155,6 @@ public interface DynamicService {
|
|||||||
* 删除黑名单.
|
* 删除黑名单.
|
||||||
*/
|
*/
|
||||||
void deleteBlacklist(DynamicBlacklistDelCmd cmd);
|
void deleteBlacklist(DynamicBlacklistDelCmd cmd);
|
||||||
|
|
||||||
|
void addApprovalDynamic(DynamicContentAddCmd cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user