init
This commit is contained in:
23
blade-service-api/blade-dict-api/pom.xml
Normal file
23
blade-service-api/blade-dict-api/pom.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>blade-service-api</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>blade-dict-api</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-cache</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
142
blade-service-api/blade-dict-api/src/main/java/org/springblade/system/cache/DictBizCache.java
vendored
Normal file
142
blade-service-api/blade-dict-api/src/main/java/org/springblade/system/cache/DictBizCache.java
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.cache;
|
||||
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
import org.springblade.system.pojo.enums.DictBizEnum;
|
||||
import org.springblade.system.feign.IDictBizClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
|
||||
|
||||
/**
|
||||
* 业务字典缓存工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class DictBizCache {
|
||||
|
||||
private static final String DICT_ID = "dictBiz:id";
|
||||
private static final String DICT_VALUE = "dictBiz:value";
|
||||
private static final String DICT_LIST = "dictBiz:list";
|
||||
|
||||
private static IDictBizClient dictClient;
|
||||
|
||||
private static IDictBizClient getDictClient() {
|
||||
if (dictClient == null) {
|
||||
dictClient = SpringUtil.getBean(IDictBizClient.class);
|
||||
}
|
||||
return dictClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典实体
|
||||
*
|
||||
* @param id 主键
|
||||
* @return DictBiz
|
||||
*/
|
||||
public static DictBiz getById(Long id) {
|
||||
String keyPrefix = DICT_ID.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
|
||||
return CacheUtil.get(DICT_CACHE, keyPrefix, id, () -> {
|
||||
R<DictBiz> result = getDictClient().getById(id);
|
||||
return result.getData();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictKey Integer型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(DictBizEnum code, Integer dictKey) {
|
||||
return getValue(code.getName(), dictKey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey Integer型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String code, Integer dictKey) {
|
||||
String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
|
||||
return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, String.valueOf(dictKey), () -> {
|
||||
R<String> result = getDictClient().getValue(code, String.valueOf(dictKey));
|
||||
return result.getData();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictKey String型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(DictBizEnum code, String dictKey) {
|
||||
return getValue(code.getName(), dictKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey String型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String code, String dictKey) {
|
||||
String keyPrefix = DICT_VALUE.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
|
||||
return CacheUtil.get(DICT_CACHE, keyPrefix + code + StringPool.COLON, dictKey, () -> {
|
||||
R<String> result = getDictClient().getValue(code, dictKey);
|
||||
return result.getData();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典集合
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @return List<DictBiz>
|
||||
*/
|
||||
public static List<DictBiz> getList(String code) {
|
||||
String keyPrefix = DICT_LIST.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON);
|
||||
return CacheUtil.get(DICT_CACHE, keyPrefix, code, () -> {
|
||||
R<List<DictBiz>> result = getDictClient().getList(code);
|
||||
return result.getData();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
173
blade-service-api/blade-dict-api/src/main/java/org/springblade/system/cache/DictCache.java
vendored
Normal file
173
blade-service-api/blade-dict-api/src/main/java/org/springblade/system/cache/DictCache.java
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.cache;
|
||||
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.system.pojo.entity.Dict;
|
||||
import org.springblade.system.pojo.enums.DictEnum;
|
||||
import org.springblade.system.feign.IDictClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE;
|
||||
|
||||
/**
|
||||
* 字典缓存工具类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public class DictCache {
|
||||
|
||||
private static final String DICT_ID = "dict:id:";
|
||||
private static final String DICT_KEY = "dict:key:";
|
||||
private static final String DICT_VALUE = "dict:value:";
|
||||
private static final String DICT_LIST = "dict:list:";
|
||||
|
||||
private static final Boolean TENANT_MODE = Boolean.FALSE;
|
||||
|
||||
private static IDictClient dictClient;
|
||||
|
||||
private static IDictClient getDictClient() {
|
||||
if (dictClient == null) {
|
||||
dictClient = SpringUtil.getBean(IDictClient.class);
|
||||
}
|
||||
return dictClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典实体
|
||||
*
|
||||
* @param id 主键
|
||||
* @return Dict
|
||||
*/
|
||||
public static Dict getById(Long id) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_ID, id, () -> {
|
||||
R<Dict> result = getDictClient().getById(id);
|
||||
return result.getData();
|
||||
}, TENANT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictValue 字典值
|
||||
* @return String
|
||||
*/
|
||||
public static String getKey(DictEnum code, String dictValue) {
|
||||
return getKey(code.getName(), dictValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典键
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictValue 字典值
|
||||
* @return String
|
||||
*/
|
||||
public static String getKey(String code, String dictValue) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_KEY + code + StringPool.COLON, dictValue, () -> {
|
||||
List<Dict> list = getList(code);
|
||||
if (Func.isEmpty(list)) {
|
||||
return StringPool.EMPTY;
|
||||
}
|
||||
return list.stream()
|
||||
.filter(dict -> dict.getDictValue().equalsIgnoreCase(dictValue))
|
||||
.map(Dict::getDictKey)
|
||||
.findFirst()
|
||||
.orElse(StringPool.EMPTY);
|
||||
}, TENANT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictKey Integer型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(DictEnum code, Integer dictKey) {
|
||||
return getValue(code.getName(), dictKey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey Integer型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String code, Integer dictKey) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, String.valueOf(dictKey), () -> {
|
||||
R<String> result = getDictClient().getValue(code, String.valueOf(dictKey));
|
||||
return result.getData();
|
||||
}, TENANT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号枚举
|
||||
* @param dictKey String型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(DictEnum code, String dictKey) {
|
||||
return getValue(code.getName(), dictKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey String型字典键
|
||||
* @return String
|
||||
*/
|
||||
public static String getValue(String code, String dictKey) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_VALUE + code + StringPool.COLON, dictKey, () -> {
|
||||
R<String> result = getDictClient().getValue(code, dictKey);
|
||||
return result.getData();
|
||||
}, TENANT_MODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典集合
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @return List<Dict>
|
||||
*/
|
||||
public static List<Dict> getList(String code) {
|
||||
return CacheUtil.get(DICT_CACHE, DICT_LIST, code, () -> {
|
||||
R<List<Dict>> result = getDictClient().getList(code);
|
||||
return result.getData();
|
||||
}, TENANT_MODE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.constant;
|
||||
|
||||
/**
|
||||
* 字典常量.
|
||||
*
|
||||
* @author zhuangqian
|
||||
*/
|
||||
public interface DictConstant {
|
||||
|
||||
String SEX_CODE = "sex";
|
||||
|
||||
String NOTICE_CODE = "notice";
|
||||
|
||||
String MENU_CATEGORY_CODE = "menu_category";
|
||||
|
||||
String BUTTON_FUNC_CODE = "button_func";
|
||||
|
||||
String YES_NO_CODE = "yes_no";
|
||||
|
||||
String FLOW_CATEGORY_CODE = "flow_category";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Feign接口类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@FeignClient(
|
||||
value = AppConstant.APPLICATION_SYSTEM_NAME,
|
||||
fallback = IDictBizClientFallback.class
|
||||
)
|
||||
public interface IDictBizClient {
|
||||
|
||||
String API_PREFIX = "/feign/client/dict-biz";
|
||||
String GET_BY_ID = API_PREFIX + "/get-by-id";
|
||||
String GET_VALUE = API_PREFIX + "/get-value";
|
||||
String GET_LIST = API_PREFIX + "/get-list";
|
||||
|
||||
/**
|
||||
* 获取字典实体
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(GET_BY_ID)
|
||||
R<DictBiz> getById(@RequestParam("id") Long id);
|
||||
|
||||
/**
|
||||
* 获取字典表对应值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey 字典序号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(GET_VALUE)
|
||||
R<String> getValue(@RequestParam("code") String code, @RequestParam("dictKey") String dictKey);
|
||||
|
||||
/**
|
||||
* 获取字典表
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(GET_LIST)
|
||||
R<List<DictBiz>> getList(@RequestParam("code") String code);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Feign失败配置
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Component
|
||||
public class IDictBizClientFallback implements IDictBizClient {
|
||||
@Override
|
||||
public R<DictBiz> getById(Long id) {
|
||||
return R.fail("获取数据失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> getValue(String code, String dictKey) {
|
||||
return R.fail("获取数据失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<DictBiz>> getList(String code) {
|
||||
return R.fail("获取数据失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.Dict;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Feign接口类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@FeignClient(
|
||||
value = AppConstant.APPLICATION_SYSTEM_NAME,
|
||||
fallback = IDictClientFallback.class
|
||||
)
|
||||
public interface IDictClient {
|
||||
|
||||
String API_PREFIX = "/feign/client/dict";
|
||||
String GET_BY_ID = API_PREFIX + "/get-by-id";
|
||||
String GET_VALUE = API_PREFIX + "/get-value";
|
||||
String GET_LIST = API_PREFIX + "/get-list";
|
||||
|
||||
/**
|
||||
* 获取字典实体
|
||||
*
|
||||
* @param id 主键
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(GET_BY_ID)
|
||||
R<Dict> getById(@RequestParam("id") Long id);
|
||||
|
||||
/**
|
||||
* 获取字典表对应值
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @param dictKey 字典序号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(GET_VALUE)
|
||||
R<String> getValue(@RequestParam("code") String code, @RequestParam("dictKey") String dictKey);
|
||||
|
||||
/**
|
||||
* 获取字典表
|
||||
*
|
||||
* @param code 字典编号
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(GET_LIST)
|
||||
R<List<Dict>> getList(@RequestParam("code") String code);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.feign;
|
||||
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.system.pojo.entity.Dict;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Feign失败配置
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Component
|
||||
public class IDictClientFallback implements IDictClient {
|
||||
@Override
|
||||
public R<Dict> getById(Long id) {
|
||||
return R.fail("获取数据失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<String> getValue(String code, String dictKey) {
|
||||
return R.fail("获取数据失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<Dict>> getList(String code) {
|
||||
return R.fail("获取数据失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.system.pojo.entity.Dict;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 数据传输对象实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DictDTO extends Dict {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_dict")
|
||||
@Schema(description = "Dict对象")
|
||||
public class Dict implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@Schema(description = "主键")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父主键
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@Schema(description = "父主键")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 字典码
|
||||
*/
|
||||
@Schema(description = "字典码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@Schema(description = "字典值")
|
||||
private String dictKey;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Schema(description = "字典名称")
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 字典备注
|
||||
*/
|
||||
@Schema(description = "字典备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否已封存
|
||||
*/
|
||||
@Schema(description = "是否已封存")
|
||||
private Integer isSealed;
|
||||
|
||||
/**
|
||||
* 业务状态
|
||||
*/
|
||||
@Schema(description = "业务状态")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否已删除
|
||||
*/
|
||||
@TableLogic
|
||||
@Schema(description = "是否已删除")
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_dict_biz")
|
||||
@Schema(description = "DictBiz对象")
|
||||
public class DictBiz implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@Schema(description = "主键")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 父主键
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@Schema(description = "父主键")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 字典码
|
||||
*/
|
||||
@Schema(description = "字典码")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@Schema(description = "字典值")
|
||||
private String dictKey;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Schema(description = "字典名称")
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 字典备注
|
||||
*/
|
||||
@Schema(description = "字典备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否已封存
|
||||
*/
|
||||
@Schema(description = "是否已封存")
|
||||
private Integer isSealed;
|
||||
|
||||
/**
|
||||
* 业务状态
|
||||
*/
|
||||
@Schema(description = "业务状态")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否已删除
|
||||
*/
|
||||
@TableLogic
|
||||
@Schema(description = "是否已删除")
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 业务字典枚举类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DictBizEnum {
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
TEST("test"),
|
||||
;
|
||||
|
||||
final String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 系统字典枚举类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DictEnum {
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
SEX("sex"),
|
||||
/**
|
||||
* 通知类型
|
||||
*/
|
||||
NOTICE("notice"),
|
||||
/**
|
||||
* 菜单类型
|
||||
*/
|
||||
MENU_CATEGORY("menu_category"),
|
||||
/**
|
||||
* 按钮功能
|
||||
*/
|
||||
BUTTON_FUNC("button_func"),
|
||||
/**
|
||||
* 是否
|
||||
*/
|
||||
YES_NO("yes_no"),
|
||||
/**
|
||||
* 流程类型
|
||||
*/
|
||||
FLOW("flow"),
|
||||
/**
|
||||
* 机构类型
|
||||
*/
|
||||
ORG_CATEGORY("org_category"),
|
||||
/**
|
||||
* 数据权限
|
||||
*/
|
||||
DATA_SCOPE_TYPE("data_scope_type"),
|
||||
/**
|
||||
* 接口权限
|
||||
*/
|
||||
API_SCOPE_TYPE("api_scope_type"),
|
||||
/**
|
||||
* 权限类型
|
||||
*/
|
||||
SCOPE_CATEGORY("scope_category"),
|
||||
/**
|
||||
* 对象存储类型
|
||||
*/
|
||||
OSS("oss"),
|
||||
/**
|
||||
* 短信服务类型
|
||||
*/
|
||||
SMS("sms"),
|
||||
/**
|
||||
* 岗位类型
|
||||
*/
|
||||
POST_CATEGORY("post_category"),
|
||||
/**
|
||||
* 行政区划
|
||||
*/
|
||||
REGION("region"),
|
||||
/**
|
||||
* 用户平台
|
||||
*/
|
||||
USER_TYPE("user_type"),
|
||||
;
|
||||
|
||||
final String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.tool.node.INode;
|
||||
import org.springblade.system.pojo.entity.DictBiz;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 视图实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "DictBizVO对象")
|
||||
public class DictBizVO extends DictBiz implements INode<DictBizVO> {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父节点ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 子孙节点
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<DictBizVO> children;
|
||||
|
||||
@Override
|
||||
public List<DictBizVO> getChildren() {
|
||||
if (this.children == null) {
|
||||
this.children = new ArrayList<>();
|
||||
}
|
||||
return this.children;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上级字典
|
||||
*/
|
||||
private String parentName;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.system.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.tool.node.INode;
|
||||
import org.springblade.system.pojo.entity.Dict;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 视图实体类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "DictVO对象")
|
||||
public class DictVO extends Dict implements INode<DictVO> {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父节点ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 子孙节点
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<DictVO> children;
|
||||
|
||||
@Override
|
||||
public List<DictVO> getChildren() {
|
||||
if (this.children == null) {
|
||||
this.children = new ArrayList<>();
|
||||
}
|
||||
return this.children;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上级字典
|
||||
*/
|
||||
private String parentName;
|
||||
}
|
||||
Reference in New Issue
Block a user