¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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(); |
| | | }); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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; |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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("è·åæ°æ®å¤±è´¥"); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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; |
| | | |
| | | /** |
| | | * ç¶èç¹ID |
| | | */ |
| | | @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; |
| | | } |
| | |
| | | <module>blade-system-api</module> |
| | | <module>blade-user-api</module> |
| | | <module>blade-code-api</module> |
| | | <module>blade-omd-api</module> |
| | | </modules> |
| | | |
| | | <dependencies> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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); |
| | | } |
| | | |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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(); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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("æä½å¤±è´¥ï¼"); |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | #æå¡å¨ç«¯å£ |
| | | server: |
| | | port: 36015 |
| | | |
| | | #æ°æ®æºé
ç½® |
| | | spring: |
| | | datasource: |
| | | url: ${blade.datasource.dev.url} |
| | | username: ${blade.datasource.dev.username} |
| | | password: ${blade.datasource.dev.password} |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | #æå¡å¨ç«¯å£ |
| | | server: |
| | | port: 8105 |
| | | |
| | | #æ°æ®æºé
ç½® |
| | | spring: |
| | | datasource: |
| | | url: ${blade.datasource.prod.url} |
| | | username: ${blade.datasource.prod.username} |
| | | password: ${blade.datasource.prod.password} |
¶Ô±ÈÐÂÎļþ |
| | |
| | | #æå¡å¨ç«¯å£ |
| | | server: |
| | | port: 8105 |
| | | |
| | | #æ°æ®æºé
ç½® |
| | | spring: |
| | | datasource: |
| | | url: ${blade.datasource.test.url} |
| | | username: ${blade.datasource.test.username} |
| | | password: ${blade.datasource.test.password} |
| | |
| | | <module>blade-system</module> |
| | | <module>blade-user</module> |
| | | <module>blade-code</module> |
| | | <module>blade-omd</module> |
| | | </modules> |
| | | |
| | | <dependencies> |