From afa215faa40a6315b3473bfbc83b22da25db47a4 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Mon, 8 Feb 2021 16:38:43 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90dict=E3=80=91=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roses/kernel/dict/api/DictApi.java | 8 - .../dict/api/constants/DictConstants.java | 3 +- .../modular/controller/DictController.java | 128 ++++------- .../controller/DictTypeController.java | 23 +- .../kernel/dict/modular/entity/SysDict.java | 2 +- .../dict/modular/mapper/DictMapper.java | 4 +- .../modular/mapper/mapping/DictMapper.xml | 41 ++-- .../dict/modular/service/DictService.java | 75 +++---- .../dict/modular/service/DictTypeService.java | 12 +- .../modular/service/impl/DictServiceImpl.java | 202 +++++------------- .../service/impl/DictTypeServiceImpl.java | 12 +- 11 files changed, 175 insertions(+), 335 deletions(-) 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 2882fce9a..29afce512 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 @@ -12,14 +12,6 @@ import java.util.List; */ public interface DictApi { - /** - * 获取字典名称通过code - * - * @author fengshuonan - * @date 2020/12/25 14:14 - */ - String getDictNameByDictCode(String dictCode); - /** * 通过字典类型编码和字典编码获取名称 * diff --git a/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/constants/DictConstants.java b/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/constants/DictConstants.java index 9fab833b8..b28671ad2 100644 --- a/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/constants/DictConstants.java +++ b/kernel-s-dict/dict-api/src/main/java/cn/stylefeng/roses/kernel/dict/api/constants/DictConstants.java @@ -23,7 +23,6 @@ public interface DictConstants { */ Long DEFAULT_DICT_PARENT_ID = -1L; - /** * 系统配置分组code */ @@ -34,4 +33,4 @@ public interface DictConstants { */ String LANGUAGES_DICT_TYPE_CODE = "languages"; -} \ No newline at end of file +} diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictController.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictController.java index d1c4ed9b4..5e9b912b2 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictController.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictController.java @@ -1,6 +1,7 @@ package cn.stylefeng.roses.kernel.dict.modular.controller; import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; +import cn.stylefeng.roses.kernel.dict.api.constants.DictConstants; import cn.stylefeng.roses.kernel.dict.modular.entity.SysDict; import cn.stylefeng.roses.kernel.dict.modular.pojo.TreeDictInfo; import cn.stylefeng.roses.kernel.dict.modular.pojo.request.DictRequest; @@ -8,10 +9,8 @@ import cn.stylefeng.roses.kernel.dict.modular.service.DictService; import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource; import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource; import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource; -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.SuccessResponseData; -import cn.stylefeng.roses.kernel.rule.tree.ztree.ZTreeNode; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; @@ -20,9 +19,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; -import static cn.stylefeng.roses.kernel.dict.api.constants.DictConstants.CONFIG_GROUP_DICT_TYPE_CODE; -import static cn.stylefeng.roses.kernel.dict.api.constants.DictConstants.LANGUAGES_DICT_TYPE_CODE; - /** * 字典详情管理,具体管理某个字典类型下的条目 * @@ -44,31 +40,7 @@ public class DictController { */ @PostResource(name = "添加字典", path = "/dict/addDict", requiredPermission = false) public ResponseData addDict(@RequestBody @Validated(DictRequest.add.class) DictRequest dictRequest) { - this.dictService.addDict(dictRequest); - return new SuccessResponseData(); - } - - /** - * 修改字典条目 - * - * @author fengshuonan - * @date 2020/10/29 16:35 - */ - @PostResource(name = "修改字典", path = "/dict/updateDict", requiredPermission = false) - public ResponseData updateDict(@RequestBody @Validated(DictRequest.edit.class) DictRequest dictRequest) { - this.dictService.updateDict(dictRequest); - return new SuccessResponseData(); - } - - /** - * 更新字典状态 - * - * @author fengshuonan - * @date 2020/10/29 16:35 - */ - @PostResource(name = "更新字典状态", path = "/dict/updateDictStatus", requiredPermission = false) - public ResponseData updateDictStatus(@RequestBody @Validated(BaseRequest.updateStatus.class) DictRequest dictRequest) { - this.dictService.updateDictStatus(dictRequest); + this.dictService.add(dictRequest); return new SuccessResponseData(); } @@ -80,7 +52,19 @@ public class DictController { */ @PostResource(name = "删除字典", path = "/dict/deleteDict", requiredPermission = false) public ResponseData deleteDict(@RequestBody @Validated(DictRequest.delete.class) DictRequest dictRequest) { - this.dictService.deleteDict(dictRequest); + this.dictService.del(dictRequest); + return new SuccessResponseData(); + } + + /** + * 修改字典条目 + * + * @author fengshuonan + * @date 2020/10/29 16:35 + */ + @PostResource(name = "修改字典", path = "/dict/updateDict", requiredPermission = false) + public ResponseData updateDict(@RequestBody @Validated(DictRequest.edit.class) DictRequest dictRequest) { + this.dictService.edit(dictRequest); return new SuccessResponseData(); } @@ -92,7 +76,7 @@ public class DictController { */ @GetResource(name = "获取字典详情", path = "/dict/getDictDetail", requiredPermission = false) public ResponseData getDictDetail(@RequestParam("dictId") Long dictId) { - SysDict detail = this.dictService.findDetail(dictId); + SysDict detail = this.dictService.detail(dictId); return new SuccessResponseData(detail); } @@ -108,6 +92,18 @@ public class DictController { return new SuccessResponseData(sysDictList); } + /** + * 获取字典列表(分页) + * + * @author fengshuonan + * @date 2020/10/29 16:35 + */ + @GetResource(name = "获取字典列表", path = "/dict/getDictListPage", requiredPermission = false) + public ResponseData getDictListPage(DictRequest dictRequest) { + PageResult page = this.dictService.findPage(dictRequest); + return new SuccessResponseData(page); + } + /** * 获取字典下拉列表,用在新增和修改字典,选择字典的父级 *

@@ -123,45 +119,7 @@ public class DictController { } /** - * 获取字典列表(分页) - * - * @author fengshuonan - * @date 2020/10/29 16:35 - */ - @GetResource(name = "获取字典列表", path = "/dict/getDictListPage", requiredPermission = false) - public ResponseData getDictListPage(DictRequest dictRequest) { - PageResult page = this.dictService.findPageList(dictRequest); - return new SuccessResponseData(page); - } - - /** - * 获取系统配置分组字典列表(分页) - * - * @author chenjinlong - * @date 2021/1/25 11:47 - */ - @GetResource(name = "获取系统配置分组字典列表", path = "/dict/getConfigGroupPage", requiredPermission = false) - public ResponseData getConfigGroupPage(DictRequest dictRequest) { - dictRequest.setDictTypeCode(CONFIG_GROUP_DICT_TYPE_CODE); - PageResult page = this.dictService.findPageList(dictRequest); - return new SuccessResponseData(page); - } - - /** - * 获取多语言字典列表(分页) - * - * @author chenjinlong - * @date 2021/1/25 11:47 - */ - @GetResource(name = "获取多语言字典列表", path = "/dict/getLanguagesPage", requiredPermission = false) - public ResponseData getLanguagesPage(DictRequest dictRequest) { - dictRequest.setDictTypeCode(LANGUAGES_DICT_TYPE_CODE); - PageResult page = this.dictService.findPageList(dictRequest); - return new SuccessResponseData(page); - } - - /** - * 获取树形字典列表 + * 获取树形字典列表(antdv在用) * * @author fengshuonan * @date 2020/10/29 16:36 @@ -173,7 +131,7 @@ public class DictController { } /** - * code校验 + * code校验,校验code是否重复 * * @author fengshuonan * @date 2020/10/29 16:36 @@ -185,25 +143,29 @@ public class DictController { } /** - * 字典树列表 + * 获取系统配置分组字典列表(分页)(给系统配置界面,左侧获取配置的分类用) * - * @author huangyao - * @date 2021/1/10 17:31 + * @author chenjinlong + * @date 2021/1/25 11:47 */ - @GetResource(name = "获取zTree形式的字典树(layui版本)", path = "/dict/zTree") - public List layuiSelectParentMenuTreeList(@Validated(DictRequest.dictZTree.class) DictRequest dictRequest) { - return this.dictService.dictZTree(dictRequest); + @GetResource(name = "获取系统配置分组字典列表", path = "/dict/getConfigGroupPage", requiredPermission = false) + public ResponseData getConfigGroupPage(DictRequest dictRequest) { + dictRequest.setDictTypeCode(DictConstants.CONFIG_GROUP_DICT_TYPE_CODE); + PageResult page = this.dictService.findPage(dictRequest); + return new SuccessResponseData(page); } /** - * 分页查询字典 + * 获取多语言字典列表(分页)(给多语言界面,左侧获取多语言的分类用) * * @author chenjinlong - * @date 2021/1/13 17:51 + * @date 2021/1/25 11:47 */ - @GetResource(name = "分页查询字典", path = "/dict/page") - public ResponseData page(DictRequest dictRequest) { - return new SuccessResponseData(this.dictService.page(dictRequest)); + @GetResource(name = "获取多语言字典列表", path = "/dict/getLanguagesPage", requiredPermission = false) + public ResponseData getLanguagesPage(DictRequest dictRequest) { + dictRequest.setDictTypeCode(DictConstants.LANGUAGES_DICT_TYPE_CODE); + PageResult page = this.dictService.findPage(dictRequest); + return new SuccessResponseData(page); } } diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictTypeController.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictTypeController.java index 8e474574c..6a3108286 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictTypeController.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictTypeController.java @@ -1,6 +1,7 @@ package cn.stylefeng.roses.kernel.dict.modular.controller; import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult; +import cn.stylefeng.roses.kernel.dict.api.constants.DictConstants; import cn.stylefeng.roses.kernel.dict.modular.entity.SysDictType; import cn.stylefeng.roses.kernel.dict.modular.pojo.request.DictTypeRequest; import cn.stylefeng.roses.kernel.dict.modular.service.DictTypeService; @@ -18,10 +19,6 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.List; -import static cn.stylefeng.roses.kernel.dict.api.constants.DictConstants.CONFIG_GROUP_DICT_TYPE_CODE; -import static cn.stylefeng.roses.kernel.dict.api.constants.DictConstants.LANGUAGES_DICT_TYPE_CODE; - - /** * 字典类型管理 * @@ -43,7 +40,7 @@ public class DictTypeController { */ @PostResource(name = "添加字典类型", path = "/dictType/addDictType", requiredPermission = false) public ResponseData addDictType(@RequestBody @Validated(DictTypeRequest.add.class) DictTypeRequest dictTypeRequest) { - this.dictTypeService.addDictType(dictTypeRequest); + this.dictTypeService.add(dictTypeRequest); return new SuccessResponseData(); } @@ -55,7 +52,7 @@ public class DictTypeController { */ @PostResource(name = "修改字典类型", path = "/dictType/updateDictType", requiredPermission = false) public ResponseData updateDictType(@RequestBody @Validated(DictTypeRequest.edit.class) DictTypeRequest dictTypeRequest) { - this.dictTypeService.updateDictType(dictTypeRequest); + this.dictTypeService.edit(dictTypeRequest); return new SuccessResponseData(); } @@ -67,7 +64,7 @@ public class DictTypeController { */ @PostResource(name = "修改字典类型状态", path = "/dictType/updateStatus", requiredPermission = false) public ResponseData updateStatus(@RequestBody @Validated(BaseRequest.updateStatus.class) DictTypeRequest dictTypeRequest) { - this.dictTypeService.updateDictTypeStatus(dictTypeRequest); + this.dictTypeService.editStatus(dictTypeRequest); return new SuccessResponseData(); } @@ -79,7 +76,7 @@ public class DictTypeController { */ @PostResource(name = "删除字典类型", path = "/dictType/deleteDictType", requiredPermission = false) public ResponseData deleteDictType(@RequestBody @Validated(DictTypeRequest.delete.class) DictTypeRequest dictTypeRequest) { - this.dictTypeService.deleteDictType(dictTypeRequest); + this.dictTypeService.del(dictTypeRequest); return new SuccessResponseData(); } @@ -95,7 +92,6 @@ public class DictTypeController { return new SuccessResponseData(detail); } - /** * 获取字典类型详情 * @@ -104,7 +100,7 @@ public class DictTypeController { */ @GetResource(name = "获取系统配置字典类型详情", path = "/dictType/getConfigDictTypeDetail", requiredPermission = false) public ResponseData getConfigDictTypeDetail(DictTypeRequest dictTypeRequest) { - dictTypeRequest.setDictTypeCode(CONFIG_GROUP_DICT_TYPE_CODE); + dictTypeRequest.setDictTypeCode(DictConstants.CONFIG_GROUP_DICT_TYPE_CODE); SysDictType detail = this.dictTypeService.detailBy(dictTypeRequest); return new SuccessResponseData(detail); } @@ -117,12 +113,11 @@ public class DictTypeController { */ @GetResource(name = "获取语种字典类型型详情", path = "/dictType/getTranslationDetail", requiredPermission = false) public ResponseData getTranslationDetail(DictTypeRequest dictTypeRequest) { - dictTypeRequest.setDictTypeCode(LANGUAGES_DICT_TYPE_CODE); + dictTypeRequest.setDictTypeCode(DictConstants.LANGUAGES_DICT_TYPE_CODE); SysDictType detail = this.dictTypeService.detailBy(dictTypeRequest); return new SuccessResponseData(detail); } - /** * 获取字典类型列表 * @@ -131,7 +126,7 @@ public class DictTypeController { */ @GetResource(name = "获取字典类型列表", path = "/dictType/getDictTypeList", requiredPermission = false) public ResponseData getDictTypeList(DictTypeRequest dictTypeRequest) { - List sysDictTypeList = dictTypeService.getDictTypeList(dictTypeRequest); + List sysDictTypeList = dictTypeService.findList(dictTypeRequest); return new SuccessResponseData(sysDictTypeList); } @@ -143,7 +138,7 @@ public class DictTypeController { */ @GetResource(name = "获取字典类型列表(分页)", path = "/dictType/getDictTypePageList", requiredPermission = false) public ResponseData getDictTypePageList(DictTypeRequest dictTypeRequest) { - PageResult dictTypePageList = dictTypeService.getDictTypePageList(dictTypeRequest); + PageResult dictTypePageList = dictTypeService.findPage(dictTypeRequest); return new SuccessResponseData(dictTypePageList); } diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/entity/SysDict.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/entity/SysDict.java index 21ea22d40..777ebd814 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/entity/SysDict.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/entity/SysDict.java @@ -104,7 +104,7 @@ public class SysDict extends BaseEntity { private transient String dictTypeName; /** - * 字典类型的名称 + * 字典上级的名称(字典有上下级,字典类型没有上下级) */ private transient String parentName; diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/DictMapper.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/DictMapper.java index db2c1cc78..219dfea57 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/DictMapper.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/DictMapper.java @@ -25,7 +25,7 @@ public interface DictMapper extends BaseMapper { * @author fengshuonan * @date 2020/10/29 17:21 */ - SysDict findDetail(@Param("dictId") Long dictId); + SysDict detail(@Param("dictId") Long dictId); /** * 获取分页字典列表 @@ -36,7 +36,7 @@ public interface DictMapper extends BaseMapper { * @author fengshuonan * @date 2020/10/29 17:21 */ - List findList(@Param("page") Page page, @Param("dictRequest") DictRequest dictRequest); + List findPage(@Param("page") Page page, @Param("dictRequest") DictRequest dictRequest); /** * 获取字典下拉列表,用在新增和修改字典,选择字典的父级 diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/mapping/DictMapper.xml b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/mapping/DictMapper.xml index 5ac0d1150..8a4b54cd5 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/mapping/DictMapper.xml +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/mapper/mapping/DictMapper.xml @@ -2,7 +2,7 @@ - SELECT dict.dict_id AS dictId, dict.dict_code AS dictCode, dict.dict_name as dictName, @@ -22,8 +22,8 @@ AND dict.dict_id = #{dictId} - + SELECT dictType.dict_type_name as dictTypeName, dict.dict_id AS dictId, dict.dict_code AS dictCode, dict.dict_encode as dictEncode, @@ -36,14 +36,11 @@ dict.dict_parent_id AS dictParentId, dict.status_flag AS statusFlag, dict.create_time AS createTime, - pDict.dict_name AS parentName + parentDict.dict_name AS parentName FROM sys_dict dict - INNER JOIN sys_dict_type type ON dict.dict_type_code = type.dict_type_code - LEFT JOIN sys_dict pDict ON pDict.dict_id = dict.dict_parent_id + INNER JOIN sys_dict_type dictType ON dict.dict_type_code = dictType.dict_type_code + LEFT JOIN sys_dict parentDict ON parentDict.dict_id = dict.dict_parent_id WHERE dict.del_flag = 'N' - - AND dict.status_flag = #{dictRequest.statusFlag} - AND dict.dict_type_code = #{dictRequest.dictTypeCode} @@ -51,11 +48,10 @@ AND dict.dict_code LIKE CONCAT('%',#{dictRequest.dictCode},'%') - AND - ( - dict.dict_name LIKE CONCAT('%',#{dictRequest.dictName},'%') - OR - dict.dict_name_pinyin LIKE CONCAT('%',#{dictRequest.dictName},'%') + AND ( + dict.dict_name LIKE CONCAT('%',#{dictRequest.dictName},'%') + OR + dict.dict_name_pinyin LIKE CONCAT('%',#{dictRequest.dictName},'%') ) @@ -65,7 +61,18 @@