批量删除系统参数配置

pull/57/head
Liyanjun 2023-07-03 21:16:51 +08:00
parent 8ba907372d
commit c713fdffbe
4 changed files with 53 additions and 1 deletions

View File

@ -77,6 +77,17 @@ public class SysConfigController {
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<>();
}
/**
*
*

View File

@ -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.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest.batchDelete;
import cn.stylefeng.roses.kernel.validator.api.validators.flag.FlagValue;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Set;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
@ -98,4 +102,10 @@ public class SysConfigParam extends BaseRequest {
@ChineseDescription("配置所属分类的编码")
private String groupCode;
/**
* id
*/
@NotEmpty(message = "configId集合不能为空", groups = batchDelete.class)
@ChineseDescription("configId集合用在批量删除")
private Set<Long> configIdList;
}

View File

@ -58,6 +58,14 @@ public interface SysConfigService extends IService<SysConfig>, InitConfigApi {
*/
void del(SysConfigParam sysConfigParam);
/**
*
*
* @author liyanjun
* @date 2023/07/03 21:29
*/
void batchDelete(SysConfigParam sysConfigParam);
/**
*
*

View File

@ -313,4 +313,27 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
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());
}
}
}