diff --git a/snowy-admin-web/src/api/biz/bizDictApi.js b/snowy-admin-web/src/api/biz/bizDictApi.js
new file mode 100644
index 00000000..3967672c
--- /dev/null
+++ b/snowy-admin-web/src/api/biz/bizDictApi.js
@@ -0,0 +1,37 @@
+/**
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+import { baseRequest } from '@/utils/request'
+
+const request = (url, ...arg) => baseRequest(`/biz/dict/${url}`, ...arg)
+/**
+ * 字典
+ *
+ * @author yubaoshan
+ * @date 2022-09-22 22:33:20
+ */
+export default {
+ // 获取业务字典分页
+ dictPage(data) {
+ return request('page', data, 'get')
+ },
+ // 获取业务字典树
+ dictTree(data) {
+ return request('tree', data, 'get')
+ },
+ // 获取所有字典树
+ dictTreeAll(data) {
+ return request('treeAll', data, 'get')
+ },
+ // 编辑业务字典
+ submitForm(data) {
+ return request('edit', data)
+ }
+}
diff --git a/snowy-admin-web/src/views/biz/dict/form.vue b/snowy-admin-web/src/views/biz/dict/form.vue
new file mode 100644
index 00000000..ef284820
--- /dev/null
+++ b/snowy-admin-web/src/views/biz/dict/form.vue
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 关闭
+ 保存
+
+
+
+
+
diff --git a/snowy-admin-web/src/views/biz/dict/index.vue b/snowy-admin-web/src/views/biz/dict/index.vue
new file mode 100644
index 00000000..a550fb49
--- /dev/null
+++ b/snowy-admin-web/src/views/biz/dict/index.vue
@@ -0,0 +1,196 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 查询
+
+
+
+ 重置
+
+
+
+
+
+
+
+
+
+ {{ record.level }}
+ 子级
+
+
+ 编辑
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/snowy-admin-web/src/views/biz/user/index.vue b/snowy-admin-web/src/views/biz/user/index.vue
index cb912742..9cc8564b 100644
--- a/snowy-admin-web/src/views/biz/user/index.vue
+++ b/snowy-admin-web/src/views/biz/user/index.vue
@@ -146,7 +146,7 @@
:org-tree-api="selectorApiFunction.orgTreeApi"
:role-page-api="selectorApiFunction.rolePageApi"
:checked-role-list-api="selectorApiFunction.checkedRoleListApi"
- :role-global="false"
+ :role-global="true"
@onBack="roleBack"
/>
diff --git a/snowy-admin-web/src/views/sys/role/index.vue b/snowy-admin-web/src/views/sys/role/index.vue
index b2952a84..cda1e569 100644
--- a/snowy-admin-web/src/views/sys/role/index.vue
+++ b/snowy-admin-web/src/views/sys/role/index.vue
@@ -78,10 +78,10 @@
授权资源
- 授权移动端资源
+ 授权移动端资源
- 授权权限
+ 授权权限
授权用户
@@ -96,8 +96,8 @@
-
-
+
+
> page(BizDictPageParam bizDictPageParam) {
+ return CommonResult.data(bizDictService.page(bizDictPageParam));
+ }
+
+ /**
+ * 获取业务字典树
+ *
+ * @author xuyuxiang
+ * @date 2022/4/24 20:00
+ */
+ @ApiOperationSupport(order = 2)
+ @ApiOperation("获取业务字典树")
+ @SaCheckPermission("/biz/dict/tree")
+ @GetMapping("/biz/dict/tree")
+ public CommonResult>> tree() {
+ return CommonResult.data(bizDictService.tree());
+ }
+
+ /**
+ * 获取所有字典树
+ *
+ * @author xuyuxiang
+ * @date 2022/4/24 20:00
+ */
+ @ApiOperationSupport(order = 3)
+ @ApiOperation("获取所有字典树")
+ @GetMapping("/biz/dict/treeAll")
+ public CommonResult>> treeAll() {
+ return CommonResult.data(bizDictService.treeAll());
+ }
+
+ /**
+ * 编辑业务字典
+ *
+ * @author xuyuxiang
+ * @date 2022/4/24 20:47
+ */
+ @ApiOperationSupport(order = 4)
+ @ApiOperation("编辑业务字典")
+ @CommonLog("编辑业务字典")
+ @SaCheckPermission("/biz/dict/edit")
+ @PostMapping("/biz/dict/edit")
+ public CommonResult edit(@RequestBody @Valid BizDictEditParam bizDictEditParam) {
+ bizDictService.edit(bizDictEditParam);
+ return CommonResult.ok();
+ }
+}
diff --git a/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/entity/BizDict.java b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/entity/BizDict.java
new file mode 100644
index 00000000..de690a74
--- /dev/null
+++ b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/entity/BizDict.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.biz.modular.dict.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import vip.xiaonuo.common.pojo.CommonEntity;
+
+/**
+ * 业务字典实体
+ *
+ * @author xuyuxiang
+ * @date 2022/2/23 18:27
+ **/
+@Getter
+@Setter
+@TableName("DEV_DICT")
+public class BizDict extends CommonEntity {
+
+ /** id */
+ @ApiModelProperty(value = "id", position = 1)
+ private String id;
+
+ /** 租户id */
+ @ApiModelProperty(value = "租户id", position = 2)
+ private String tenantId;
+
+ /** 父id */
+ @ApiModelProperty(value = "父id", position = 3)
+ private String parentId;
+
+ /** 字典文字 */
+ @ApiModelProperty(value = "字典文字", position = 4)
+ private String dictLabel;
+
+ /** 字典值 */
+ @ApiModelProperty(value = "字典值", position = 5)
+ private String dictValue;
+
+ /** 分类 */
+ @ApiModelProperty(value = "分类", position = 6)
+ private String category;
+
+ /** 排序码 */
+ @ApiModelProperty(value = "排序码", position = 7)
+ private Integer sortCode;
+
+ /** 扩展信息 */
+ @ApiModelProperty(value = "扩展信息", position = 8)
+ @TableField(insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
+ private String extJson;
+}
diff --git a/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/enums/BizDictCategoryEnum.java b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/enums/BizDictCategoryEnum.java
new file mode 100644
index 00000000..b3ddae74
--- /dev/null
+++ b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/enums/BizDictCategoryEnum.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.biz.modular.dict.enums;
+
+import lombok.Getter;
+import vip.xiaonuo.common.exception.CommonException;
+
+/**
+ * 业务字典分类枚举
+ *
+ * @author xuyuxiang
+ * @date 2022/7/6 22:21
+ */
+@Getter
+public enum BizDictCategoryEnum {
+
+ /**
+ * 业务
+ */
+ BIZ("BIZ");
+
+ private final String value;
+
+ BizDictCategoryEnum(String value) {
+ this.value = value;
+ }
+
+ public static void validate(String value) {
+ boolean flag = BIZ.getValue().equals(value);
+ if(!flag) {
+ throw new CommonException("不支持的字典分类:{}", value);
+ }
+ }
+}
diff --git a/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/mapper/BizDictMapper.java b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/mapper/BizDictMapper.java
new file mode 100644
index 00000000..c28689c2
--- /dev/null
+++ b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/mapper/BizDictMapper.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.biz.modular.dict.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import vip.xiaonuo.biz.modular.dict.entity.BizDict;
+
+/**
+ * 业务字典Mapper接口
+ *
+ * @author xuyuxiang
+ * @date 2022/4/22 10:40
+ **/
+public interface BizDictMapper extends BaseMapper {
+}
diff --git a/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/mapper/mapping/BizDictMapper.xml b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/mapper/mapping/BizDictMapper.xml
new file mode 100644
index 00000000..d9e3e967
--- /dev/null
+++ b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/mapper/mapping/BizDictMapper.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/param/BizDictEditParam.java b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/param/BizDictEditParam.java
new file mode 100644
index 00000000..11fc0c57
--- /dev/null
+++ b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/param/BizDictEditParam.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.biz.modular.dict.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * 业务字典编辑参数
+ *
+ * @author xuyuxiang
+ * @date 2022/7/30 21:48
+ */
+@Getter
+@Setter
+public class BizDictEditParam {
+
+ /** id */
+ @ApiModelProperty(value = "id", position = 1)
+ @NotBlank(message = "id不能为空")
+ private String id;
+
+ /** 字典文字 */
+ @ApiModelProperty(value = "字典文字", position = 2)
+ @NotBlank(message = "dictLabel不能为空")
+ private String dictLabel;
+
+ /** 排序码 */
+ @ApiModelProperty(value = "排序码", position = 3)
+ @NotNull(message = "sortCode不能为空")
+ private Integer sortCode;
+
+ /** 扩展信息 */
+ @ApiModelProperty(value = "扩展信息", position = 4)
+ private String extJson;
+}
diff --git a/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/param/BizDictPageParam.java b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/param/BizDictPageParam.java
new file mode 100644
index 00000000..5211bc7f
--- /dev/null
+++ b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/param/BizDictPageParam.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.biz.modular.dict.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 业务字典查询参数
+ *
+ * @author xuyuxiang
+ * @date 2022/7/30 21:49
+ */
+@Getter
+@Setter
+public class BizDictPageParam {
+
+ /** 当前页 */
+ @ApiModelProperty(value = "当前页码")
+ private Integer current;
+
+ /** 每页条数 */
+ @ApiModelProperty(value = "每页条数")
+ private Integer size;
+
+ /** 排序字段 */
+ @ApiModelProperty(value = "排序字段,字段驼峰名称,如:userName")
+ private String sortField;
+
+ /** 排序方式 */
+ @ApiModelProperty(value = "排序方式,升序:ASCEND;降序:DESCEND")
+ private String sortOrder;
+
+ /** 父id */
+ @ApiModelProperty(value = "父id")
+ private String parentId;
+
+ /** 字典文字关键词 */
+ @ApiModelProperty(value = "字典文字关键词")
+ private String searchKey;
+}
diff --git a/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/service/BizDictService.java b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/service/BizDictService.java
new file mode 100644
index 00000000..d367b063
--- /dev/null
+++ b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/service/BizDictService.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.biz.modular.dict.service;
+
+import cn.hutool.core.lang.tree.Tree;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import vip.xiaonuo.biz.modular.dict.entity.BizDict;
+import vip.xiaonuo.biz.modular.dict.param.BizDictEditParam;
+import vip.xiaonuo.biz.modular.dict.param.BizDictPageParam;
+
+import java.util.List;
+
+/**
+ * 业务字典Service接口
+ *
+ * @author xuyuxiang
+ * @date 2022/4/22 10:41
+ **/
+public interface BizDictService extends IService {
+
+ /**
+ * 获取业务字典分页
+ *
+ * @author xuyuxiang
+ * @date 2022/4/24 20:08
+ */
+ Page page(BizDictPageParam bizDictPageParam);
+
+ /**
+ * 获取业务字典树
+ *
+ * @author xuyuxiang
+ * @date 2022/4/24 20:08
+ */
+ List> tree();
+
+ /**
+ * 获取所有字典树
+ *
+ * @author xuyuxiang
+ * @date 2022/4/24 20:08
+ */
+ List> treeAll();
+
+ /**
+ * 编辑业务字典
+ *
+ * @author xuyuxiang
+ * @date 2022/4/24 21:13
+ */
+ void edit(BizDictEditParam bizDictEditParam);
+
+ /**
+ * 获取业务字典详情
+ *
+ * @author xuyuxiang
+ * @date 2022/4/24 21:18
+ */
+ BizDict queryEntity(String id);
+}
diff --git a/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/service/impl/BizDictServiceImpl.java b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/service/impl/BizDictServiceImpl.java
new file mode 100644
index 00000000..329492db
--- /dev/null
+++ b/snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/dict/service/impl/BizDictServiceImpl.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright [2022] [https://www.xiaonuo.vip]
+ *
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
+ *
+ * 1.请不要删除和修改根目录下的LICENSE文件。
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
+ */
+package vip.xiaonuo.biz.modular.dict.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.tree.Tree;
+import cn.hutool.core.lang.tree.TreeNode;
+import cn.hutool.core.lang.tree.TreeUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fhs.trans.service.impl.DictionaryTransService;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.stereotype.Service;
+import vip.xiaonuo.biz.modular.dict.entity.BizDict;
+import vip.xiaonuo.biz.modular.dict.enums.BizDictCategoryEnum;
+import vip.xiaonuo.biz.modular.dict.mapper.BizDictMapper;
+import vip.xiaonuo.biz.modular.dict.param.BizDictEditParam;
+import vip.xiaonuo.biz.modular.dict.param.BizDictPageParam;
+import vip.xiaonuo.biz.modular.dict.service.BizDictService;
+import vip.xiaonuo.common.enums.CommonSortOrderEnum;
+import vip.xiaonuo.common.exception.CommonException;
+import vip.xiaonuo.common.page.CommonPageRequest;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
+/**
+ * 字典Service接口实现类
+ *
+ * @author xuyuxiang
+ * @date 2022/4/22 10:41
+ **/
+@Service
+public class BizDictServiceImpl extends ServiceImpl implements BizDictService, InitializingBean {
+
+ private static final String ROOT_PARENT_ID = "0";
+
+ @Resource
+ private DictionaryTransService dictionaryTransService;
+
+ @Override
+ public Page page(BizDictPageParam bizDictPageParam) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ // 查询部分字段
+ queryWrapper.lambda().select(BizDict::getId, BizDict::getParentId, BizDict::getCategory, BizDict::getDictLabel,
+ BizDict::getDictValue, BizDict::getSortCode).eq(BizDict::getCategory, BizDictCategoryEnum.BIZ.getValue());
+ if (ObjectUtil.isNotEmpty(bizDictPageParam.getParentId())) {
+ queryWrapper.lambda().eq(BizDict::getParentId, bizDictPageParam.getParentId())
+ .or().eq(BizDict::getId, bizDictPageParam.getParentId());
+ }
+ if (ObjectUtil.isNotEmpty(bizDictPageParam.getSearchKey())) {
+ queryWrapper.lambda().like(BizDict::getDictLabel, bizDictPageParam.getSearchKey());
+ }
+ if (ObjectUtil.isAllNotEmpty(bizDictPageParam.getSortField(), bizDictPageParam.getSortOrder())) {
+ CommonSortOrderEnum.validate(bizDictPageParam.getSortOrder());
+ queryWrapper.orderBy(true, bizDictPageParam.getSortOrder().equals(CommonSortOrderEnum.ASC.getValue()),
+ StrUtil.toUnderlineCase(bizDictPageParam.getSortField()));
+ } else {
+ queryWrapper.lambda().orderByAsc(BizDict::getSortCode);
+ }
+ return this.page(CommonPageRequest.defaultPage(), queryWrapper);
+ }
+
+ @Override
+ public List> tree() {
+ LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ lambdaQueryWrapper.eq(BizDict::getCategory, BizDictCategoryEnum.BIZ.getValue()).orderByAsc(BizDict::getSortCode);
+ List bizDictList = this.list(lambdaQueryWrapper);
+ List> treeNodeList = bizDictList.stream().map(bizDict ->
+ new TreeNode<>(bizDict.getId(), bizDict.getParentId(),
+ bizDict.getDictLabel(), bizDict.getSortCode()).setExtra(JSONUtil.parseObj(bizDict)))
+ .collect(Collectors.toList());
+ return TreeUtil.build(treeNodeList, "0");
+ }
+
+ @Override
+ public List> treeAll() {
+ List bizDictList = this.list();
+ List> treeNodeList = bizDictList.stream().map(bizDict ->
+ new TreeNode<>(bizDict.getId(), bizDict.getParentId(),
+ bizDict.getDictLabel(), bizDict.getSortCode()).setExtra(JSONUtil.parseObj(bizDict)))
+ .collect(Collectors.toList());
+ return TreeUtil.build(treeNodeList, "0");
+ }
+
+ @Override
+ public void edit(BizDictEditParam bizDictEditParam) {
+ BizDict bizDict = this.queryEntity(bizDictEditParam.getId());
+ checkParam(bizDictEditParam);
+ BeanUtil.copyProperties(bizDictEditParam, bizDict);
+ this.updateById(bizDict);
+ refreshTransCache();
+ }
+
+ private void checkParam(BizDictEditParam bizDictEditParam) {
+ boolean hasSameDictLabel = this.count(new LambdaQueryWrapper()
+ .eq(BizDict::getCategory, BizDictCategoryEnum.BIZ.getValue())
+ .eq(BizDict::getDictLabel, bizDictEditParam.getDictLabel())
+ .ne(BizDict::getId, bizDictEditParam.getId())) > 0;
+ if (hasSameDictLabel) {
+ throw new CommonException("存在重复的字典文字,名称为:{}", bizDictEditParam.getDictLabel());
+ }
+ }
+
+ @Override
+ public BizDict queryEntity(String id) {
+ BizDict bizDict = this.getById(id);
+ if (ObjectUtil.isEmpty(bizDict)) {
+ throw new CommonException("字典不存在,id值为:{}", id);
+ }
+ return bizDict;
+ }
+
+ @Override
+ public void afterPropertiesSet() {
+ refreshTransCache();
+ }
+
+ private void refreshTransCache() {
+ // 异步不阻塞主线程,不会 增加启动用时
+ CompletableFuture.supplyAsync(() -> {
+ // 使用redis能解决共享问题,但是性能没有直接取缓存的好。
+ dictionaryTransService.makeUseRedis();
+ List bizDictList = super.list(new LambdaQueryWrapper<>());
+ // 非root级别的字典根据ParentId分组
+ Map> bizDictGroupByPIDMap = bizDictList.stream().filter(dict -> !ROOT_PARENT_ID
+ .equals(dict.getParentId())).collect(Collectors.groupingBy(BizDict::getParentId));
+ Map parentDictIdValMap = bizDictList.stream().filter(dict -> ROOT_PARENT_ID
+ .equals(dict.getParentId())).collect(Collectors.toMap(BizDict::getId, BizDict::getDictValue));
+ for (String parentId : parentDictIdValMap.keySet()) {
+ if(bizDictGroupByPIDMap.containsKey(parentId)){
+ dictionaryTransService.refreshCache(parentDictIdValMap.get(parentId), bizDictGroupByPIDMap.get(parentId).stream()
+ .collect(Collectors.toMap(BizDict::getDictValue, BizDict::getDictLabel)));
+ }
+ }
+ return null;
+ });
+ }
+}