From 79b4c68a73b5e3b51c6494a63e7b605d35bc7da6 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Wed, 28 Jun 2023 17:31:34 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=907.6.0=E3=80=91=E3=80=90config=E3=80=91?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE=E7=B1=BB=E5=9E=8B=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modular/service/SysConfigTypeService.java | 17 ++++ .../roses/kernel/dict/api/DictApi.java | 9 +++ .../roses/kernel/dict/api/DictTypeApi.java | 43 ++++++++++ .../dict/api/pojo/SimpleDictAddParam.java | 78 +++++++++++++++++++ .../dict/modular/service/DictTypeService.java | 11 +-- .../modular/service/impl/DictServiceImpl.java | 16 ++++ 6 files changed, 165 insertions(+), 9 deletions(-) create mode 100644 kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/DictTypeApi.java create mode 100644 kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/pojo/SimpleDictAddParam.java diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/SysConfigTypeService.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/SysConfigTypeService.java index 435206368..c02217051 100644 --- a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/SysConfigTypeService.java +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/SysConfigTypeService.java @@ -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; + /** * 查询系统配置类型列表 *

@@ -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); } } diff --git a/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/DictApi.java b/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/DictApi.java index f9c5fba89..f6ba612b5 100644 --- a/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/DictApi.java +++ b/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/DictApi.java @@ -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); + } diff --git a/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/DictTypeApi.java b/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/DictTypeApi.java new file mode 100644 index 000000000..1974b507e --- /dev/null +++ b/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/DictTypeApi.java @@ -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. + * + * Guns采用APACHE 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); + +} diff --git a/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/pojo/SimpleDictAddParam.java b/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/pojo/SimpleDictAddParam.java new file mode 100644 index 000000000..a732e8b7d --- /dev/null +++ b/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/pojo/SimpleDictAddParam.java @@ -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. + * + * Guns采用APACHE 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; + + +} diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/DictTypeService.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/DictTypeService.java index 12abc86ce..fa7aad4fa 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/DictTypeService.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/DictTypeService.java @@ -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 { +public interface DictTypeService extends IService, DictTypeApi { /** * 添加字典类型 @@ -85,12 +86,4 @@ public interface DictTypeService extends IService { */ List findList(DictTypeRequest dictTypeRequest); - /** - * 通过字典类型的编码,获取到字典类型的id - * - * @author fengshuonan - * @since 2023/6/27 17:39 - */ - Long getDictTypeIdByDictTypeCode(String dictTypeCode); - } diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/DictServiceImpl.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/DictServiceImpl.java index 30322cc3f..a80f82fd8 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/DictServiceImpl.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/DictServiceImpl.java @@ -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 implements } } + @Override + public void simpleAddDict(SimpleDictAddParam simpleDictAddParam) { + + // 组装添加字典的参数 + DictRequest dictRequest = new DictRequest(); + BeanUtil.copyProperties(simpleDictAddParam, dictRequest); + + // 设置为启用 + dictRequest.setStatusFlag(StatusEnum.ENABLE.getCode()); + + // 添加字典 + this.add(dictRequest); + } + /** * 获取详细信息 *