mirror of https://gitee.com/stylefeng/roses
批量删除系统参数配置
parent
8ba907372d
commit
c713fdffbe
|
@ -77,6 +77,17 @@ public class SysConfigController {
|
||||||
return new SuccessResponseData<>();
|
return new SuccessResponseData<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除系统参数配置
|
||||||
|
*
|
||||||
|
* @author liyanjun
|
||||||
|
* @date 2023/07/03 21:29
|
||||||
|
*/
|
||||||
|
@PostResource(name = "批量删除系统参数配置", path = "/sysConfig/batchDelete")
|
||||||
|
public ResponseData<?> batchDelete(@RequestBody @Validated(SysConfigParam.delete.class) SysConfigParam sysConfigParam) {
|
||||||
|
sysConfigService.batchDelete(sysConfigParam);
|
||||||
|
return new SuccessResponseData<>();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 编辑系统参数配置
|
* 编辑系统参数配置
|
||||||
*
|
*
|
||||||
|
|
|
@ -26,11 +26,15 @@ package cn.stylefeng.roses.kernel.config.modular.pojo.param;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest.batchDelete;
|
||||||
import cn.stylefeng.roses.kernel.validator.api.validators.flag.FlagValue;
|
import cn.stylefeng.roses.kernel.validator.api.validators.flag.FlagValue;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,4 +102,10 @@ public class SysConfigParam extends BaseRequest {
|
||||||
@ChineseDescription("配置所属分类的编码")
|
@ChineseDescription("配置所属分类的编码")
|
||||||
private String groupCode;
|
private String groupCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色id集合,用在批量删除
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "configId集合不能为空", groups = batchDelete.class)
|
||||||
|
@ChineseDescription("configId集合,用在批量删除")
|
||||||
|
private Set<Long> configIdList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,14 @@ public interface SysConfigService extends IService<SysConfig>, InitConfigApi {
|
||||||
*/
|
*/
|
||||||
void del(SysConfigParam sysConfigParam);
|
void del(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除系统参数配置
|
||||||
|
*
|
||||||
|
* @author liyanjun
|
||||||
|
* @date 2023/07/03 21:29
|
||||||
|
*/
|
||||||
|
void batchDelete(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除系统参数配置
|
* 删除系统参数配置
|
||||||
*
|
*
|
||||||
|
|
|
@ -313,4 +313,27 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void batchDelete(SysConfigParam sysConfigParam) {
|
||||||
|
|
||||||
|
for(Long configId:sysConfigParam.getConfigIdList()){
|
||||||
|
// 1.根据id获取常量
|
||||||
|
SysConfig sysConfig = this.getById(configId);
|
||||||
|
if (ObjectUtil.isEmpty(sysConfig) || sysConfig.getDelFlag().equals(YesOrNotEnum.Y.getCode())) {
|
||||||
|
throw new ConfigException(ConfigExceptionEnum.CONFIG_NOT_EXIST, "id: " + sysConfigParam.getConfigId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.不能删除系统参数
|
||||||
|
if (YesOrNotEnum.Y.getCode().equals(configId)) {
|
||||||
|
throw new ConfigException(ConfigExceptionEnum.CONFIG_SYS_CAN_NOT_DELETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.逻辑删除
|
||||||
|
this.removeById(configId);
|
||||||
|
|
||||||
|
// 4.删除对应context
|
||||||
|
ConfigContext.me().deleteConfig(sysConfig.getConfigCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue