【7.6.0】【config】配置类型:更新详情接口

pull/57/head
fengshuonan 2023-06-28 18:46:55 +08:00
parent b0b04649fc
commit 6010fd714f
6 changed files with 90 additions and 12 deletions

View File

@ -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.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.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
@ -102,6 +103,18 @@ public class SysConfigTypeController {
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);
}
}

View File

@ -45,7 +45,7 @@ public class SysConfigTypeParam extends BaseRequest {
/**
* id
*/
@NotBlank(message = "配置类型id不能为空", groups = {edit.class, delete.class})
@NotBlank(message = "配置类型id不能为空", groups = {edit.class, delete.class, detail.class})
@ChineseDescription("配置类型id")
private Long configTypeId;

View File

@ -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.dict.api.DictApi;
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.rule.pojo.dict.SimpleDict;
import org.springframework.stereotype.Service;
@ -79,7 +80,7 @@ public class SysConfigTypeService {
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);
@ -96,8 +97,8 @@ public class SysConfigTypeService {
dictApi.simpleEditDict(simpleDictAddParam);
// 如果更新了字典的编码,则属于该类型下的字典配置编码也都修改
if (!originDictInfo.getCode().equals(sysConfigTypeParam.getConfigTypeCode())) {
sysConfigService.updateSysConfigTypeCode(originDictInfo.getCode(), sysConfigTypeParam.getConfigTypeCode());
if (!originDictInfo.getDictCode().equals(sysConfigTypeParam.getConfigTypeCode())) {
sysConfigService.updateSysConfigTypeCode(originDictInfo.getDictCode(), sysConfigTypeParam.getConfigTypeCode());
}
}
@ -114,13 +115,25 @@ public class SysConfigTypeService {
public void delete(SysConfigTypeParam sysConfigTypeParam) {
// 获取字典的编码
SimpleDict originDictInfo = dictApi.getDictByDictId(sysConfigTypeParam.getConfigTypeId());
DictDetail originDictInfo = dictApi.getDictByDictId(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());
}
}

View File

@ -24,6 +24,7 @@
*/
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.rule.pojo.dict.SimpleDict;
@ -74,7 +75,7 @@ public interface DictApi {
* @author fengshuonan
* @since 2023/5/4 21:25
*/
SimpleDict getDictByDictId(Long dictId);
DictDetail getDictByDictId(Long dictId);
/**
* id

View File

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

View File

@ -29,6 +29,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
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.pojo.DictDetail;
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.factory.DictFactory;
@ -260,20 +261,20 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, SysDict> implements
}
@Override
public SimpleDict getDictByDictId(Long dictId) {
public DictDetail getDictByDictId(Long dictId) {
if (dictId == null) {
return new SimpleDict();
return new DictDetail();
}
LambdaQueryWrapper<SysDict> sysDictLambdaQueryWrapper = new LambdaQueryWrapper<>();
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);
if (sysDict == null) {
return new SimpleDict();
return new DictDetail();
} else {
return new SimpleDict(sysDict.getDictId(), sysDict.getDictName(), sysDict.getDictCode());
return new DictDetail(sysDict.getDictId(), sysDict.getDictName(), sysDict.getDictCode(), sysDict.getDictSort());
}
}