mirror of https://gitee.com/stylefeng/roses
【7.6.0】【config】配置类型:更新详情接口
parent
b0b04649fc
commit
6010fd714f
|
@ -26,6 +26,7 @@ package cn.stylefeng.roses.kernel.config.modular.controller;
|
||||||
|
|
||||||
import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigTypeParam;
|
import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigTypeParam;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.service.SysConfigTypeService;
|
import cn.stylefeng.roses.kernel.config.modular.service.SysConfigTypeService;
|
||||||
|
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||||
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.response.ResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||||
|
@ -102,6 +103,18 @@ public class SysConfigTypeController {
|
||||||
return new SuccessResponseData<>();
|
return new SuccessResponseData<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取配置类型的详情
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/6/28 17:00
|
||||||
|
*/
|
||||||
|
@GetResource(name = "获取配置类型的详情", path = "/sysConfigType/detail")
|
||||||
|
public ResponseData<DictDetail> detail(@RequestBody @Validated(BaseRequest.detail.class) SysConfigTypeParam sysConfigTypeParam) {
|
||||||
|
DictDetail detail = sysConfigTypeService.detail(sysConfigTypeParam);
|
||||||
|
return new SuccessResponseData<>(detail);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class SysConfigTypeParam extends BaseRequest {
|
||||||
/**
|
/**
|
||||||
* 配置类型id
|
* 配置类型id
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "配置类型id不能为空", groups = {edit.class, delete.class})
|
@NotBlank(message = "配置类型id不能为空", groups = {edit.class, delete.class, detail.class})
|
||||||
@ChineseDescription("配置类型id")
|
@ChineseDescription("配置类型id")
|
||||||
private Long configTypeId;
|
private Long configTypeId;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import cn.stylefeng.roses.kernel.config.api.constants.ConfigConstants;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigTypeParam;
|
import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigTypeParam;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.DictApi;
|
import cn.stylefeng.roses.kernel.dict.api.DictApi;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.DictTypeApi;
|
import cn.stylefeng.roses.kernel.dict.api.DictTypeApi;
|
||||||
|
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.pojo.SimpleDictUpdateParam;
|
import cn.stylefeng.roses.kernel.dict.api.pojo.SimpleDictUpdateParam;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -79,7 +80,7 @@ public class SysConfigTypeService {
|
||||||
public void edit(SysConfigTypeParam sysConfigTypeParam) {
|
public void edit(SysConfigTypeParam sysConfigTypeParam) {
|
||||||
|
|
||||||
// 查询旧的字典编码
|
// 查询旧的字典编码
|
||||||
SimpleDict originDictInfo = dictApi.getDictByDictId(sysConfigTypeParam.getConfigTypeId());
|
DictDetail originDictInfo = dictApi.getDictByDictId(sysConfigTypeParam.getConfigTypeId());
|
||||||
|
|
||||||
// 查询字典类型
|
// 查询字典类型
|
||||||
Long dictTypeId = dictTypeApi.getDictTypeIdByDictTypeCode(ConfigConstants.CONFIG_GROUP_DICT_TYPE_CODE);
|
Long dictTypeId = dictTypeApi.getDictTypeIdByDictTypeCode(ConfigConstants.CONFIG_GROUP_DICT_TYPE_CODE);
|
||||||
|
@ -96,8 +97,8 @@ public class SysConfigTypeService {
|
||||||
dictApi.simpleEditDict(simpleDictAddParam);
|
dictApi.simpleEditDict(simpleDictAddParam);
|
||||||
|
|
||||||
// 如果更新了字典的编码,则属于该类型下的字典配置编码也都修改
|
// 如果更新了字典的编码,则属于该类型下的字典配置编码也都修改
|
||||||
if (!originDictInfo.getCode().equals(sysConfigTypeParam.getConfigTypeCode())) {
|
if (!originDictInfo.getDictCode().equals(sysConfigTypeParam.getConfigTypeCode())) {
|
||||||
sysConfigService.updateSysConfigTypeCode(originDictInfo.getCode(), sysConfigTypeParam.getConfigTypeCode());
|
sysConfigService.updateSysConfigTypeCode(originDictInfo.getDictCode(), sysConfigTypeParam.getConfigTypeCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -114,13 +115,25 @@ public class SysConfigTypeService {
|
||||||
public void delete(SysConfigTypeParam sysConfigTypeParam) {
|
public void delete(SysConfigTypeParam sysConfigTypeParam) {
|
||||||
|
|
||||||
// 获取字典的编码
|
// 获取字典的编码
|
||||||
SimpleDict originDictInfo = dictApi.getDictByDictId(sysConfigTypeParam.getConfigTypeId());
|
DictDetail originDictInfo = dictApi.getDictByDictId(sysConfigTypeParam.getConfigTypeId());
|
||||||
|
|
||||||
// 删除字典
|
// 删除字典
|
||||||
this.dictApi.deleteByDictId(sysConfigTypeParam.getConfigTypeId());
|
this.dictApi.deleteByDictId(sysConfigTypeParam.getConfigTypeId());
|
||||||
|
|
||||||
// 删除配置类型对应的所有配置
|
// 删除配置类型对应的所有配置
|
||||||
this.sysConfigService.delByConfigCode(originDictInfo.getCode());
|
this.sysConfigService.delByConfigCode(originDictInfo.getDictCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取配置类型详情
|
||||||
|
* <p>
|
||||||
|
* 本质是直接获取字典的详情
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/6/28 18:45
|
||||||
|
*/
|
||||||
|
public DictDetail detail(SysConfigTypeParam sysConfigTypeParam) {
|
||||||
|
return this.dictApi.getDictByDictId(sysConfigTypeParam.getConfigTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
*/
|
*/
|
||||||
package cn.stylefeng.roses.kernel.dict.api;
|
package cn.stylefeng.roses.kernel.dict.api;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.pojo.SimpleDictUpdateParam;
|
import cn.stylefeng.roses.kernel.dict.api.pojo.SimpleDictUpdateParam;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ public interface DictApi {
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @since 2023/5/4 21:25
|
* @since 2023/5/4 21:25
|
||||||
*/
|
*/
|
||||||
SimpleDict getDictByDictId(Long dictId);
|
DictDetail getDictByDictId(Long dictId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过字典id获取字典的名称
|
* 通过字典id获取字典的名称
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package cn.stylefeng.roses.kernel.dict.api.pojo;
|
||||||
|
|
||||||
|
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典信息详情
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/6/28 18:41
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class DictDetail {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典id
|
||||||
|
*/
|
||||||
|
@ChineseDescription("字典id")
|
||||||
|
private Long dictId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典名称
|
||||||
|
*/
|
||||||
|
@ChineseDescription("字典名称")
|
||||||
|
private String dictName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典编码
|
||||||
|
*/
|
||||||
|
@ChineseDescription("字典编码")
|
||||||
|
private String dictCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序,带小数点
|
||||||
|
*/
|
||||||
|
@ChineseDescription("排序")
|
||||||
|
private BigDecimal dictSort;
|
||||||
|
|
||||||
|
public DictDetail() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DictDetail(Long dictId, String dictCode, String dictName, BigDecimal dictSort) {
|
||||||
|
this.dictId = dictId;
|
||||||
|
this.dictCode = dictCode;
|
||||||
|
this.dictName = dictName;
|
||||||
|
this.dictSort = dictSort;
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.exception.DictException;
|
import cn.stylefeng.roses.kernel.dict.api.exception.DictException;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.exception.enums.DictExceptionEnum;
|
import cn.stylefeng.roses.kernel.dict.api.exception.enums.DictExceptionEnum;
|
||||||
|
import cn.stylefeng.roses.kernel.dict.api.pojo.DictDetail;
|
||||||
import cn.stylefeng.roses.kernel.dict.api.pojo.SimpleDictUpdateParam;
|
import cn.stylefeng.roses.kernel.dict.api.pojo.SimpleDictUpdateParam;
|
||||||
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict;
|
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict;
|
||||||
import cn.stylefeng.roses.kernel.dict.modular.factory.DictFactory;
|
import cn.stylefeng.roses.kernel.dict.modular.factory.DictFactory;
|
||||||
|
@ -260,20 +261,20 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, SysDict> implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SimpleDict getDictByDictId(Long dictId) {
|
public DictDetail getDictByDictId(Long dictId) {
|
||||||
if (dictId == null) {
|
if (dictId == null) {
|
||||||
return new SimpleDict();
|
return new DictDetail();
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<SysDict> sysDictLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysDict> sysDictLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
sysDictLambdaQueryWrapper.eq(SysDict::getDictId, dictId);
|
sysDictLambdaQueryWrapper.eq(SysDict::getDictId, dictId);
|
||||||
sysDictLambdaQueryWrapper.select(SysDict::getDictName, SysDict::getDictCode, SysDict::getDictId);
|
sysDictLambdaQueryWrapper.select(SysDict::getDictName, SysDict::getDictCode, SysDict::getDictId, SysDict::getDictSort);
|
||||||
SysDict sysDict = this.getOne(sysDictLambdaQueryWrapper, false);
|
SysDict sysDict = this.getOne(sysDictLambdaQueryWrapper, false);
|
||||||
|
|
||||||
if (sysDict == null) {
|
if (sysDict == null) {
|
||||||
return new SimpleDict();
|
return new DictDetail();
|
||||||
} else {
|
} else {
|
||||||
return new SimpleDict(sysDict.getDictId(), sysDict.getDictName(), sysDict.getDictCode());
|
return new DictDetail(sysDict.getDictId(), sysDict.getDictName(), sysDict.getDictCode(), sysDict.getDictSort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue