mirror of https://gitee.com/stylefeng/roses
【7.6.0】【config】更新修改配置类型
parent
94b92b3413
commit
5cb58e9c7a
|
@ -60,4 +60,12 @@ public class SimpleDict {
|
|||
@ChineseDescription("编码")
|
||||
private String code;
|
||||
|
||||
public SimpleDict() {
|
||||
}
|
||||
|
||||
public SimpleDict(Long id, String name, String code) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,4 +103,14 @@ public interface SysConfigService extends IService<SysConfig>, InitConfigApi {
|
|||
*/
|
||||
InitConfigResponse getInitConfigs();
|
||||
|
||||
/**
|
||||
* 更新所有config所属的字典类型编码
|
||||
*
|
||||
* @param originTypeCode 原有的typeCode
|
||||
* @param destTypeCode 更新后的typeCode
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/28 18:02
|
||||
*/
|
||||
void updateSysConfigTypeCode(String originTypeCode, String destTypeCode);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import cn.stylefeng.roses.kernel.dict.api.DictTypeApi;
|
|||
import cn.stylefeng.roses.kernel.dict.api.pojo.SimpleDictUpdateParam;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
@ -49,6 +50,7 @@ public class SysConfigTypeService {
|
|||
* @author fengshuonan
|
||||
* @since 2023/6/28 17:07
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(SysConfigTypeParam sysConfigTypeParam) {
|
||||
|
||||
// 查询字典类型
|
||||
|
@ -66,13 +68,19 @@ public class SysConfigTypeService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 更新字典类型
|
||||
* 新增系统配置类型
|
||||
* <p>
|
||||
* 针对字典类型编码为config_group的字典修改一个条目
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/28 17:32
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(SysConfigTypeParam sysConfigTypeParam) {
|
||||
|
||||
// 查询旧的字典编码
|
||||
SimpleDict originDictInfo = dictApi.getDictByDictId(sysConfigTypeParam.getConfigTypeId());
|
||||
|
||||
// 查询字典类型
|
||||
Long dictTypeId = dictTypeApi.getDictTypeIdByDictTypeCode(ConfigConstants.CONFIG_GROUP_DICT_TYPE_CODE);
|
||||
|
||||
|
@ -86,6 +94,12 @@ public class SysConfigTypeService {
|
|||
|
||||
// 编辑字典
|
||||
dictApi.simpleEditDict(simpleDictAddParam);
|
||||
|
||||
// 如果更新了字典的编码,则属于该类型下的字典配置编码也都修改
|
||||
if (!originDictInfo.getCode().equals(sysConfigTypeParam.getConfigTypeCode())) {
|
||||
sysConfigService.updateSysConfigTypeCode(originDictInfo.getCode(), sysConfigTypeParam.getConfigTypeCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -251,6 +251,14 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||
return initConfigResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysConfigTypeCode(String originTypeCode, String destTypeCode) {
|
||||
LambdaUpdateWrapper<SysConfig> sysConfigLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
sysConfigLambdaUpdateWrapper.eq(SysConfig::getGroupCode, originTypeCode);
|
||||
sysConfigLambdaUpdateWrapper.set(SysConfig::getGroupCode, destTypeCode);
|
||||
this.update(sysConfigLambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统参数配置
|
||||
*
|
||||
|
|
|
@ -68,6 +68,14 @@ public interface DictApi {
|
|||
*/
|
||||
void deleteByDictId(Long dictId);
|
||||
|
||||
/**
|
||||
* 通过字典id获取字典的名称和编码信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/5/4 21:25
|
||||
*/
|
||||
SimpleDict getDictByDictId(Long dictId);
|
||||
|
||||
/**
|
||||
* 通过字典id获取字典的名称
|
||||
*
|
||||
|
|
|
@ -259,6 +259,24 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, SysDict> implements
|
|||
this.removeById(dictId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleDict getDictByDictId(Long dictId) {
|
||||
if (dictId == null) {
|
||||
return new SimpleDict();
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SysDict> sysDictLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysDictLambdaQueryWrapper.eq(SysDict::getDictId, dictId);
|
||||
sysDictLambdaQueryWrapper.select(SysDict::getDictName, SysDict::getDictCode, SysDict::getDictId);
|
||||
SysDict sysDict = this.getOne(sysDictLambdaQueryWrapper, false);
|
||||
|
||||
if (sysDict == null) {
|
||||
return new SimpleDict();
|
||||
} else {
|
||||
return new SimpleDict(sysDict.getDictId(), sysDict.getDictName(), sysDict.getDictCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDictNameByDictId(Long dictId) {
|
||||
if (dictId == null) {
|
||||
|
|
Loading…
Reference in New Issue