Merge branch 'dev' into test

This commit is contained in:
chenwenjian 2023-08-17 15:06:16 +08:00
commit 4c79f13c9d
5 changed files with 58 additions and 7 deletions

View File

@ -22,7 +22,7 @@ public interface BlackAndWhiteListApi {
/** /**
* 创建黑名单或白名单 * 创建黑名单或白名单
* @param req 包含module和param两个字段 * @param req 包含type,module,params三个字段
* @return 记录id * @return 记录id
*/ */
@PostMapping("api/black-white-list/create") @PostMapping("api/black-white-list/create")
@ -30,7 +30,7 @@ public interface BlackAndWhiteListApi {
/** /**
* 删除黑名单或白名单 * 删除黑名单或白名单
* @param req 包含module和param两个字段 * @param req 包含type,module,params三个字段
* @return void * @return void
*/ */
@PostMapping("api/black-white-list/delete") @PostMapping("api/black-white-list/delete")
@ -38,7 +38,7 @@ public interface BlackAndWhiteListApi {
/** /**
* 查询黑名单或白名单 * 查询黑名单或白名单
* @param req 包含module和param两个字段 * @param req 包含type,module,params三个字段
* @return 黑白名单记录列表 * @return 黑白名单记录列表
*/ */
@PostMapping("api/black-white-list/query") @PostMapping("api/black-white-list/query")
@ -46,7 +46,7 @@ public interface BlackAndWhiteListApi {
/** /**
* 判断指定模块指定参数记录是否在黑名单或白名单中 * 判断指定模块指定参数记录是否在黑名单或白名单中
* @param req 包含module和param两个字段 * @param req 包含type,module,params三个字段
* @return 若记录存在则返回true否则返回false * @return 若记录存在则返回true否则返回false
*/ */
@PostMapping("api/black-white-list/is-in") @PostMapping("api/black-white-list/is-in")

View File

@ -0,0 +1,42 @@
package cn.axzo.nanopart.api.constant.enums;
import java.util.Arrays;
/**
* @author chenwenjian
* @date 2023/8/17 14:17
* @description 名单类型枚举
* @modifiedBy
* @version: 1.0
*/
public enum ListTypeEnum {
/**
* 黑名单
*/
BLACK_LIST(0,"黑名单"),
/**
* 白名单
*/
WHITE_LIST(1,"白名单");
private final Integer value;
private final String description;
public Integer getValue() {
return value;
}
public String getDescription() {
return description;
}
ListTypeEnum(Integer value, String description) {
this.value = value;
this.description = description;
}
public static ListTypeEnum getByType(Integer value){
return Arrays.stream(values()).filter(l -> l.getValue().equals(value)).findFirst().orElse(null);
}
}

View File

@ -1,8 +1,10 @@
package cn.axzo.nanopart.api.request; package cn.axzo.nanopart.api.request;
import cn.axzo.nanopart.api.constant.enums.ListTypeEnum;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Map; import java.util.Map;
/** /**
@ -15,7 +17,11 @@ import java.util.Map;
@Data @Data
public class BlackAndWhiteListReq { public class BlackAndWhiteListReq {
@NotNull(message = "名单类型错误")
private ListTypeEnum type;
@NotBlank(message = "模块名不能为空") @NotBlank(message = "模块名不能为空")
private String module; private String module;
private Map<String,Object> param; private Map<String,Object> param;
} }

View File

@ -20,6 +20,8 @@ import java.util.Map;
@TableName(value = "saas_black_white_list",autoResultMap = true) @TableName(value = "saas_black_white_list",autoResultMap = true)
public class SaasBlackWhiteList extends BaseEntity<SaasBlackWhiteList> { public class SaasBlackWhiteList extends BaseEntity<SaasBlackWhiteList> {
private Integer type;
/** /**
* 模块名 * 模块名
*/ */

View File

@ -33,7 +33,7 @@ public class BlackAndWhiteListRepository extends ServiceImpl<BlackAndWhiteListMa
private final BlackAndWhiteListMapper blackAndWhiteListMapper; private final BlackAndWhiteListMapper blackAndWhiteListMapper;
public Long create(BlackAndWhiteListReq req){ public Long create(BlackAndWhiteListReq req){
SaasBlackWhiteList blackWhiteList = BeanMapper.copyBean(req, SaasBlackWhiteList.class); SaasBlackWhiteList blackWhiteList = BeanMapper.copyBean(req, SaasBlackWhiteList.class, (req1, saasBlackWhiteList) -> saasBlackWhiteList.setType(req1.getType().getValue()));
Date nowTime = new Date(System.currentTimeMillis()); Date nowTime = new Date(System.currentTimeMillis());
blackWhiteList.setCreateAt(nowTime); blackWhiteList.setCreateAt(nowTime);
blackWhiteList.setUpdateAt(nowTime); blackWhiteList.setUpdateAt(nowTime);
@ -57,7 +57,8 @@ public class BlackAndWhiteListRepository extends ServiceImpl<BlackAndWhiteListMa
public List<SaasBlackWhiteList> detail(BlackAndWhiteListReq req) { public List<SaasBlackWhiteList> detail(BlackAndWhiteListReq req) {
QueryWrapper<SaasBlackWhiteList> queryWrapper = new QueryWrapper<>(); QueryWrapper<SaasBlackWhiteList> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StringUtils.isNotBlank(req.getModule()),"module",req.getModule()) queryWrapper.eq("type",req.getType().getValue())
.eq(StringUtils.isNotBlank(req.getModule()),"module",req.getModule())
.eq("is_delete",0); .eq("is_delete",0);
buildQueryWrapper(queryWrapper, req.getParam(), ""); buildQueryWrapper(queryWrapper, req.getParam(), "");
return blackAndWhiteListMapper.selectList(queryWrapper); return blackAndWhiteListMapper.selectList(queryWrapper);