新增发布动态黑名单功能
This commit is contained in:
parent
603b952548
commit
6756a89ce5
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
@ -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),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 类型编码
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
}
|
||||
@ -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;
|
||||
|
||||
}
|
||||
@ -145,4 +145,14 @@ public interface DynamicService {
|
||||
* 校验发送动态权限.
|
||||
*/
|
||||
Boolean checkSendPermission2(AppExtCommand cmd);
|
||||
|
||||
/**
|
||||
* 添加黑名单.
|
||||
*/
|
||||
void addBlacklist(DynamicBlacklistAddCmd cmd);
|
||||
|
||||
/**
|
||||
* 删除黑名单.
|
||||
*/
|
||||
void deleteBlacklist(DynamicBlacklistDelCmd cmd);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user