From 43ac462d09de49a3e7fb6a8879fb56b8421c0434 Mon Sep 17 00:00:00 2001 From: yuxc <653031404@qq.com> Date: 星期二, 28 三月 2023 09:54:18 +0800 Subject: [PATCH] 新建omd微服务以及移植字典功能 --- Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/mapper/DictBizMapper.java | 64 ++ Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/service/impl/DictBizServiceImpl.java | 142 ++++++ Source/BladeX/blade-service/blade-omd/src/main/resources/application-prod.yml | 10 Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/service/IDictBizService.java | 109 ++++ Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/feign/DictBizClient.java | 69 +++ Source/BladeX/blade-service/blade-omd/src/main/resources/application-dev.yml | 11 Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/enums/DictBizEnum.java | 39 + Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/wrapper/DictBizWrapper.java | 61 ++ Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/OmdApplication.java | 34 + Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/entity/DictBizM.java | 108 ++++ Source/BladeX/blade-service/blade-omd/src/main/resources/application-test.yml | 10 Source/BladeX/blade-service/blade-omd/pom.xml | 93 ++++ Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/vo/DictBizMVO.java | 71 +++ Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/controller/DictBizOmdController.java | 189 ++++++++ Source/BladeX/blade-service-api/blade-omd-api/pom.xml | 17 Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/feign/IDictBizClient.java | 84 +++ Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/mapper/DictBizMapper.xml | 51 ++ Source/BladeX/blade-service/pom.xml | 1 Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/feign/IDictBizClientFallback.java | 51 ++ Source/BladeX/blade-service-api/pom.xml | 1 Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/cache/DictBizCache.java | 133 +++++ 21 files changed, 1,348 insertions(+), 0 deletions(-) diff --git a/Source/BladeX/blade-service-api/blade-omd-api/pom.xml b/Source/BladeX/blade-service-api/blade-omd-api/pom.xml new file mode 100644 index 0000000..922d846 --- /dev/null +++ b/Source/BladeX/blade-service-api/blade-omd-api/pom.xml @@ -0,0 +1,17 @@ +<?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>3.0.1.RELEASE</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>blade-omd-api</artifactId> + <name>${project.artifactId}</name> + <version>${bladex.project.version}</version> + <packaging>jar</packaging> + +</project> diff --git a/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/cache/DictBizCache.java b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/cache/DictBizCache.java new file mode 100644 index 0000000..3846a05 --- /dev/null +++ b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/cache/DictBizCache.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.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.omd.entity.DictBizM; +import org.springblade.omd.enums.DictBizEnum; +import org.springblade.omd.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 DictBizM getById(Long id) { + String keyPrefix = DICT_ID.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); + return CacheUtil.get(DICT_CACHE, keyPrefix, id, () -> { + R<DictBizM> 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<DictBizM> 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<DictBizM>> result = getDictClient().getList(code); + return result.getData(); + }); + } + +} diff --git a/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/entity/DictBizM.java b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/entity/DictBizM.java new file mode 100644 index 0000000..f6fec5d --- /dev/null +++ b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/entity/DictBizM.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * 瀹炰綋绫� + * + * @author Chill + */ +@Data +@TableName("pl_sys_dict_biz") +@ApiModel(value = "DictBiz瀵硅薄", description = "DictBiz瀵硅薄") +public class DictBizM implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 涓婚敭 + */ + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "涓婚敭") + @TableId(value = "id", type = IdType.ASSIGN_ID) + private Long id; + + /** + * 绉熸埛ID + */ + @ApiModelProperty(value = "绉熸埛ID") + private String tenantId; + + /** + * 鐖朵富閿� + */ + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "鐖朵富閿�") + private Long parentId; + + /** + * 瀛楀吀鐮� + */ + @ApiModelProperty(value = "瀛楀吀鐮�") + private String code; + + /** + * 瀛楀吀鍊� + */ + @ApiModelProperty(value = "瀛楀吀鍊�") + private String dictKey; + + /** + * 瀛楀吀鍚嶇О + */ + @ApiModelProperty(value = "瀛楀吀鍚嶇О") + private String dictValue; + + /** + * 鎺掑簭 + */ + @ApiModelProperty(value = "鎺掑簭") + private Integer sort; + + /** + * 瀛楀吀澶囨敞 + */ + @ApiModelProperty(value = "瀛楀吀澶囨敞") + private String remark; + + /** + * 鏄惁宸插皝瀛� + */ + @ApiModelProperty(value = "鏄惁宸插皝瀛�") + private Integer isSealed; + + /** + * 鏄惁宸插垹闄� + */ + @TableLogic + @ApiModelProperty(value = "鏄惁宸插垹闄�") + private Integer isDeleted; + + +} diff --git a/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/enums/DictBizEnum.java b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/enums/DictBizEnum.java new file mode 100644 index 0000000..1bec1e8 --- /dev/null +++ b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/enums/DictBizEnum.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 涓氬姟瀛楀吀鏋氫妇绫� + * + * @author Chill + */ +@Getter +@AllArgsConstructor +public enum DictBizEnum { + + /** + * 娴嬭瘯 + */ + TEST("test"), + ; + + final String name; + +} diff --git a/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/feign/IDictBizClient.java b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/feign/IDictBizClient.java new file mode 100644 index 0000000..4add47b --- /dev/null +++ b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/feign/IDictBizClient.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.feign; + + +import org.springblade.core.tool.api.R; +import org.springblade.omd.entity.DictBizM; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.validation.Valid; +import java.util.List; + +/** + * Feign鎺ュ彛绫� + * + * @author Chill + */ +@FeignClient( + value = "blade-omd", + fallback = IDictBizClientFallback.class +) +public interface IDictBizClient { + + String API_PREFIX = "/client"; + String GET_BY_ID = API_PREFIX + "/dict-biz/get-by-id"; + String GET_VALUE = API_PREFIX + "/dict-biz/get-value"; + String GET_LIST = API_PREFIX + "/dict-biz/get-list"; + String CHECK_VALUE = API_PREFIX + "/dict-biz/check-value"; + + /** + * 鑾峰彇瀛楀吀瀹炰綋 + * + * @param id 涓婚敭 + * @return + */ + @GetMapping(GET_BY_ID) + R<DictBizM> 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<DictBizM>> getList(@RequestParam("code") String code); + + /** + * 妫�鏌ュ瓧鍏告槸鍚﹀瓨鍦紝瀛樺湪鍗宠繑鍥烇紝涓嶅瓨鍦ㄦ柊澧� + * + * @param dict 瀛楀吀鏁版嵁 + * @return + */ + @GetMapping(CHECK_VALUE) + R getCheck(@Valid @RequestBody DictBizM dict); + +} diff --git a/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/feign/IDictBizClientFallback.java b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/feign/IDictBizClientFallback.java new file mode 100644 index 0000000..59b2e31 --- /dev/null +++ b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/feign/IDictBizClientFallback.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.feign; + +import org.springblade.core.tool.api.R; +import org.springblade.omd.entity.DictBizM; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * Feign澶辫触閰嶇疆 + * + * @author Chill + */ +@Component +public class IDictBizClientFallback implements IDictBizClient { + @Override + public R<DictBizM> getById(Long id) { + return R.fail("鑾峰彇鏁版嵁澶辫触"); + } + + @Override + public R<String> getValue(String code, String dictKey) { + return R.fail("鑾峰彇鏁版嵁澶辫触"); + } + + @Override + public R<List<DictBizM>> getList(String code) { + return R.fail("鑾峰彇鏁版嵁澶辫触"); + } + + @Override + public R getCheck(DictBizM dict) { + return R.fail("鑾峰彇鏁版嵁澶辫触"); + } +} diff --git a/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/vo/DictBizMVO.java b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/vo/DictBizMVO.java new file mode 100644 index 0000000..aafd6ba --- /dev/null +++ b/Source/BladeX/blade-service-api/blade-omd-api/src/main/java/org/springblade/omd/vo/DictBizMVO.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.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.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tool.node.INode; +import org.springblade.omd.entity.DictBizM; + +import java.util.ArrayList; +import java.util.List; + +/** + * 瑙嗗浘瀹炰綋绫� + * + * @author Chill + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "DictBizVO瀵硅薄", description = "DictBizVO瀵硅薄") +public class DictBizMVO extends DictBizM implements INode<DictBizM> { + private static final long serialVersionUID = 1L; + /** + * 涓婚敭ID + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 鐖惰妭鐐笽D + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long parentId; + + /** + * 瀛愬瓩鑺傜偣 + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List<DictBizM> children; + + @Override + public List<DictBizM> getChildren() { + if (this.children == null) { + this.children = new ArrayList<>(); + } + return this.children; + } + + /** + * 涓婄骇瀛楀吀 + */ + private String parentName; +} diff --git a/Source/BladeX/blade-service-api/pom.xml b/Source/BladeX/blade-service-api/pom.xml index b4a57f8..effd0cb 100644 --- a/Source/BladeX/blade-service-api/pom.xml +++ b/Source/BladeX/blade-service-api/pom.xml @@ -22,6 +22,7 @@ <module>blade-system-api</module> <module>blade-user-api</module> <module>blade-code-api</module> + <module>blade-omd-api</module> </modules> <dependencies> diff --git a/Source/BladeX/blade-service/blade-omd/pom.xml b/Source/BladeX/blade-service/blade-omd/pom.xml new file mode 100644 index 0000000..40d7c15 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/pom.xml @@ -0,0 +1,93 @@ +<?xml version="1.0"?> +<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> + <groupId>org.springblade</groupId> + <artifactId>blade-service</artifactId> + <version>3.0.1.RELEASE</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + + <artifactId>blade-omd</artifactId> + <name>${project.artifactId}</name> + <version>${bladex.project.version}</version> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>org.springblade</groupId> + <artifactId>blade-core-boot</artifactId> + </dependency> + <dependency> + <groupId>org.springblade</groupId> + <artifactId>blade-starter-swagger</artifactId> + </dependency> + <dependency> + <groupId>org.springblade</groupId> + <artifactId>blade-omd-api</artifactId> + <version>${bladex.project.version}</version> + </dependency> + <dependency> + <groupId>org.springblade</groupId> + <artifactId>blade-flow-api</artifactId> + <version>${bladex.project.version}</version> + </dependency> + + <!--Oss--> + <dependency> + <groupId>org.springblade</groupId> + <artifactId>blade-starter-oss</artifactId> + </dependency> + <!--MinIO--> + <dependency> + <groupId>io.minio</groupId> + <artifactId>minio</artifactId> + </dependency> + <!--QiNiu--> + <dependency> + <groupId>com.qiniu</groupId> + <artifactId>qiniu-java-sdk</artifactId> + </dependency> + <!--<dependency> + <groupId>org.springblade</groupId> + <artifactId>blade-starter-transaction</artifactId> + </dependency>--> + <dependency> + <groupId>com.oracle.database.jdbc</groupId> + <artifactId>ojdbc8</artifactId> + </dependency> + <dependency> + <groupId>cn.easyproject</groupId> + <artifactId>orai18n</artifactId> + <version>${orai18n.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>com.spotify</groupId> + <artifactId>dockerfile-maven-plugin</artifactId> + <configuration> + <username>${docker.username}</username> + <password>${docker.password}</password> + <repository>${docker.registry.url}/${docker.namespace}/${project.artifactId}</repository> + <tag>${project.version}</tag> + <useMavenSettingsForAuth>true</useMavenSettingsForAuth> + <buildArgs> + <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE> + </buildArgs> + <skip>false</skip> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> diff --git a/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/OmdApplication.java b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/OmdApplication.java new file mode 100644 index 0000000..e7d2dd2 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/OmdApplication.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd; + +import org.springblade.core.cloud.client.BladeCloudApplication; +import org.springblade.core.launch.BladeApplication; + +/** + * 绯荤粺妯″潡鍚姩鍣� + * @author Chill + */ +@BladeCloudApplication +public class OmdApplication { + + public static void main(String[] args) { + BladeApplication.run("blade-omd", OmdApplication.class, args); + } + +} + diff --git a/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/controller/DictBizOmdController.java b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/controller/DictBizOmdController.java new file mode 100644 index 0000000..e3d4b3c --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/controller/DictBizOmdController.java @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.annotations.*; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.cache.utils.CacheUtil; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tenant.annotation.NonDS; +import org.springblade.core.tool.api.R; +import org.springblade.omd.entity.DictBizM; +import org.springblade.omd.service.IDictBizService; +import org.springblade.omd.vo.DictBizMVO; +import org.springblade.omd.wrapper.DictBizWrapper; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; + +/** + * 鎺у埗鍣� + * + * @author Chill + */ +@NonDS +@RestController +@AllArgsConstructor +@RequestMapping("/dict-biz") +@Api(value = "涓氬姟瀛楀吀", tags = "涓氬姟瀛楀吀") +public class DictBizOmdController extends BladeController { + + private final IDictBizService dictService; + + /** + * 璇︽儏 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "璇︽儏", notes = "浼犲叆dict") + public R<DictBizMVO> detail(DictBizM dict) { + DictBizM detail = dictService.getOne(Condition.getQueryWrapper(dict)); + return R.data(DictBizWrapper.build().entityVO(detail)); + } + + /** + * 鍒楄〃 + */ + @GetMapping("/list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "code", value = "瀛楀吀缂栧彿", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "dictValue", value = "瀛楀吀鍚嶇О", paramType = "query", dataType = "string") + }) + @ApiOperationSupport(order = 2) + @ApiOperation(value = "鍒楄〃", notes = "浼犲叆dict") + public R<List<DictBizMVO>> list(@ApiIgnore @RequestParam Map<String, Object> dict) { + List<DictBizM> list = dictService.list(Condition.getQueryWrapper(dict, DictBizM.class).lambda().orderByAsc(DictBizM::getSort)); + return R.data(DictBizWrapper.build().listNodeVO(list)); + } + + /** + * 椤剁骇鍒楄〃 + */ + @GetMapping("/parent-list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "code", value = "瀛楀吀缂栧彿", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "dictValue", value = "瀛楀吀鍚嶇О", paramType = "query", dataType = "string") + }) + @ApiOperationSupport(order = 3) + @ApiOperation(value = "鍒楄〃", notes = "浼犲叆dict") + public R<IPage<DictBizMVO>> parentList(@ApiIgnore @RequestParam Map<String, Object> dict, Query query) { + return R.data(dictService.parentList(dict, query)); + } + + /** + * 瀛愬垪琛� + */ + @GetMapping("/child-list") + @ApiImplicitParams({ + @ApiImplicitParam(name = "code", value = "瀛楀吀缂栧彿", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "dictValue", value = "瀛楀吀鍚嶇О", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "parentId", value = "瀛楀吀鍚嶇О", paramType = "query", dataType = "string") + }) + @ApiOperationSupport(order = 4) + @ApiOperation(value = "鍒楄〃", notes = "浼犲叆dict") + public R<List<DictBizMVO>> childList(@ApiIgnore @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) { + return R.data(dictService.childList(dict, parentId)); + } + + /** + * 鑾峰彇瀛楀吀鏍戝舰缁撴瀯 + */ + @GetMapping("/tree") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "鏍戝舰缁撴瀯", notes = "鏍戝舰缁撴瀯") + public R<List<DictBizMVO>> tree() { + List<DictBizMVO> tree = dictService.tree(); + return R.data(tree); + } + + /** + * 鑾峰彇瀛楀吀鏍戝舰缁撴瀯 + */ + @GetMapping("/parent-tree") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "鏍戝舰缁撴瀯", notes = "鏍戝舰缁撴瀯") + public R<List<DictBizMVO>> parentTree() { + List<DictBizMVO> tree = dictService.parentTree(); + return R.data(tree); + } + + /** + * 鏂板鎴栦慨鏀� + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "鏂板鎴栦慨鏀�", notes = "浼犲叆dict") + public R submit(@Valid @RequestBody DictBizM dict) { + CacheUtil.clear(DICT_CACHE); + return R.status(dictService.submit(dict)); + } + + + /** + * 鍒犻櫎 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "鍒犻櫎", notes = "浼犲叆ids") + public R remove(@ApiParam(value = "涓婚敭闆嗗悎", required = true) @RequestParam String ids) { + CacheUtil.clear(DICT_CACHE); + return R.status(dictService.removeDict(ids)); + } + + /** + * 鑾峰彇瀛楀吀 + */ + @GetMapping("/dictionary") + @ApiOperationSupport(order = 8) + @ApiOperation(value = "鑾峰彇瀛楀吀", notes = "鑾峰彇瀛楀吀") + public R<List<DictBizM>> dictionary(String code) { + List<DictBizM> tree = dictService.getList(code); + return R.data(tree); + } + + /** + * 鑾峰彇瀛楀吀鏍� + */ + @GetMapping("/dictionary-tree") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "鑾峰彇瀛楀吀鏍�", notes = "鑾峰彇瀛楀吀鏍�") + public R<List<DictBizMVO>> dictionaryTree(String code) { + List<DictBizM> tree = dictService.getList(code); + return R.data(DictBizWrapper.build().listNodeVO(tree)); + } + + /** + * 妫�鏌ュ瓧鍏告槸鍚﹀瓨鍦紝瀛樺湪鍗宠繑鍥烇紝涓嶅瓨鍦ㄦ柊澧� + */ + @PostMapping("/check") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "鏂板鎴栦慨鏀�", notes = "浼犲叆dict") + public R checkOrInsert(@Valid @RequestBody DictBizM dict) { + CacheUtil.clear(DICT_CACHE); + return dictService.checkOrInsert(dict); + } + +} diff --git a/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/feign/DictBizClient.java b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/feign/DictBizClient.java new file mode 100644 index 0000000..eb3b366 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/feign/DictBizClient.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.feign; + + +import lombok.AllArgsConstructor; +import org.springblade.core.tenant.annotation.NonDS; +import org.springblade.core.tool.api.R; +import org.springblade.omd.entity.DictBizM; +import org.springblade.omd.service.IDictBizService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import java.util.List; + + +/** + * 瀛楀吀鏈嶅姟Feign瀹炵幇绫� + * + * @author Chill + */ +@NonDS +@ApiIgnore +@RestController +@AllArgsConstructor +public class DictBizClient implements IDictBizClient { + + private final IDictBizService service; + + @Override + @GetMapping(GET_BY_ID) + public R<DictBizM> getById(Long id) { + return R.data(service.getById(id)); + } + + @Override + @GetMapping(GET_VALUE) + public R<String> getValue(String code, String dictKey) { + return R.data(service.getValue(code, dictKey)); + } + + @Override + @GetMapping(GET_LIST) + public R<List<DictBizM>> getList(String code) { + return R.data(service.getList(code)); + } + + @Override + @GetMapping(CHECK_VALUE) + public R getCheck(DictBizM dict) { + return service.checkOrInsert(dict); + } + +} diff --git a/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/mapper/DictBizMapper.java b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/mapper/DictBizMapper.java new file mode 100644 index 0000000..c835d01 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/mapper/DictBizMapper.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springblade.omd.entity.DictBizM; +import org.springblade.omd.vo.DictBizMVO; + +import java.util.List; + +/** + * Mapper 鎺ュ彛 + * + * @author Chill + */ +public interface DictBizMapper extends BaseMapper<DictBizM> { + + /** + * 鑾峰彇瀛楀吀琛ㄥ搴斾腑鏂� + * + * @param code 瀛楀吀缂栧彿 + * @param dictKey 瀛楀吀搴忓彿 + * @return + */ + String getValue(String code, String dictKey); + + /** + * 鑾峰彇瀛楀吀琛� + * + * @param code 瀛楀吀缂栧彿 + * @return + */ + List<DictBizM> getList(String code); + + /** + * 鑾峰彇鏍戝舰鑺傜偣 + * + * @return + */ + List<DictBizMVO> tree(); + + /** + * 鑾峰彇鏍戝舰鑺傜偣 + * + * @return + */ + List<DictBizMVO> parentTree(); + +} diff --git a/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/mapper/DictBizMapper.xml b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/mapper/DictBizMapper.xml new file mode 100644 index 0000000..f75b087 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/mapper/DictBizMapper.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="org.springblade.omd.mapper.DictBizMapper"> + + <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 --> + <resultMap id="dictResultMap" type="org.springblade.omd.entity.DictBizM"> + <id column="id" property="id"/> + <result column="tenant_id" property="tenantId"/> + <result column="parent_id" property="parentId"/> + <result column="code" property="code"/> + <result column="dict_key" property="dictKey"/> + <result column="dict_value" property="dictValue"/> + <result column="sort" property="sort"/> + <result column="remark" property="remark"/> + <result column="is_deleted" property="isDeleted"/> + </resultMap> + + <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode"> + <id column="id" property="id"/> + <result column="parent_id" property="parentId"/> + <result column="title" property="title"/> + <result column="value" property="value"/> + <result column="key" property="key"/> + </resultMap> + + <select id="getValue" resultType="java.lang.String"> + select + dict_value + from pl_sys_dict_biz where code = #{param1} and dict_key = #{param2} and is_deleted = 0 + </select> + + <!-- oracle 鐗堟湰 --> + <!--<select id="getValue" resultType="java.lang.String"> + select + dict_value + from pl_sys_dict_biz where code = #{param1, jdbcType=VARCHAR} and dict_key = #{param2} and dict_key >= 0 rownum 1 + </select>--> + + <select id="getList" resultMap="dictResultMap"> + select id, tenant_id, parent_id, code, dict_key, dict_value, sort, remark from pl_sys_dict_biz where code = #{param1} and parent_id > 0 and is_sealed = 0 and is_deleted = 0 + </select> + + <select id="tree" resultMap="treeNodeResultMap"> + select id, parent_id, dict_value as title, id as "value", id as "key" from pl_sys_dict_biz where is_deleted = 0 + </select> + + <select id="parentTree" resultMap="treeNodeResultMap"> + select id, parent_id, dict_value as title, id as "value", id as "key" from pl_sys_dict_biz where is_deleted = 0 and parent_id = 0 + </select> + +</mapper> diff --git a/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/service/IDictBizService.java b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/service/IDictBizService.java new file mode 100644 index 0000000..506c635 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/service/IDictBizService.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.service; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.omd.entity.DictBizM; +import org.springblade.omd.vo.DictBizMVO; + +import java.util.List; +import java.util.Map; + +/** + * 鏈嶅姟绫� + * + * @author Chill + */ +public interface IDictBizService extends IService<DictBizM> { + + /** + * 鏍戝舰缁撴瀯 + * + * @return + */ + List<DictBizMVO> tree(); + + /** + * 鏍戝舰缁撴瀯 + * + * @return + */ + List<DictBizMVO> parentTree(); + + /** + * 鑾峰彇瀛楀吀琛ㄥ搴斾腑鏂� + * + * @param code 瀛楀吀缂栧彿 + * @param dictKey 瀛楀吀搴忓彿 + * @return + */ + String getValue(String code, String dictKey); + + /** + * 鑾峰彇瀛楀吀琛� + * + * @param code 瀛楀吀缂栧彿 + * @return + */ + List<DictBizM> getList(String code); + + /** + * 鏂板鎴栦慨鏀� + * + * @param dict + * @return + */ + boolean submit(DictBizM dict); + + /** + * 鍒犻櫎瀛楀吀 + * + * @param ids + * @return + */ + boolean removeDict(String ids); + + /** + * 椤剁骇鍒楄〃 + * + * @param dict + * @param query + * @return + */ + IPage<DictBizMVO> parentList(Map<String, Object> dict, Query query); + + /** + * 瀛愬垪琛� + * + * @param dict + * @param parentId + * @return + */ + List<DictBizMVO> childList(Map<String, Object> dict, Long parentId); + + /** + * 鏂板鎴栦慨鏀� + * + * @param dict + * @return + */ + R checkOrInsert(DictBizM dict); +} diff --git a/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/service/impl/DictBizServiceImpl.java b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/service/impl/DictBizServiceImpl.java new file mode 100644 index 0000000..168ae02 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/service/impl/DictBizServiceImpl.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springblade.common.constant.CommonConstant; +import org.springblade.core.cache.utils.CacheUtil; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.constant.BladeConstant; +import org.springblade.core.tool.node.ForestNodeMerger; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringPool; +import org.springblade.omd.cache.DictBizCache; +import org.springblade.omd.entity.DictBizM; +import org.springblade.omd.mapper.DictBizMapper; +import org.springblade.omd.service.IDictBizService; +import org.springblade.omd.vo.DictBizMVO; +import org.springblade.omd.wrapper.DictBizWrapper; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; + +/** + * 鏈嶅姟瀹炵幇绫� + * + * @author Chill + */ +@Service +public class DictBizServiceImpl extends ServiceImpl<DictBizMapper, DictBizM> implements IDictBizService { + + @Override + public List tree() { + return ForestNodeMerger.merge((List)baseMapper.tree()); + } + + @Override + public List<DictBizMVO> parentTree() { + return ForestNodeMerger.merge((List)baseMapper.parentTree()); + } + + @Override + public String getValue(String code, String dictKey) { + return Func.toStr(baseMapper.getValue(code, dictKey), StringPool.EMPTY); + } + + @Override + public List<DictBizM> getList(String code) { + return baseMapper.getList(code); + } + + @Override + public boolean submit(DictBizM dict) { + LambdaQueryWrapper<DictBizM> lqw = Wrappers.<DictBizM>query().lambda().eq(DictBizM::getCode, dict.getCode()).eq(DictBizM::getDictKey, dict.getDictKey()); + Long cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(DictBizM::getId, dict.getId())); + if (cnt > 0L) { + throw new ServiceException("褰撳墠瀛楀吀閿�煎凡瀛樺湪!"); + } + // 淇敼椤剁骇瀛楀吀鍚庡悓姝ユ洿鏂颁笅灞炲瓧鍏哥殑缂栧彿 + if (Func.isNotEmpty(dict.getId()) && dict.getParentId().longValue() == BladeConstant.TOP_PARENT_ID) { + DictBizM parent = DictBizCache.getById(dict.getId()); + this.update(Wrappers.<DictBizM>update().lambda().set(DictBizM::getCode, dict.getCode()).eq(DictBizM::getCode, parent.getCode()).ne(DictBizM::getParentId, BladeConstant.TOP_PARENT_ID)); + } + if (Func.isEmpty(dict.getParentId())) { + dict.setParentId(BladeConstant.TOP_PARENT_ID); + } + dict.setIsDeleted(BladeConstant.DB_NOT_DELETED); + CacheUtil.clear(DICT_CACHE); + return saveOrUpdate(dict); + } + + @Override + public boolean removeDict(String ids) { + Long cnt = baseMapper.selectCount(Wrappers.<DictBizM>query().lambda().in(DictBizM::getParentId, Func.toLongList(ids))); + if (cnt > 0L) { + throw new ServiceException("璇峰厛鍒犻櫎瀛愯妭鐐�!"); + } + return removeByIds(Func.toLongList(ids)); + } + + @Override + public IPage<DictBizMVO> parentList(Map<String, Object> dict, Query query) { + IPage<DictBizM> page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, DictBizM.class).lambda().eq(DictBizM::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(DictBizM::getSort)); + return DictBizWrapper.build().pageVO(page); + } + + @Override + public List<DictBizMVO> childList(Map<String, Object> dict, Long parentId) { + if (parentId < 0) { + return new ArrayList<>(); + } + dict.remove("parentId"); + DictBizM parentDict = DictBizCache.getById(parentId); + List<DictBizM> list = this.list(Condition.getQueryWrapper(dict, DictBizM.class).lambda().ne(DictBizM::getId, parentId).eq(DictBizM::getCode, parentDict.getCode()).orderByAsc(DictBizM::getSort)); + return DictBizWrapper.build().listNodeVO(list); + } + + @Override + public R checkOrInsert(DictBizM dict) { + + LambdaQueryWrapper<DictBizM> lqw = Wrappers.<DictBizM>query().lambda().eq(DictBizM::getCode, dict.getCode()).eq(DictBizM::getDictKey, dict.getDictKey()); + Long cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(DictBizM::getId, dict.getId())); + if (cnt > 0L) { + return R.fail("瀛楀吀宸茬粡瀛樺湪锛�"); + } + + if (Func.isEmpty(dict.getParentId())) { + dict.setParentId(BladeConstant.TOP_PARENT_ID); + } + dict.setIsDeleted(BladeConstant.DB_NOT_DELETED); + CacheUtil.clear(DICT_CACHE); + + if(saveOrUpdate(dict) == true){ + return R.success("鎿嶄綔鎴愬姛!"); + } + return R.fail("鎿嶄綔澶辫触锛�"); + + } +} diff --git a/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/wrapper/DictBizWrapper.java b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/wrapper/DictBizWrapper.java new file mode 100644 index 0000000..c1324ab --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/java/org/springblade/omd/wrapper/DictBizWrapper.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 搴勯獮 (smallchill@163.com) + */ +package org.springblade.omd.wrapper; + +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.core.tool.constant.BladeConstant; +import org.springblade.core.tool.node.ForestNodeMerger; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.omd.cache.DictBizCache; +import org.springblade.omd.entity.DictBizM; +import org.springblade.omd.vo.DictBizMVO; + +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + + +/** + * 鍖呰绫�,杩斿洖瑙嗗浘灞傛墍闇�鐨勫瓧娈� + * + * @author Chill + */ +public class DictBizWrapper extends BaseEntityWrapper<DictBizM, DictBizMVO> { + + public static DictBizWrapper build() { + return new DictBizWrapper(); + } + + @Override + public DictBizMVO entityVO(DictBizM dict) { + DictBizMVO dictVO = Objects.requireNonNull(BeanUtil.copy(dict, DictBizMVO.class)); + if (Func.equals(dict.getParentId(), BladeConstant.TOP_PARENT_ID)) { + dictVO.setParentName(BladeConstant.TOP_PARENT_NAME); + } else { + DictBizM parent = DictBizCache.getById(dict.getParentId()); + dictVO.setParentName(parent.getDictValue()); + } + return dictVO; + } + + public List<DictBizMVO> listNodeVO(List<DictBizM> list) { + List<DictBizMVO> collect = list.stream().map(dict -> BeanUtil.copy(dict, DictBizMVO.class)).collect(Collectors.toList()); + return ForestNodeMerger.merge((List)collect); + } + +} diff --git a/Source/BladeX/blade-service/blade-omd/src/main/resources/application-dev.yml b/Source/BladeX/blade-service/blade-omd/src/main/resources/application-dev.yml new file mode 100644 index 0000000..5fdf0dc --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/resources/application-dev.yml @@ -0,0 +1,11 @@ +#鏈嶅姟鍣ㄧ鍙� +server: + port: 36015 + +#鏁版嵁婧愰厤缃� +spring: + datasource: + url: ${blade.datasource.dev.url} + username: ${blade.datasource.dev.username} + password: ${blade.datasource.dev.password} + diff --git a/Source/BladeX/blade-service/blade-omd/src/main/resources/application-prod.yml b/Source/BladeX/blade-service/blade-omd/src/main/resources/application-prod.yml new file mode 100644 index 0000000..08082e2 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/resources/application-prod.yml @@ -0,0 +1,10 @@ +#鏈嶅姟鍣ㄧ鍙� +server: + port: 8105 + +#鏁版嵁婧愰厤缃� +spring: + datasource: + url: ${blade.datasource.prod.url} + username: ${blade.datasource.prod.username} + password: ${blade.datasource.prod.password} diff --git a/Source/BladeX/blade-service/blade-omd/src/main/resources/application-test.yml b/Source/BladeX/blade-service/blade-omd/src/main/resources/application-test.yml new file mode 100644 index 0000000..a40a289 --- /dev/null +++ b/Source/BladeX/blade-service/blade-omd/src/main/resources/application-test.yml @@ -0,0 +1,10 @@ +#鏈嶅姟鍣ㄧ鍙� +server: + port: 8105 + +#鏁版嵁婧愰厤缃� +spring: + datasource: + url: ${blade.datasource.test.url} + username: ${blade.datasource.test.username} + password: ${blade.datasource.test.password} diff --git a/Source/BladeX/blade-service/pom.xml b/Source/BladeX/blade-service/pom.xml index ae9fcd7..6920bb2 100644 --- a/Source/BladeX/blade-service/pom.xml +++ b/Source/BladeX/blade-service/pom.xml @@ -22,6 +22,7 @@ <module>blade-system</module> <module>blade-user</module> <module>blade-code</module> + <module>blade-omd</module> </modules> <dependencies> -- Gitblit v1.9.3