diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/dynamic/DynamicRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/dynamic/DynamicRestController.java index 937a3259..90b4d325 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/dynamic/DynamicRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/dynamic/DynamicRestController.java @@ -329,4 +329,32 @@ public class DynamicRestController extends BaseController { return dynamicService.checkSendPermission2(cmd); } + /** + * 添加黑名单. + * + * @eo.name 添加黑名单. + * @eo.url /blacklist/add + * @eo.method post + * @eo.request-type json + */ + @PostMapping("/admin/blacklist/add") + public void addBlacklist(@RequestBody @Validated DynamicBlacklistAddCmd cmd) { + dynamicService.addBlacklist(cmd); + } + + /** + * 删除黑名单. + * + * @eo.name 删除黑名单. + * @eo.url /blacklist/delete + * @eo.method post + * @eo.request-type json + */ + @PostMapping("/admin/blacklist/delete") + public void deleteBlacklist(@RequestBody @Validated DynamicBlacklistDelCmd cmd) { + dynamicService.deleteBlacklist(cmd); + } + + + } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicBlacklistAddCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicBlacklistAddCmdExe.java new file mode 100644 index 00000000..26a86a56 --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicBlacklistAddCmdExe.java @@ -0,0 +1,43 @@ +package com.red.circle.other.app.command.dynamic; + +import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.other.app.dto.cmd.dynamic.DynamicBlacklistAddCmd; +import com.red.circle.other.app.enums.violation.ViolationTypeEnum; +import com.red.circle.other.infra.database.rds.service.dynamic.DynamicBlacklistService; +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.model.cmd.dynamic.DynamicBlacklistCmd; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +/** + * 添加黑名单执行器. + * + * @author pengshigang + * @since 2025-01-29 + */ +@Component +@RequiredArgsConstructor +public class DynamicBlacklistAddCmdExe { + + private final AdministratorService administratorService; + private final AdministratorAuthService administratorAuthService; + private final DynamicBlacklistService dynamicBlacklistService; + + public void execute(DynamicBlacklistAddCmd cmd) { + // 验证管理员权限 + ViolationTypeEnum violationTypeEnum = ViolationTypeEnum.CREATE_CONTENT; + ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION, + administratorService.existsAdmin(cmd.getReqUserId()) && + administratorAuthService.existsAuth(cmd.requiredReqUserId(), violationTypeEnum.name())); + + // 添加黑名单 + DynamicBlacklistCmd blacklistCmd = new DynamicBlacklistCmd(); + blacklistCmd.setUserId(cmd.getUserId()); + blacklistCmd.setReqUserId(cmd.getReqUserId()); + blacklistCmd.setSysOrigin(cmd.getReqSysOrigin().getOrigin()); + dynamicBlacklistService.add(blacklistCmd); + } + +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicBlacklistDelCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicBlacklistDelCmdExe.java new file mode 100644 index 00000000..ae7d9c0b --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/dynamic/DynamicBlacklistDelCmdExe.java @@ -0,0 +1,38 @@ +package com.red.circle.other.app.command.dynamic; + +import com.red.circle.framework.core.asserts.ResponseAssert; +import com.red.circle.framework.core.response.CommonErrorCode; +import com.red.circle.other.app.dto.cmd.dynamic.DynamicBlacklistDelCmd; +import com.red.circle.other.app.enums.violation.ViolationTypeEnum; +import com.red.circle.other.infra.database.rds.service.dynamic.DynamicBlacklistService; +import com.red.circle.other.infra.database.rds.service.sys.AdministratorAuthService; +import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +/** + * 删除黑名单执行器. + * + * @author pengshigang + * @since 2025-01-29 + */ +@Component +@RequiredArgsConstructor +public class DynamicBlacklistDelCmdExe { + + private final AdministratorService administratorService; + private final AdministratorAuthService administratorAuthService; + private final DynamicBlacklistService dynamicBlacklistService; + + public void execute(DynamicBlacklistDelCmd cmd) { + // 验证管理员权限 + ViolationTypeEnum violationTypeEnum = ViolationTypeEnum.CREATE_CONTENT; + ResponseAssert.isTrue(CommonErrorCode.INSUFFICIENT_PERMISSION, + administratorService.existsAdmin(cmd.getReqUserId()) && + administratorAuthService.existsAuth(cmd.requiredReqUserId(), violationTypeEnum.name())); + + // 删除黑名单 + dynamicBlacklistService.deleteByUserId(cmd.getUserId()); + } + +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/enums/violation/ViolationTypeEnum.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/enums/violation/ViolationTypeEnum.java index ac5aad3a..df7504f6 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/enums/violation/ViolationTypeEnum.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/enums/violation/ViolationTypeEnum.java @@ -43,7 +43,24 @@ public enum ViolationTypeEnum { /** * 房间主题 */ - ROOM_THEME(6, "房间主题", TargetTypeEnum.ROOM); + ROOM_THEME(6, "房间主题", TargetTypeEnum.ROOM), + + /** + * 发布动态 + */ + CREATE_CONTENT(7, "发布动态", TargetTypeEnum.USER), + + /** + * 删除动态 + */ + DELETE_CONTENT(8, "删除动态", TargetTypeEnum.USER), + + /** + * 删除评论 + */ + DELETE_COMMENT(9, "删除评论", TargetTypeEnum.USER), + + ; /** * 类型编码 diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/dynamic/DynamicServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/dynamic/DynamicServiceImpl.java index 53af19df..88b9c4fd 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/dynamic/DynamicServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/dynamic/DynamicServiceImpl.java @@ -4,6 +4,8 @@ import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.common.business.dto.cmd.IdLongCmd; import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd; import com.red.circle.framework.dto.PageResult; +import com.red.circle.other.app.command.dynamic.DynamicBlacklistAddCmdExe; +import com.red.circle.other.app.command.dynamic.DynamicBlacklistDelCmdExe; import com.red.circle.other.app.command.dynamic.DynamicCheckSendPermissionCmdExe; import com.red.circle.other.app.command.dynamic.DynamicCommentCmdExe; import com.red.circle.other.app.command.dynamic.DynamicCommentLikeCmdExe; @@ -71,6 +73,8 @@ public class DynamicServiceImpl implements DynamicService { private final DynamicMessageAllDelCmdExe dynamicMessageAllDelCmdExe; private final DynamicMessageUpdateReadCmdExe dynamicMessageUpdateReadCmdExe; private final DynamicCheckSendPermissionCmdExe dynamicCheckSendPermissionCmdExe; + private final DynamicBlacklistAddCmdExe dynamicBlacklistAddCmdExe; + private final DynamicBlacklistDelCmdExe dynamicBlacklistDelCmdExe; @Override public Long createDynamic(DynamicContentAddCmd cmd) { @@ -187,4 +191,14 @@ public class DynamicServiceImpl implements DynamicService { return dynamicCheckSendPermissionCmdExe.execute2(cmd); } + @Override + public void addBlacklist(DynamicBlacklistAddCmd cmd) { + dynamicBlacklistAddCmdExe.execute(cmd); + } + + @Override + public void deleteBlacklist(DynamicBlacklistDelCmd cmd) { + dynamicBlacklistDelCmdExe.execute(cmd); + } + } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicBlacklistAddCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicBlacklistAddCmd.java new file mode 100644 index 00000000..dc0c649f --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicBlacklistAddCmd.java @@ -0,0 +1,26 @@ +package com.red.circle.other.app.dto.cmd.dynamic; + +import com.red.circle.common.business.dto.cmd.AppExtCommand; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 动态-添加黑名单. + * + * @author pengshigang + * @since 2025-01-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DynamicBlacklistAddCmd extends AppExtCommand { + + /** + * 用户ID. + * + * @eo.required + */ + @NotNull(message = "用户ID不能为空") + private Long userId; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicBlacklistDelCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicBlacklistDelCmd.java new file mode 100644 index 00000000..62f0fbeb --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/dynamic/DynamicBlacklistDelCmd.java @@ -0,0 +1,26 @@ +package com.red.circle.other.app.dto.cmd.dynamic; + +import com.red.circle.common.business.dto.cmd.AppExtCommand; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 动态-删除黑名单. + * + * @author pengshigang + * @since 2025-01-29 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class DynamicBlacklistDelCmd extends AppExtCommand { + + /** + * 用户ID. + * + * @eo.required + */ + @NotNull(message = "用户ID不能为空") + private Long userId; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/dynamic/DynamicService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/dynamic/DynamicService.java index a665d54c..8a47a683 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/dynamic/DynamicService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/dynamic/DynamicService.java @@ -145,4 +145,14 @@ public interface DynamicService { * 校验发送动态权限. */ Boolean checkSendPermission2(AppExtCommand cmd); + + /** + * 添加黑名单. + */ + void addBlacklist(DynamicBlacklistAddCmd cmd); + + /** + * 删除黑名单. + */ + void deleteBlacklist(DynamicBlacklistDelCmd cmd); }