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

pull/57/head
fengshuonan 2023-06-28 17:31:34 +08:00
parent 1cf6010683
commit 79b4c68a73
6 changed files with 165 additions and 9 deletions

View File

@ -3,6 +3,8 @@ package cn.stylefeng.roses.kernel.config.modular.service;
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.SimpleDictAddParam;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import org.springframework.stereotype.Service;
@ -21,6 +23,9 @@ public class SysConfigTypeService {
@Resource
private DictApi dictApi;
@Resource
private DictTypeApi dictTypeApi;
/**
*
* <p>
@ -43,6 +48,18 @@ public class SysConfigTypeService {
*/
public void add(SysConfigTypeParam sysConfigTypeParam) {
// 查询字典类型
Long dictTypeId = dictTypeApi.getDictTypeIdByDictTypeCode(ConfigConstants.CONFIG_GROUP_DICT_TYPE_CODE);
// 配置类型信息转化为新增字典的参数信息
SimpleDictAddParam simpleDictAddParam = new SimpleDictAddParam();
simpleDictAddParam.setDictTypeId(dictTypeId);
simpleDictAddParam.setDictName(sysConfigTypeParam.getConfigTypeName());
simpleDictAddParam.setDictCode(sysConfigTypeParam.getConfigTypeCode());
simpleDictAddParam.setDictSort(sysConfigTypeParam.getConfigTypeSort());
// 新增一个字典
dictApi.simpleAddDict(simpleDictAddParam);
}
}

View File

@ -24,6 +24,7 @@
*/
package cn.stylefeng.roses.kernel.dict.api;
import cn.stylefeng.roses.kernel.dict.api.pojo.SimpleDictAddParam;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import java.util.List;
@ -75,4 +76,12 @@ public interface DictApi {
*/
String getDictNameByDictId(Long dictId);
/**
*
*
* @author fengshuonan
* @since 2023/6/28 17:26
*/
void simpleAddDict(SimpleDictAddParam simpleDictAddParam);
}

View File

@ -0,0 +1,43 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
package cn.stylefeng.roses.kernel.dict.api;
/**
* api
*
* @author fengshuonan
* @since 2023/6/28 17:24
*/
public interface DictTypeApi {
/**
* id
*
* @author fengshuonan
* @since 2023/6/27 17:39
*/
Long getDictTypeIdByDictTypeCode(String dictTypeCode);
}

View File

@ -0,0 +1,78 @@
/*
* Copyright [2020-2030] [https://www.stylefeng.cn]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* GunsAPACHE LICENSE 2.0使
*
* 1.LICENSE
* 2.Guns
* 3.
* 4. https://gitee.com/stylefeng/guns
* 5. https://gitee.com/stylefeng/guns
* 6.
*/
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 17:21
*/
@Data
public class SimpleDictAddParam {
/**
* id
*/
@ChineseDescription("字典id")
private Long dictId;
/**
* id
*/
@ChineseDescription("字典类型id")
private Long dictTypeId;
/**
*
*/
@ChineseDescription("字典名称")
private String dictName;
/**
*
*/
@ChineseDescription("字典编码")
private String dictCode;
/**
* id
*/
@ChineseDescription("上级字典的id")
private Long dictParentId = -1L;
/**
*
*/
@ChineseDescription("排序")
private BigDecimal dictSort;
}

View File

@ -25,6 +25,7 @@
package cn.stylefeng.roses.kernel.dict.modular.service;
import cn.stylefeng.roses.kernel.dict.api.DictTypeApi;
import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType;
import cn.stylefeng.roses.kernel.dict.modular.pojo.request.DictTypeRequest;
import com.baomidou.mybatisplus.extension.service.IService;
@ -37,7 +38,7 @@ import java.util.List;
* @author fengshuonan
* @since 2020/10/29 18:54
*/
public interface DictTypeService extends IService<SysDictType> {
public interface DictTypeService extends IService<SysDictType>, DictTypeApi {
/**
*
@ -85,12 +86,4 @@ public interface DictTypeService extends IService<SysDictType> {
*/
List<SysDictType> findList(DictTypeRequest dictTypeRequest);
/**
* id
*
* @author fengshuonan
* @since 2023/6/27 17:39
*/
Long getDictTypeIdByDictTypeCode(String dictTypeCode);
}

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.SimpleDictAddParam;
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.mapper.DictMapper;
@ -39,6 +40,7 @@ import cn.stylefeng.roses.kernel.dict.modular.service.DictTypeService;
import cn.stylefeng.roses.kernel.pinyin.api.PinYinApi;
import cn.stylefeng.roses.kernel.rule.constants.SymbolConstant;
import cn.stylefeng.roses.kernel.rule.constants.TreeConstants;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.pojo.dict.SimpleDict;
import cn.stylefeng.roses.kernel.rule.tree.buildpids.PidStructureBuildUtil;
import cn.stylefeng.roses.kernel.rule.tree.factory.DefaultTreeBuildFactory;
@ -275,6 +277,20 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, SysDict> implements
}
}
@Override
public void simpleAddDict(SimpleDictAddParam simpleDictAddParam) {
// 组装添加字典的参数
DictRequest dictRequest = new DictRequest();
BeanUtil.copyProperties(simpleDictAddParam, dictRequest);
// 设置为启用
dictRequest.setStatusFlag(StatusEnum.ENABLE.getCode());
// 添加字典
this.add(dictRequest);
}
/**
*
*