¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.cache; |
| | | |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import com.vci.ubcs.omd.feign.IOmdAttributeClient; |
| | | 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 java.util.List; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; |
| | | |
| | | |
| | | /** |
| | | * å
æ°æ®(屿§)ç¼åå·¥å
·ç±» |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class OmdAttributeCache { |
| | | |
| | | private static final String ATTR_ID = "attr:id"; |
| | | private static final String ATTR_LIST = "attr:list"; |
| | | private static final String ATTR_CACHE = "ubcs:attr"; |
| | | |
| | | private static IOmdAttributeClient attrClient; |
| | | |
| | | private static IOmdAttributeClient getAttributeClient() { |
| | | if (attrClient == null) { |
| | | attrClient = SpringUtil.getBean(IOmdAttributeClient.class); |
| | | } |
| | | return attrClient; |
| | | } |
| | | |
| | | /** |
| | | * è·åå
æ°æ®å®ä½ |
| | | * |
| | | * @param id ä¸»é® |
| | | * @return å
æ°æ®å®ä½å¯¹è±¡ |
| | | */ |
| | | public static OmdAttribute getById(Long id) { |
| | | String keyPrefix = ATTR_ID.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(ATTR_CACHE, keyPrefix, id, () -> { |
| | | R<OmdAttribute> result = getAttributeClient().getById(id); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * è·åå
æ°æ®éå |
| | | * |
| | | * @param key 屿§åç§° |
| | | */ |
| | | public static List<OmdAttribute> getList(String key) { |
| | | String keyPrefix = ATTR_LIST.concat(StringPool.DASH).concat(AuthUtil.getTenantId()).concat(StringPool.COLON); |
| | | return CacheUtil.get(DICT_CACHE, keyPrefix, key, () -> { |
| | | R<List<OmdAttribute>> result = getAttributeClient().getList(key); |
| | | return result.getData(); |
| | | }); |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.constant; |
| | | |
| | | /** |
| | | * Description: |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/4 |
| | | */ |
| | | public class OmdCacheConstant { |
| | | /** |
| | | * å
æ°æ® |
| | | */ |
| | | public static final String ATTR_CACHE = "ubcs:attr"; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.dto; |
| | | |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | |
| | | /** |
| | | * Description: å
æ°æ®é¡µé¢ä¼ è¾å¯¹è±¡ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/4 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class OmdAttributeDTO extends OmdAttribute { |
| | | |
| | | /** |
| | | * åºåå |
| | | */ |
| | | private static final long serialVersionUID = 5515095331865594996L; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.entity; |
| | | |
| | | 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 lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | import org.springframework.data.annotation.Transient; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | |
| | | /** |
| | | * Description: å
æ°æ®(屿§æ± ) |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | @Data |
| | | @ToString(callSuper = true) |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("pl_omd_attribute") |
| | | @ApiModel(value = "屿§å¯¹è±¡", description = "屿§å¯¹è±¡") |
| | | public class OmdAttribute extends BaseEntity { |
| | | /** |
| | | * åºåå |
| | | */ |
| | | private static final long serialVersionUID = -6792640675358002410L; |
| | | |
| | | /** |
| | | * ç§æ·ID |
| | | */ |
| | | @ApiModelProperty(value = "ç§æ·ID") |
| | | private String tenantId; |
| | | |
| | | /** |
| | | * åæ®µç¼å· |
| | | */ |
| | | @ApiModelProperty(value = "åæ®µç¼å·") |
| | | @NotNull |
| | | private String key; |
| | | |
| | | /** |
| | | * åæ®µåç§° |
| | | */ |
| | | @ApiModelProperty(value = "åæ®µåç§°") |
| | | private String label; |
| | | |
| | | /** |
| | | * 屿§ç±»ååå
¸ç |
| | | */ |
| | | @ApiModelProperty(value = "屿§ç±»ååå
¸ç ") |
| | | private String typeCode; |
| | | |
| | | /** |
| | | * 屿§ç±»ååå
¸å¼ |
| | | */ |
| | | @ApiModelProperty(value = "屿§ç±»ååå
¸å¼") |
| | | private String typeKey; |
| | | |
| | | /** |
| | | * 屿§ç±»ååå
¸æ¾ç¤ºåç§° |
| | | */ |
| | | @Transient |
| | | private String typeValue; |
| | | |
| | | |
| | | /** |
| | | * æ ç¾ |
| | | */ |
| | | @ApiModelProperty(value = "æ ç¾") |
| | | private String hashtag; |
| | | |
| | | /** |
| | | * æè¿° |
| | | */ |
| | | @ApiModelProperty(value = "æè¿°") |
| | | private String description; |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºç©º |
| | | */ |
| | | @ApiModelProperty("æ¯å¦ä¸ºç©º") |
| | | private String nullable; |
| | | |
| | | /** |
| | | * æå¤§é¿åº¦ |
| | | */ |
| | | @ApiModelProperty("æå¤§é¿åº¦") |
| | | private Integer maxLength; |
| | | |
| | | /** |
| | | * 精度 |
| | | */ |
| | | @ApiModelProperty("精度") |
| | | private Integer precision; |
| | | |
| | | /** |
| | | * åç
§çç±»å |
| | | */ |
| | | @ApiModelProperty("åç
§ç±»ååå
¸ç ") |
| | | private String referTypeCode; |
| | | |
| | | /** |
| | | * åç
§ç±»ååå
¸å¼ |
| | | */ |
| | | @ApiModelProperty("åç
§ç±»ååå
¸å¼") |
| | | private String referTypeKey; |
| | | |
| | | /** |
| | | * åç
§ç±»ååå
¸æ¾ç¤ºåç§° |
| | | */ |
| | | @Transient |
| | | private String referTypeValue; |
| | | |
| | | /** |
| | | * åç
§å¯¹è±¡ |
| | | */ |
| | | @ApiModelProperty("åç
§ç主é®") |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long referToId; |
| | | |
| | | /** |
| | | * åç
§å¯¹è±¡çåç§° |
| | | */ |
| | | @ApiModelProperty("åç
§å¯¹è±¡åç§°") |
| | | private String referToName; |
| | | |
| | | /** |
| | | * 使ç¨åå
¸ |
| | | */ |
| | | @ApiModelProperty("使ç¨åå
¸") |
| | | private String usingDict; |
| | | |
| | | /** |
| | | * åå
¸ç |
| | | */ |
| | | @ApiModelProperty("åå
¸ç ") |
| | | private String dictCode; |
| | | |
| | | /** |
| | | * åå
¸é®å¼ |
| | | */ |
| | | @ApiModelProperty("åå
¸é®å¼") |
| | | private String dictKey; |
| | | |
| | | /** |
| | | * åå
¸æ¾ç¤ºå¼ |
| | | */ |
| | | @Transient |
| | | private String dictValue; |
| | | |
| | | /** |
| | | * é»è®¤å¼ |
| | | */ |
| | | @ApiModelProperty("é»è®¤å¼") |
| | | private String defaultValue; |
| | | /** |
| | | * æ¯è¾æ¹å¼ |
| | | */ |
| | | @Transient |
| | | private String calculateType; |
| | | |
| | | /** |
| | | * æ¯è¾å¼ |
| | | */ |
| | | @Transient |
| | | private String calculateValue; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.ToString; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | |
| | | |
| | | /** |
| | | * Description: åæ®µèå´ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @TableName("pl_omd_field_range") |
| | | @ApiModel(value = "åæ®µèå´",description = "åæ®µèå´") |
| | | public class OmdFieldRange extends BaseEntity { |
| | | /** |
| | | * åºåå |
| | | */ |
| | | private static final long serialVersionUID = 7849276277821126507L; |
| | | /** |
| | | * æ¯è¾æ¹å¼ |
| | | */ |
| | | @ApiModelProperty("æ¯è¾æ¹å¼") |
| | | private String calculateType; |
| | | |
| | | /** |
| | | * æ¯è¾å¼ |
| | | */ |
| | | @ApiModelProperty("æ¯è¾å¼") |
| | | private String calculateValue; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.enums; |
| | | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * Description: 屿§ç±»åæä¸¾ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum OmdCompareTypeEnum { |
| | | /** |
| | | * å¤§äº |
| | | */ |
| | | GRATE_THAN("grate_than",">"), |
| | | /** |
| | | * å°äº |
| | | */ |
| | | LESS_THAN("less_than","<"), |
| | | /** |
| | | * 大äºçäº |
| | | */ |
| | | GRATE_EQUAL("grate_equal",">="), |
| | | /** |
| | | * å°äºçäº |
| | | */ |
| | | LESS_EQUAL("less_equal","<="), |
| | | /** |
| | | * çäº |
| | | */ |
| | | EQUAL("equal","="), |
| | | /** |
| | | * ä¸çäº |
| | | */ |
| | | NOT_EQUAL("not_equal","!="), |
| | | /** |
| | | * èå´ |
| | | */ |
| | | BETWEEN("between","[]"), |
| | | ; |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | private final String value; |
| | | |
| | | /** |
| | | * æ¾ç¤ºå¼ |
| | | */ |
| | | private final String text; |
| | | |
| | | /** |
| | | * æ ¹æ®åç§°è·å对åºçæä¸¾å¼ |
| | | * |
| | | * @param text åç§° |
| | | * @return æä¸¾å¼ |
| | | */ |
| | | public static String getValueByText(String text) { |
| | | for (OmdCompareTypeEnum item : OmdCompareTypeEnum.values()) { |
| | | if (item.getText().equalsIgnoreCase(text)) { |
| | | return item.getValue(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æä¸¾å¼è·ååç§° |
| | | * |
| | | * @param value æä¸¾å¼ |
| | | * @return åç§° |
| | | */ |
| | | public static String getTextByValue(String value) { |
| | | for (OmdCompareTypeEnum item : OmdCompareTypeEnum.values()) { |
| | | if (item.getValue().equalsIgnoreCase(value)) { |
| | | return item.getText(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æä¸¾å¼è·å对象 |
| | | * |
| | | * @param value æä¸¾å¼ |
| | | * @return æä¸¾å¯¹è±¡ |
| | | */ |
| | | public static OmdCompareTypeEnum forValue(String value) { |
| | | for (OmdCompareTypeEnum item : OmdCompareTypeEnum.values()) { |
| | | if (item.getValue().equalsIgnoreCase(value)) { |
| | | return item; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.enums; |
| | | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * Description: 屿§ç±»åæä¸¾ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum OmdFieldTypeEnum { |
| | | /** |
| | | * å符串 |
| | | */ |
| | | VTSTRING("VTString","å符串"), |
| | | /** |
| | | * æ´æ° |
| | | */ |
| | | VTINTEGER("VTInteger","æ´æ°"), |
| | | /** |
| | | * å¸å° |
| | | */ |
| | | VTBOOLEAN("VTBoolean","å¸å°"), |
| | | /** |
| | | * é¿æ´æ° |
| | | */ |
| | | VTLONG("VTLong","é¿æ´æ°"), |
| | | /** |
| | | * æµ®ç¹æ° |
| | | */ |
| | | VTDOUBLE("VTDouble","æµ®ç¹æ°"), |
| | | /** |
| | | * æ¥æ |
| | | */ |
| | | VTDATE("VTDate","æ¥æ"), |
| | | /** |
| | | * æ¶é´ |
| | | */ |
| | | VTTIME("VTTime","æ¶é´"), |
| | | /** |
| | | * æ¥ææ¶é´ |
| | | */ |
| | | VTDATETIME("VTDateTime","æ¥ææ¶é´"), |
| | | ; |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | private final String value; |
| | | |
| | | /** |
| | | * æ¾ç¤ºå¼ |
| | | */ |
| | | private final String text; |
| | | |
| | | /** |
| | | * æ ¹æ®åç§°è·å对åºçæä¸¾å¼ |
| | | * |
| | | * @param text åç§° |
| | | * @return æä¸¾å¼ |
| | | */ |
| | | public static String getValueByText(String text) { |
| | | for (OmdFieldTypeEnum item : OmdFieldTypeEnum.values()) { |
| | | if (item.getText().equalsIgnoreCase(text)) { |
| | | return item.getValue(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æä¸¾å¼è·ååç§° |
| | | * |
| | | * @param value æä¸¾å¼ |
| | | * @return åç§° |
| | | */ |
| | | public static String getTextByValue(String value) { |
| | | for (OmdFieldTypeEnum item : OmdFieldTypeEnum.values()) { |
| | | if (item.getValue().equalsIgnoreCase(value)) { |
| | | return item.getText(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æä¸¾å¼è·å对象 |
| | | * |
| | | * @param value æä¸¾å¼ |
| | | * @return æä¸¾å¯¹è±¡ |
| | | */ |
| | | public static OmdFieldTypeEnum forValue(String value) { |
| | | for (OmdFieldTypeEnum item : OmdFieldTypeEnum.values()) { |
| | | if (item.getValue().equalsIgnoreCase(value)) { |
| | | return item; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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 com.vci.ubcs.omd.feign; |
| | | |
| | | |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Feignæ¥å£ç±» |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @FeignClient( |
| | | value = AppConstant.APPLICATION_NAME_OMD, |
| | | fallback = IOmdAttributeFallback.class |
| | | ) |
| | | public interface IOmdAttributeClient { |
| | | |
| | | String API_PREFIX = "/client"; |
| | | String GET_BY_ID = API_PREFIX + "/attribute/get-by-id"; |
| | | String GET_LIST = API_PREFIX + "/attribute/get-list"; |
| | | |
| | | |
| | | /** |
| | | * è·åå
æ°æ®å¯¹è±¡ |
| | | * @param id ä¸»é® |
| | | * @return å
æ°æ®å¯¹è±¡ |
| | | */ |
| | | @GetMapping(GET_BY_ID) |
| | | R<OmdAttribute> getById(@RequestParam("id") Long id); |
| | | |
| | | /** |
| | | * è·åå
æ°æ®å表 |
| | | * @param key æ¥è¯¢å±æ§å |
| | | * @return å
æ°æ®å表 |
| | | */ |
| | | @GetMapping(GET_LIST) |
| | | R<List<OmdAttribute>> getList(@RequestParam("key") String key); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * 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 com.vci.ubcs.omd.feign; |
| | | |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Feign失败é
ç½® |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Component |
| | | public class IOmdAttributeFallback implements IOmdAttributeClient { |
| | | @Override |
| | | public R<OmdAttribute> getById(Long id) { |
| | | return R.fail("è·åæ°æ®å¤±è´¥"); |
| | | } |
| | | |
| | | @Override |
| | | public R<List<OmdAttribute>> getList(String code) { |
| | | return R.fail("è·åæ°æ®å¤±è´¥"); |
| | | } |
| | | |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * Description: å
æ°æ®æ¾ç¤ºå¯¹è±¡ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "å
æ°æ®æ¾ç¤ºå¯¹è±¡", description = "å
æ°æ®æ¾ç¤ºå¯¹è±¡") |
| | | public class OmdAttributeVO extends OmdAttribute { |
| | | /** |
| | | * åºåå |
| | | */ |
| | | private static final long serialVersionUID = 279638479374768539L; |
| | | |
| | | /** |
| | | * 主é®ID |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("åæ®µèå´") |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | List<OmdFieldRangeVO> fieldRanges; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.vo; |
| | | |
| | | import com.vci.ubcs.omd.entity.OmdFieldRange; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | |
| | | /** |
| | | * Description: åæ®µèå´æ¾ç¤ºå¯¹è±¡ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ApiModel(value = "åæ®µèå´æ¾ç¤ºå¯¹è±¡", description = "åæ®µèå´æ¾ç¤ºå¯¹è±¡") |
| | | public class OmdFieldRangeVO extends OmdFieldRange { |
| | | /** |
| | | * åºåå |
| | | */ |
| | | private static final long serialVersionUID = 1770817945737478318L; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.controller; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.omd.constant.OmdCacheConstant; |
| | | import com.vci.ubcs.omd.dto.OmdAttributeDTO; |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import com.vci.ubcs.omd.service.IOmdAttributeService; |
| | | import com.vci.ubcs.omd.vo.OmdAttributeVO; |
| | | import com.vci.ubcs.omd.wrapper.OmdAttributeWrapper; |
| | | 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.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Description: å
æ°æ®(屿§)æ§å¶å¨ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | @NonDS |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/attribute") |
| | | @Api(value = "å
æ°æ®æ§å¶å¨", tags = "å
æ°æ®æ§å¶å¨") |
| | | public class OmdAttributeController extends BladeController { |
| | | /** |
| | | * å
æ°æ®æå¡ |
| | | */ |
| | | private IOmdAttributeService attributeService; |
| | | |
| | | /** |
| | | * æ¥ç详æ
|
| | | * @param id ä¸»é® |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "æ¥ç详æ
", notes = "ä¼ å
¥ä¸»é®") |
| | | public R<OmdAttributeVO> detail(Long id) { |
| | | return R.data(attributeService.getAttributeDetail(id)); |
| | | } |
| | | |
| | | /** |
| | | * å表 |
| | | * @param condition æ¥è¯¢æ¡ä»¶ |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "key", value = "屿§å", paramType = "query", dataType = "string"), |
| | | }) |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "æ¥è¯¢å表", notes = "ä¼ å
¥æ¥è¯¢") |
| | | public R<List<OmdAttributeVO>> list(@ApiIgnore @RequestParam Map<String, Object> condition) { |
| | | return R.data(OmdAttributeWrapper.build().listEntityVO(attributeService.list(Condition.getQueryWrapper(condition, OmdAttribute.class).lambda().orderByAsc(OmdAttribute::getKey)))); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢æä¿®æ¹ |
| | | * @param dto å
æ°æ®é¡µé¢ä¼ è¾å¯¹è±¡ |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "æ°å¢æä¿®æ¹", notes = "ä¼ å
¥å
æ°æ®å¯¹è±¡") |
| | | public R submit(@Valid @RequestBody OmdAttributeDTO dto) { |
| | | CacheUtil.clear(OmdCacheConstant.ATTR_CACHE); |
| | | return R.status(attributeService.submit(dto)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ |
| | | * @param ids 主é®éå |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "å é¤", notes = "主é®éå") |
| | | public R remove(@ApiParam(value = "主é®éå", required = true) @RequestParam String ids) { |
| | | CacheUtil.clear(OmdCacheConstant.ATTR_CACHE); |
| | | return R.status(attributeService.removeAttrs(ids)); |
| | | } |
| | | |
| | | /** |
| | | * æ¥çåºç¨èå´ |
| | | * @param id ä¸»é® |
| | | * @return æ¥è¯¢ç»æ |
| | | */ |
| | | @GetMapping("/applyRange") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "æ¥çåºç¨èå´",notes = "ä¼ å
¥ä¸»é®") |
| | | public R applyRange(Long id){ |
| | | return R.data(attributeService.applyRange(id)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.feign; |
| | | |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import com.vci.ubcs.omd.service.IOmdAttributeService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Description: å
æ°æ®æå¡feignè°ç¨ç±» |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/4 |
| | | */ |
| | | @NonDS |
| | | @ApiIgnore |
| | | @RestController |
| | | @AllArgsConstructor |
| | | public class OmdAttributeClient implements IOmdAttributeClient{ |
| | | private final IOmdAttributeService service; |
| | | |
| | | @Override |
| | | @GetMapping(GET_BY_ID) |
| | | public R<OmdAttribute> getById(Long id) { |
| | | return R.data(service.getById(id)); |
| | | } |
| | | |
| | | @Override |
| | | @GetMapping(GET_LIST) |
| | | public R<List<OmdAttribute>> getList(String key) { |
| | | Map<String,Object> condition = new HashMap<>(); |
| | | condition.put("key",key); |
| | | return R.data(service.list(Condition.getQueryWrapper(condition, OmdAttribute.class).lambda().orderByAsc(OmdAttribute::getKey))); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.mapper; |
| | | |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import org.springblade.core.mp.mapper.BladeMapper; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Description:å
æ°æ®æ°æ®å± |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | public interface OmdAttributeMapper extends BladeMapper<OmdAttribute> { |
| | | |
| | | /** |
| | | * æ¥è¯¢å
¨é¨ |
| | | * @return æ¥è¯¢ç»æ |
| | | */ |
| | | List<OmdAttribute> selectAll(); |
| | | |
| | | /** |
| | | * 䏻鮿¥è¯¢ |
| | | * @param primaryKey ä¸»é® |
| | | * @return æ¥è¯¢ç»æ |
| | | */ |
| | | OmdAttribute selectByPrimaryKey(Long primaryKey); |
| | | |
| | | /** |
| | | * 䏻鮿¹éæ¥è¯¢ |
| | | * @param primaryKeyCollection 主é®éå |
| | | * @return æ¥è¯¢ç»æ |
| | | */ |
| | | List<OmdAttribute> selectByPrimaryKeyCollection(Collection<String> primaryKeyCollection); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.service; |
| | | |
| | | import com.vci.ubcs.omd.dto.OmdAttributeDTO; |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import com.vci.ubcs.omd.vo.OmdAttributeVO; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * Description: å
æ°æ®(屿§)çæå¡æ¥å£ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | public interface IOmdAttributeService extends BaseService<OmdAttribute> { |
| | | |
| | | /** |
| | | * è·åå
æ°æ®è¯¦æ
|
| | | * @param id ä¸»é® |
| | | * @return å
æ°æ®æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | OmdAttributeVO getAttributeDetail(Long id); |
| | | |
| | | /** |
| | | * æ°å¢æä¿®æ¹ |
| | | * @param dto 页é¢ä¼ è¾å¯¹è±¡ |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | boolean submit(OmdAttributeDTO dto); |
| | | |
| | | /** |
| | | * å é¤ |
| | | * @param ids 主é®éå |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | boolean removeAttrs(String ids); |
| | | |
| | | /** |
| | | * æ¥çåºç¨èå´ |
| | | * @param id ä¸»é® |
| | | * @return æ¥è¯¢å·²åºç¨çä¸å¡ç±»ååç§° |
| | | */ |
| | | List<String> applyRange(Long id); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.vci.ubcs.core.log.exception.ServiceException; |
| | | import com.vci.ubcs.omd.constant.OmdCacheConstant; |
| | | import com.vci.ubcs.omd.dto.OmdAttributeDTO; |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import com.vci.ubcs.omd.mapper.OmdAttributeMapper; |
| | | import com.vci.ubcs.omd.service.IOmdAttributeService; |
| | | import com.vci.ubcs.omd.vo.OmdAttributeVO; |
| | | import com.vci.ubcs.omd.wrapper.OmdAttributeWrapper; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * Description: å
æ°æ®(屿§)çæå¡ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | @Service |
| | | public class OmdAttributeServiceImpl extends ServiceImpl<OmdAttributeMapper, OmdAttribute> implements IOmdAttributeService { |
| | | |
| | | @Override |
| | | public boolean deleteLogic(@NotEmpty List<Long> ids) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean changeStatus(@NotEmpty List<Long> ids, Integer status) { |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * è·åå
æ°æ®è¯¦æ
|
| | | * |
| | | * @param id ä¸»é® |
| | | * @return å
æ°æ®æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public OmdAttributeVO getAttributeDetail(Long id) { |
| | | Func.requireNotNull(id,"主é®ä¸è½ä¸ºç©º"); |
| | | return OmdAttributeWrapper.build().entityVO(baseMapper.selectByPrimaryKey(id)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢æä¿®æ¹ |
| | | * |
| | | * @param dto 页é¢ä¼ è¾å¯¹è±¡ |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @Override |
| | | public boolean submit(OmdAttributeDTO dto) { |
| | | LambdaQueryWrapper<OmdAttribute> wrapper = Wrappers.<OmdAttribute>query().lambda().eq(OmdAttribute::getKey, dto.getKey()); |
| | | Long count = baseMapper.selectCount((Func.isEmpty(dto.getId())) ? wrapper : wrapper.notIn(OmdAttribute::getId, dto.getId())); |
| | | if (count > 0L) { |
| | | throw new ServiceException("屿§åå·²åå¨!"); |
| | | } |
| | | dto.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
| | | OmdAttribute omdAttribute = BeanUtil.copy(dto, OmdAttribute.class); |
| | | CacheUtil.clear(OmdCacheConstant.ATTR_CACHE); |
| | | return saveOrUpdate(omdAttribute); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ |
| | | * |
| | | * @param ids 主é®éå |
| | | * @return æ§è¡ç»æ |
| | | */ |
| | | @Override |
| | | public boolean removeAttrs(String ids) { |
| | | List<Long> idList = Func.toLongList(ids); |
| | | return !deleteLogic(idList) && removeByIds(idList); |
| | | } |
| | | |
| | | /** |
| | | * æ¥çåºç¨èå´ |
| | | * |
| | | * @param id ä¸»é® |
| | | * @return æ¥è¯¢å·²åºç¨çä¸å¡ç±»ååç§° |
| | | */ |
| | | @Override |
| | | public List<String> applyRange(Long id) { |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.wrapper; |
| | | |
| | | import com.vci.ubcs.omd.cache.DictBizCache; |
| | | import com.vci.ubcs.omd.entity.OmdAttribute; |
| | | import com.vci.ubcs.omd.vo.*; |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | | * å
æ°æ®å¯¹è±¡çå
è£
ç±»,è¿åè§å¾å±æéçåæ®µ |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | public class OmdAttributeWrapper extends BaseEntityWrapper<OmdAttribute, OmdAttributeVO> { |
| | | |
| | | public static OmdAttributeWrapper build() { |
| | | return new OmdAttributeWrapper(); |
| | | } |
| | | |
| | | /** |
| | | * do2vo |
| | | * @param entity pojo |
| | | * @return æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public OmdAttributeVO entityVO(OmdAttribute entity) { |
| | | OmdAttributeVO vo = Objects.requireNonNull(BeanUtil.copy(entity, OmdAttributeVO.class)); |
| | | vo.setTypeValue(DictBizCache.getValue(vo.getTypeCode(),vo.getTypeKey())); |
| | | if (StringUtil.isNotBlank(vo.getReferTypeCode())){ |
| | | vo.setReferTypeValue(DictBizCache.getValue(vo.getReferTypeCode(),vo.getReferTypeKey())); |
| | | } |
| | | if (StringUtil.isNotBlank(vo.getDictCode())){ |
| | | vo.setDictValue(DictBizCache.getValue(vo.getDictCode(),vo.getDictKey())); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * æ¹é转vo |
| | | * @param list pojoéå |
| | | * @return æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | public List<OmdAttributeVO> listEntityVO(List<OmdAttribute> list) { |
| | | return list.stream().map(this::entityVO).collect(Collectors.toList()); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.omd.wrapper; |
| | | |
| | | import com.vci.ubcs.omd.entity.OmdFieldRange; |
| | | import com.vci.ubcs.omd.vo.OmdFieldRangeVO; |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Description: åæ®µèå´çå
è£
ç±» |
| | | * |
| | | * @author LiHang |
| | | * @date 2023/4/3 |
| | | */ |
| | | public class OmdFiledRangeWrapper extends BaseEntityWrapper<OmdFieldRange, OmdFieldRangeVO> { |
| | | |
| | | public static OmdFiledRangeWrapper build() { |
| | | return new OmdFiledRangeWrapper(); |
| | | } |
| | | |
| | | /** |
| | | * do2vo |
| | | * @param entity pojo |
| | | * @return æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | @Override |
| | | public OmdFieldRangeVO entityVO(OmdFieldRange entity) { |
| | | OmdFieldRangeVO vo = Objects.requireNonNull(BeanUtil.copy(entity, OmdFieldRangeVO.class)); |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * æ¹é转vo |
| | | * @param list pojoéå |
| | | * @return æ¾ç¤ºå¯¹è±¡ |
| | | */ |
| | | public List<OmdFieldRangeVO> listEntityVO(List<OmdFieldRange> list) { |
| | | return list.stream().map(this::entityVO).collect(Collectors.toList()); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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="com.vci.ubcs.omd.mapper.OmdAttributeMapper"> |
| | | |
| | | <!-- éç¨æ¥è¯¢æ å°ç»æ --> |
| | | <resultMap id="baseResultMap" type="com.vci.ubcs.omd.entity.OmdAttribute"> |
| | | <id column="id" property="id"/> |
| | | <result column="create_user" property="createUser" jdbcType="NUMBER"/> |
| | | <result column="create_dept" property="createDept" jdbcType="NUMBER"/> |
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="update_user" property="updateUser" jdbcType="NUMBER"/> |
| | | <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | <result column="status" property="status" jdbcType="NUMBER"/> |
| | | <result column="is_deleted" property="isDeleted" jdbcType="NUMBER"/> |
| | | <result column="tenant_id" property="tenantId" jdbcType="NUMBER"/> |
| | | <result column="key" property="key" jdbcType="VARCHAR"/> |
| | | <result column="label" property="label" jdbcType="VARCHAR"/> |
| | | <result column="type" property="type" jdbcType="VARCHAR"/> |
| | | <result column="hashtag" property="hashtag" jdbcType="VARCHAR"/> |
| | | <result column="description" property="description" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="extraResultMap" type="com.vci.ubcs.omd.entity.OmdAttribute"> |
| | | <result column="nullable" property="nullable" jdbcType="VARCHAR"/> |
| | | <result column="max_length" property="maxLength" jdbcType="NUMBER"/> |
| | | <result column="precision" property="precision" jdbcType="NUMBER"/> |
| | | <result column="refer_to_id" property="referToId" jdbcType="NUMBER"/> |
| | | <result column="refer_type" property="referType" jdbcType="VARCHAR"/> |
| | | <result column="refer_to_name" property="referToName" jdbcType="VARCHAR"/> |
| | | <result column="using_enum" property="usingEnum" jdbcType="VARCHAR"/> |
| | | <result column="enum_key" property="enumKey" jdbcType="VARCHAR"/> |
| | | <result column="enum_name" property="enumName" jdbcType="VARCHAR"/> |
| | | <result column="default_value" property="defaultValue" jdbcType="VARCHAR"/> |
| | | <result column="calculate_type" property="calculateType" jdbcType="VARCHAR"/> |
| | | <result column="calculate_value" property="calculateValue" jdbcType="VARCHAR"/> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | </mapper> |