【7.6.0】【config】更新修改配置类型

pull/57/head
fengshuonan 2023-06-28 18:12:10 +08:00
parent 94b92b3413
commit 5cb58e9c7a
6 changed files with 67 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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());
}
}
}

View File

@ -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);
}
/**
*
*

View File

@ -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
*

View File

@ -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) {