diff --git a/bonus-common-biz/pom.xml b/bonus-common-biz/pom.xml index 02219f0d..fd773b73 100644 --- a/bonus-common-biz/pom.xml +++ b/bonus-common-biz/pom.xml @@ -221,6 +221,12 @@ 33.0.0-jre compile + + com.amazonaws + aws-java-sdk-s3 + 1.12.780 + + diff --git a/bonus-common-biz/src/main/java/com/bonus/framework/config/deserializer/DateTimeDeserializer.java b/bonus-common-biz/src/main/java/com/bonus/framework/config/deserializer/DateTimeDeserializer.java new file mode 100644 index 00000000..d7092f64 --- /dev/null +++ b/bonus-common-biz/src/main/java/com/bonus/framework/config/deserializer/DateTimeDeserializer.java @@ -0,0 +1,101 @@ +package com.bonus.framework.config.deserializer; + + +import com.beust.jcommander.internal.Maps; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Iterator; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class DateTimeDeserializer extends JsonDeserializer { + public static final String YYYY_MM_DD_HH_MM_SS = "yyyy$1MM$2dd$3HH$4mm$5ss$6"; + public static final String YYYY_MM_DD_HH_MM = "yyyy$1MM$2dd$3HH$4mm$5"; + public static final String YYYY_MM_DD_HH = "yyyy$1MM$2dd$3HH$4"; + public static final String YYYY_MM_DD = "yyyy$1MM$2dd$3"; + public static final String YYYY_MM = "yyyy$1MM$2"; + public static final String HH_MM_SS = "HH$1mm$2ss$3"; + public static final String HH_MM = "HH$1mm$2"; + private static final Map patternMap = Maps.newLinkedHashMap(); + + public static void main(String[] args) { + System.out.println(getPattern("2014/10/10 11:11:11")); + System.out.println(getPattern("2014-10-10")); + System.out.println(getPattern("2014-10-10 11:11")); + System.out.println(getPattern("2014-10")); + System.out.println(getPattern("2014年10月10日 11点11分11秒")); + System.out.println(getPattern("11:11:11")); + System.out.println(getPattern("11点11分")); + } + + public static String getPattern(String dateString) { + Iterator var1 = patternMap.entrySet().iterator(); + + while(var1.hasNext()) { + Map.Entry entry = (Map.Entry)var1.next(); + Matcher matcher = ((Pattern)entry.getValue()).matcher(dateString); + if (matcher.find()) { + if ("yyyy$1MM$2dd$3HH$4mm$5ss$6".equals(entry.getKey())) { + return "yyyy$1MM$2dd$3HH$4mm$5ss$6".replace("$1", matcher.group(1)).replace("$2", matcher.group(2)).replace("$3", matcher.group(3)).replace("$4", matcher.group(4)).replace("$5", matcher.group(5)).replace("$6", matcher.group(6)); + } + + if ("yyyy$1MM$2dd$3HH$4mm$5".equals(entry.getKey())) { + return "yyyy$1MM$2dd$3HH$4mm$5".replace("$1", matcher.group(1)).replace("$2", matcher.group(2)).replace("$3", matcher.group(3)).replace("$4", matcher.group(4)).replace("$5", matcher.group(5)); + } + + if ("yyyy$1MM$2dd$3HH$4".equals(entry.getKey())) { + return "yyyy$1MM$2dd$3HH$4".replace("$1", matcher.group(1)).replace("$2", matcher.group(2)).replace("$3", matcher.group(3)).replace("$4", matcher.group(4)); + } + + if ("yyyy$1MM$2dd$3".equals(entry.getKey())) { + return "yyyy$1MM$2dd$3".replace("$1", matcher.group(1)).replace("$2", matcher.group(2)).replace("$3", matcher.group(3)); + } + + if ("yyyy$1MM$2".equals(entry.getKey())) { + return "yyyy$1MM$2".replace("$1", matcher.group(1)).replace("$2", matcher.group(2)); + } + + if ("HH$1mm$2ss$3".equals(entry.getKey())) { + return "HH$1mm$2ss$3".replace("$1", matcher.group(1)).replace("$2", matcher.group(2)).replace("$3", matcher.group(3)); + } + + if ("HH$1mm$2".equals(entry.getKey())) { + return "HH$1mm$2".replace("$1", matcher.group(1)).replace("$2", matcher.group(2)); + } + } + } + + return null; + } + + @Override + public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + if (StringUtils.isBlank(p.getText())) { + return null; + } else { + String pattern = getPattern(p.getText()); + if (pattern == null) { + throw new RuntimeException("不支持的日期格式:" + p.getText()); + } else { + return LocalDateTime.parse(p.getText(), DateTimeFormatter.ofPattern(pattern)); + } + } + } + + static { + patternMap.put("yyyy$1MM$2dd$3HH$4mm$5ss$6", Pattern.compile("^\\d{4}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D?)$")); + patternMap.put("yyyy$1MM$2dd$3HH$4mm$5", Pattern.compile("^\\d{4}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D?)$")); + patternMap.put("yyyy$1MM$2dd$3HH$4", Pattern.compile("^\\d{4}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D?)$")); + patternMap.put("yyyy$1MM$2dd$3", Pattern.compile("^\\d{4}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D?)$")); + patternMap.put("yyyy$1MM$2", Pattern.compile("^\\d{4}(\\D+)\\d{1,2}(\\D?)$")); + patternMap.put("HH$1mm$2ss$3", Pattern.compile("^\\d{1,2}(\\D+)\\d{1,2}(\\D+)\\d{1,2}(\\D?)$")); + patternMap.put("HH$1mm$2", Pattern.compile("^\\d{1,2}(\\D+)\\d{1,2}(\\D?)$")); + } +} diff --git a/bonus-common-biz/src/main/java/com/bonus/framework/config/serializer/DateTimeSerializer.java b/bonus-common-biz/src/main/java/com/bonus/framework/config/serializer/DateTimeSerializer.java new file mode 100644 index 00000000..b0ce4de4 --- /dev/null +++ b/bonus-common-biz/src/main/java/com/bonus/framework/config/serializer/DateTimeSerializer.java @@ -0,0 +1,64 @@ +package com.bonus.framework.config.serializer; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class DateTimeSerializer extends JsonSerializer { + private final String pattern; + + public DateTimeSerializer(String pattern) { + this.pattern = pattern; + } + + @Override + public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + gen.writeString(value.format(DateTimeFormatter.ofPattern(this.pattern))); + } + + public static class HH_MM extends DateTimeSerializer { + public HH_MM() { + super("HH:mm"); + } + } + + public static class HH_MM_SS extends DateTimeSerializer { + public HH_MM_SS() { + super("HH:mm:ss"); + } + } + + public static class YYYY_MM extends DateTimeSerializer { + public YYYY_MM() { + super("yyyy-MM"); + } + } + + public static class YYYY_MM_DD extends DateTimeSerializer { + public YYYY_MM_DD() { + super("yyyy-MM-dd"); + } + } + + public static class YYYY_MM_DD_HH extends DateTimeSerializer { + public YYYY_MM_DD_HH() { + super("yyyy-MM-dd HH"); + } + } + + public static class YYYY_MM_DD_HH_MM extends DateTimeSerializer { + public YYYY_MM_DD_HH_MM() { + super("yyyy-MM-dd HH:mm"); + } + } + + public static class YYYY_MM_DD_HH_MM_SS extends DateTimeSerializer { + public YYYY_MM_DD_HH_MM_SS() { + super("yyyy-MM-dd HH:mm:ss"); + } + } +} diff --git a/bonus-cust-auth/pom.xml b/bonus-cust-auth/pom.xml index 3e15998a..2950f958 100644 --- a/bonus-cust-auth/pom.xml +++ b/bonus-cust-auth/pom.xml @@ -135,12 +135,16 @@ alipay-sdk-java 4.34.0.ALL - - - - - - + + com.baomidou + mybatis-plus-extension + 3.5.6 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.10.1 + diff --git a/bonus-modules/bonus-smart-canteen/pom.xml b/bonus-modules/bonus-smart-canteen/pom.xml index 9e973958..08e50d4e 100644 --- a/bonus-modules/bonus-smart-canteen/pom.xml +++ b/bonus-modules/bonus-smart-canteen/pom.xml @@ -16,7 +16,11 @@ - + + com.baomidou + mybatis-plus-boot-starter + 3.5.10.1 + com.github.ulisesbocchio diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/controller/AccMetadataController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/controller/AccMetadataController.java new file mode 100644 index 00000000..309c2140 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/controller/AccMetadataController.java @@ -0,0 +1,32 @@ +package com.bonus.core.account.v3.metadata.controller; + +import com.bonus.core.account.v3.metadata.model.AccMetadataModel; +import com.bonus.core.account.v3.metadata.service.AccMetadataService; +import com.sun.org.slf4j.internal.Logger; +import com.sun.org.slf4j.internal.LoggerFactory; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController +@RequestMapping({"/api/v2/acc/metadata"}) +@Api( + tags = {"账户配置控制器"} +) +public class AccMetadataController { + private static final Logger log = LoggerFactory.getLogger(AccMetadataController.class); + @Resource + @Lazy + private AccMetadataService accMetadataService; + + @ApiOperation("查询配置") + @PostMapping({"/query"}) + public AccMetadataModel queryMetadata() { + return this.accMetadataService.queryMetadata(); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/enums/AccWalletIdEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/enums/AccWalletIdEnum.java new file mode 100644 index 00000000..d6c6332d --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/enums/AccWalletIdEnum.java @@ -0,0 +1,117 @@ +package com.bonus.core.account.v3.metadata.enums; + +import cn.hutool.core.collection.ListUtil; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +public enum AccWalletIdEnum { + WALLET(1, "个人钱包"), + SUBSIDY(2, "补贴钱包"), + LUCK_MONEY(4, "红包"); + + private final Integer key; + private final String desc; + + private AccWalletIdEnum(Integer key, String desc) { + this.key = key; + this.desc = desc; + } + + public static String getDesc(Integer key) { + AccWalletIdEnum[] var1 = values(); + int var2 = var1.length; + + for(int var3 = 0; var3 < var2; ++var3) { + AccWalletIdEnum temp = var1[var3]; + if (temp.getKey().equals(key)) { + return temp.getDesc(); + } + } + + return ""; + } + + public static AccWalletIdEnum getEnum(Integer key) { + AccWalletIdEnum[] var1 = values(); + int var2 = var1.length; + + for(int var3 = 0; var3 < var2; ++var3) { + AccWalletIdEnum temp = var1[var3]; + if (temp.getKey().equals(key)) { + return temp; + } + } + + return null; + } + + public static Map getEnumMap() { + return (Map)Arrays.stream(values()).collect(Collectors.toMap(AccWalletIdEnum::getKey, Function.identity())); + } + + public static List checkAccCancelWallet() { + return Arrays.asList(WALLET.getKey(), SUBSIDY.getKey()); + } + + public static String getAllWalletId() { + List list = new ArrayList(); + AccWalletIdEnum[] var1 = values(); + int var2 = var1.length; + + for(int var3 = 0; var3 < var2; ++var3) { + AccWalletIdEnum temp = var1[var3]; + list.add(temp.getKey()); + } + + return StringUtils.join(list, ","); + } + + public static List getAllWalletIdList() { + List list = new ArrayList(); + AccWalletIdEnum[] var1 = values(); + int var2 = var1.length; + + for(int var3 = 0; var3 < var2; ++var3) { + AccWalletIdEnum temp = var1[var3]; + list.add(temp.getKey()); + } + + return list; + } + + public static boolean ifSupportOpenRecharge(Integer walletId) { + return ListUtil.toList(new Integer[]{WALLET.getKey(), SUBSIDY.getKey()}).contains(walletId); + } + + public static boolean iFCorrectWalletId(Integer key) { + List list = new ArrayList(); + AccWalletIdEnum[] var2 = values(); + int var3 = var2.length; + + for(int var4 = 0; var4 < var3; ++var4) { + AccWalletIdEnum temp = var2[var4]; + list.add(temp.getKey()); + } + + return list.contains(key); + } + + public Integer getKey() { + return this.key; + } + + public String getDesc() { + return this.desc; + } + + // $FF: synthetic method + private static AccWalletIdEnum[] $values() { + return new AccWalletIdEnum[]{WALLET, SUBSIDY, LUCK_MONEY}; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/model/AccMetadataModel.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/model/AccMetadataModel.java new file mode 100644 index 00000000..4343c8a1 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/model/AccMetadataModel.java @@ -0,0 +1,101 @@ +package com.bonus.core.account.v3.metadata.model; + +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.util.StrUtil; +import com.bonus.core.account.v3.metadata.enums.AccWalletIdEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel("账户配置模型") +public class AccMetadataModel { + @ApiModelProperty("账户支付顺序(1,2,4)") + private String accPayOrder; + @ApiModelProperty("是否启用第三方充值 默认否") + private String ifUseThirdRecharge; + @ApiModelProperty("是否查询第三方余额 默认否") + private String ifUseThirdAccBal; + @ApiModelProperty("账户个人钱包-最低余额限制 默认0") + private String minBalanceLimit; + @ApiModelProperty("账户补贴钱包-最低余额限制 默认0") + private String minSubBalanceLimit; + @ApiModelProperty("账户红包钱包-最低余额限制 默认0") + private String minRedBalanceLimit; + @ApiModelProperty("移动端取款是否审批 默认否 1是 2否") + private String ifApproveMobileWithdraw; + @ApiModelProperty("移动端是否支持取款 默认否") + private String ifSupportMobileWithdraw; + @ApiModelProperty("离线支付默认使用钱包(个人钱包)") + private String offlineWalletPay; + + public String getAccPayOrder() { + return StrUtil.isBlank(this.accPayOrder) ? AccWalletIdEnum.getAllWalletId() : this.accPayOrder; + } + + public String getOfflineWalletPay() { + return CharSequenceUtil.isBlank(this.offlineWalletPay) ? String.valueOf(AccWalletIdEnum.WALLET.getKey()) : this.offlineWalletPay; + } + + public String getIfUseThirdRecharge() { + return this.ifUseThirdRecharge; + } + + public String getIfUseThirdAccBal() { + return this.ifUseThirdAccBal; + } + + public String getMinBalanceLimit() { + return this.minBalanceLimit; + } + + public String getMinSubBalanceLimit() { + return this.minSubBalanceLimit; + } + + public String getMinRedBalanceLimit() { + return this.minRedBalanceLimit; + } + + public String getIfApproveMobileWithdraw() { + return this.ifApproveMobileWithdraw; + } + + public String getIfSupportMobileWithdraw() { + return this.ifSupportMobileWithdraw; + } + + public void setAccPayOrder(final String accPayOrder) { + this.accPayOrder = accPayOrder; + } + + public void setIfUseThirdRecharge(final String ifUseThirdRecharge) { + this.ifUseThirdRecharge = ifUseThirdRecharge; + } + + public void setIfUseThirdAccBal(final String ifUseThirdAccBal) { + this.ifUseThirdAccBal = ifUseThirdAccBal; + } + + public void setMinBalanceLimit(final String minBalanceLimit) { + this.minBalanceLimit = minBalanceLimit; + } + + public void setMinSubBalanceLimit(final String minSubBalanceLimit) { + this.minSubBalanceLimit = minSubBalanceLimit; + } + + public void setMinRedBalanceLimit(final String minRedBalanceLimit) { + this.minRedBalanceLimit = minRedBalanceLimit; + } + + public void setIfApproveMobileWithdraw(final String ifApproveMobileWithdraw) { + this.ifApproveMobileWithdraw = ifApproveMobileWithdraw; + } + + public void setIfSupportMobileWithdraw(final String ifSupportMobileWithdraw) { + this.ifSupportMobileWithdraw = ifSupportMobileWithdraw; + } + + public void setOfflineWalletPay(final String offlineWalletPay) { + this.offlineWalletPay = offlineWalletPay; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/service/AccMetadataService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/service/AccMetadataService.java new file mode 100644 index 00000000..31f587a9 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/account/v3/metadata/service/AccMetadataService.java @@ -0,0 +1,21 @@ +package com.bonus.core.account.v3.metadata.service; + +import com.bonus.core.account.v3.metadata.model.AccMetadataModel; +import com.bonus.core.allocation.api.AllocMetadataApi; +import com.bonus.core.common.enums.MetadataModelTypeEnum; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +public class AccMetadataService { + @Resource + @Lazy + private AllocMetadataApi allocMetadataApi; + + public AccMetadataModel queryMetadata() { + return (AccMetadataModel)this.allocMetadataApi.queryMetadataModel(MetadataModelTypeEnum.ACC, new AccMetadataModel()); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/mapper/AllocPayMetadataMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/mapper/AllocPayMetadataMapper.java new file mode 100644 index 00000000..96b7eba0 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/mapper/AllocPayMetadataMapper.java @@ -0,0 +1,9 @@ +package com.bonus.core.allocation.alloc.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bonus.core.allocation.alloc.model.AllocMetadata; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface AllocPayMetadataMapper extends BaseMapper { +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/mapper/AllocPayMetadataMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/mapper/AllocPayMetadataMapper.xml new file mode 100644 index 00000000..034d3ec2 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/mapper/AllocPayMetadataMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/model/AllocMetadata.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/model/AllocMetadata.java new file mode 100644 index 00000000..71a990dd --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/model/AllocMetadata.java @@ -0,0 +1,51 @@ +package com.bonus.core.allocation.alloc.model; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.bonus.core.common.enums.MetadataModelTypeEnum; +import com.bonus.framework.config.deserializer.DateTimeDeserializer; +import com.bonus.framework.config.serializer.DateTimeSerializer; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.ArrayList; + +@TableName("alloc_metadata") +@ApiModel("元数据配置表") +@Data +public class AllocMetadata { + @TableId + @ApiModelProperty("元数据id") + private Long metadataId; + @ApiModelProperty("区域id") + private Long areaId; + @ApiModelProperty("食堂id") + private Long canteenId; + @ApiModelProperty("档口id") + private Long stallId; + @ApiModelProperty("是否有效 1是2否") + private Integer ifActive; + @ApiModelProperty("模型类型") + private String modelType; + @ApiModelProperty("模型key") + private String modelKey; + @ApiModelProperty("模型值") + private String modelValue; + @ApiModelProperty("模型key备注") + private String modelKeyRemark; + @ApiModelProperty("创建人") + private String crby; + @ApiModelProperty("创建时间") + private LocalDateTime crtime; + @ApiModelProperty("更新人") + private String upby; + @ApiModelProperty("更新时间") + private LocalDateTime uptime; + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/model/MetadataModel.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/model/MetadataModel.java new file mode 100644 index 00000000..5929dcbb --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/model/MetadataModel.java @@ -0,0 +1,38 @@ +package com.bonus.core.allocation.alloc.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel("元数据model") +public class MetadataModel { + @ApiModelProperty("模型key") + private String modelKey; + @ApiModelProperty("模型值") + private String modelValue; + @ApiModelProperty("模型key备注") + private String modelKeyRemark; + + public String getModelKey() { + return this.modelKey; + } + + public String getModelValue() { + return this.modelValue; + } + + public String getModelKeyRemark() { + return this.modelKeyRemark; + } + + public void setModelKey(final String modelKey) { + this.modelKey = modelKey; + } + + public void setModelValue(final String modelValue) { + this.modelValue = modelValue; + } + + public void setModelKeyRemark(final String modelKeyRemark) { + this.modelKeyRemark = modelKeyRemark; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/service/AllocMetadataService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/service/AllocMetadataService.java new file mode 100644 index 00000000..88eb0fcf --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/service/AllocMetadataService.java @@ -0,0 +1,12 @@ +package com.bonus.core.allocation.alloc.service; + + +import com.bonus.core.allocation.alloc.model.AllocMetadata; +import com.bonus.core.common.enums.MetadataModelTypeEnum; + +import java.util.List; + +public interface AllocMetadataService { + + List listPayMetadataByType(MetadataModelTypeEnum modelType, Long canteenId, Long stallId); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/service/impl/AllocMetadataServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/service/impl/AllocMetadataServiceImpl.java new file mode 100644 index 00000000..5061c83b --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/alloc/service/impl/AllocMetadataServiceImpl.java @@ -0,0 +1,75 @@ +package com.bonus.core.allocation.alloc.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bonus.core.allocation.alloc.mapper.AllocPayMetadataMapper; +import com.bonus.core.allocation.alloc.model.AllocMetadata; +import com.bonus.core.allocation.alloc.service.AllocMetadataService; +import com.bonus.core.allocation.api.AllocStallApi; +import com.bonus.core.allocation.canteen.model.AllocStall; +import com.bonus.core.common.enums.MetadataModelTypeEnum; +import com.bonus.core.common.redis.RedisUtil; +import com.bonus.core.common.utils.TenantContextHolder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +public class AllocMetadataServiceImpl extends ServiceImpl implements AllocMetadataService { + private static final Logger log = LoggerFactory.getLogger(AllocMetadataServiceImpl.class); + private static final String CACHE_PREFIX = "yst:"; + private static final String CACHE_KEY = "pay-mata-data"; + private static final long CACHE_SECONDS = 3600L; + @Resource + private AllocStallApi allocStallApi; + + public List listPayMetadataCacheable(MetadataModelTypeEnum modelTypeEnum) { + return this.listPayMetadataCacheable(modelTypeEnum.getKey()); + } + private List listPayMetadataCacheable(String modelType) { + String var10000 = this.getCacheKeyPrefix(); + String cacheKey = var10000 + modelType; + Object cacheObj = RedisUtil.getObj(cacheKey); + if (cacheObj instanceof List) { + return (List)cacheObj; + } else { + List selectList = this.baseMapper.selectList(Wrappers.lambdaQuery(AllocMetadata.class).eq(AllocMetadata::getModelType, modelType)); + RedisUtil.setObj(cacheKey, selectList, 3600L); + return selectList; + } + } + public String getCacheKeyPrefix() { + return "yst:" + TenantContextHolder.getTenantId() + ":pay-mata-data:"; + } + @Override + public List listPayMetadataByType(MetadataModelTypeEnum modelType, Long canteenId, Long stallId) { + if (ObjectUtil.isNotNull(stallId) && ObjectUtil.isNull(canteenId)) { + AllocStall stall = this.allocStallApi.getAllocStall(stallId); + if (!ObjectUtil.isNull(stall) && !ObjectUtil.isNull(stall.getCanteenId())) { + canteenId = stall.getCanteenId(); + } else { + log.warn("【配置项】未查到档口关联食堂:{},{},{}", new Object[]{modelType, canteenId, stallId}); + } + } + + Long finalCanteenId = canteenId; + return (List)this.listPayMetadataCacheable(modelType).stream().filter((s) -> { + return ObjectUtil.equal(s.getCanteenId(), finalCanteenId) && ObjectUtil.equal(s.getStallId(), stallId); + }).collect(Collectors.toList()); + } + + + public String getPayMetadataValue(MetadataModelTypeEnum modelTypeEnum, String modelKey, Long canteenId, Long stallId) { + return (String)this.listPayMetadataByType(modelTypeEnum, canteenId, stallId).stream().filter((s) -> { + return StrUtil.equals(s.getModelKey(), modelKey); + }).map(AllocMetadata::getModelValue).filter(Objects::nonNull).findFirst().orElse(""); + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocMetadataApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocMetadataApi.java new file mode 100644 index 00000000..322eb5b7 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocMetadataApi.java @@ -0,0 +1,30 @@ +package com.bonus.core.allocation.api; + +import com.bonus.core.common.enums.MetadataModelTypeEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * @ClassName: AllocMetadataApi + * @author: tqzhang + * @Date: 2025/1/24 23:51 + * @version: 1.0 + * @description: + */ +@Component +public class AllocMetadataApi { + private static final Logger log = LoggerFactory.getLogger(AllocMetadataApi.class); + @Resource + @Lazy + private GlobalMetadataApi globalMetadataApi; + + public T queryMetadataModel(MetadataModelTypeEnum modelTypeEnum, T t) { + return this.globalMetadataApi.getModel(modelTypeEnum, t, (Long)null, (Long)null); + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocStallApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocStallApi.java new file mode 100644 index 00000000..e9cd5d0e --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocStallApi.java @@ -0,0 +1,21 @@ +package com.bonus.core.allocation.api; + +import com.bonus.core.allocation.canteen.model.AllocStall; +import com.bonus.core.allocation.canteen.service.AllocStallService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +@Component +public class AllocStallApi { + private static final Logger log = LoggerFactory.getLogger(AllocStallApi.class); + @Resource + @Lazy + private AllocStallService allocStallService; + + public AllocStall getAllocStall(Long stallId) { + return this.allocStallService.getAllocStallCache(stallId); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/GlobalMetadataApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/GlobalMetadataApi.java new file mode 100644 index 00000000..d603ab09 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/GlobalMetadataApi.java @@ -0,0 +1,33 @@ +package com.bonus.core.allocation.api; + +import cn.hutool.core.util.ObjectUtil; +import com.bonus.core.allocation.alloc.model.AllocMetadata; +import com.bonus.core.allocation.alloc.service.AllocMetadataService; +import com.bonus.core.allocation.util.MetadataUtil; +import com.bonus.core.common.enums.MetadataModelTypeEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; + +@Component +public class GlobalMetadataApi { + private static final Logger log = LoggerFactory.getLogger(GlobalMetadataApi.class); + @Resource + @Lazy + private AllocMetadataService allocMetadataService; + + public T getModel(MetadataModelTypeEnum modelTypeEnum, T t, Long canteenId, Long stallId) { + List metadataList = this.getList(modelTypeEnum, canteenId, stallId); + return MetadataUtil.transferToPayModel(metadataList, t); + } + + public List getList(MetadataModelTypeEnum modelTypeEnum, Long canteenId, Long stallId) { + Long finalCanteenId = ObjectUtil.equal(canteenId, -1) ? null : canteenId; + Long finalStallId = ObjectUtil.equal(stallId, -1) ? null : stallId; + return this.allocMetadataService.listPayMetadataByType(modelTypeEnum, finalCanteenId, finalStallId); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/mapper/AllocStallMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/mapper/AllocStallMapper.java new file mode 100644 index 00000000..17913787 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/mapper/AllocStallMapper.java @@ -0,0 +1,9 @@ +package com.bonus.core.allocation.canteen.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bonus.core.allocation.canteen.model.AllocStall; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface AllocStallMapper extends BaseMapper { +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/mapper/AllocStallMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/mapper/AllocStallMapper.xml new file mode 100644 index 00000000..a052cafb --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/mapper/AllocStallMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/model/AllocStall.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/model/AllocStall.java new file mode 100644 index 00000000..d7b6b9cc --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/model/AllocStall.java @@ -0,0 +1,370 @@ +package com.bonus.core.allocation.canteen.model; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.bonus.core.common.utils.SysUtil; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDateTime; +import java.time.LocalTime; + +@TableName("alloc_stall") +@ApiModel("档口信息表") +public class AllocStall { + @TableId + @ApiModelProperty("主键id") + private Long id; + @ApiModelProperty("档口id") + private Long stallId; + @ApiModelProperty("档口编号") + private String stallNum; + @ApiModelProperty("档口名称") + private String stallName; + @ApiModelProperty("食堂id") + private Long canteenId; + @ApiModelProperty("区域id") + private Long areaId; + @ApiModelProperty("档口业务类型") + private Integer stallType; + @ApiModelProperty("第三方档口id") + private String thirdStallId; + @ApiModelProperty("人员id") + private Long custId; + @ApiModelProperty("联系电话") + private String contactTel; + @ApiModelProperty("主营项目") + private String mainProject; + @ApiModelProperty("档口营业状态") + private Integer businessState; + @ApiModelProperty("营业时间") + @JsonDeserialize( + using = LocalTimeDeserializer.class + ) + @JsonSerialize( + using = LocalTimeSerializer.class + ) + private LocalTime startBusinessTime; + @JsonDeserialize( + using = LocalTimeDeserializer.class + ) + @JsonSerialize( + using = LocalTimeSerializer.class + ) + private LocalTime endBusinessTime; + @ApiModelProperty("是否启用叫号") + private Integer ifUseCallNum; + @ApiModelProperty("线上流水号前缀") + private String onLineMealCodePrefix; + @ApiModelProperty("线下流水号前缀") + private String offLineMealCodePrefix; + @ApiModelProperty("是否启用配送配置") + private Integer ifEnableDelivery; + @ApiModelProperty("配送方式(多个数据之间 使用,分隔)") + private String deliveries; + @ApiModelProperty("是否启用点餐配置") + private Integer ifEnableOrder; + @ApiModelProperty("档口图片链接") + private String imgUrl; + @ApiModelProperty("是否支持报餐") + private Integer ifBook; + @ApiModelProperty("是否支持预定餐") + private Integer ifReserve; + @ApiModelProperty("是否启用收款码") + private Integer ifEnablePayCode; + @ApiModelProperty("档口收款码链接") + private String payCodeUrl; + @ApiModelProperty("是否删除") + private Integer ifDel; + @ApiModelProperty("创建人") + private String crby; + @ApiModelProperty("创建时间") + @JsonDeserialize( + using = LocalDateTimeDeserializer.class + ) + @JsonSerialize( + using = LocalDateTimeSerializer.class + ) + private LocalDateTime crtime; + @ApiModelProperty("更新人") + private String upby; + @ApiModelProperty("更新时间") + @JsonDeserialize( + using = LocalDateTimeDeserializer.class + ) + @JsonSerialize( + using = LocalDateTimeSerializer.class + ) + private LocalDateTime uptime; + + public AllocStall(Long stallId) { + this.stallId = stallId; + } + + public AllocStall(Long stallId, Long canteenId, String stallName, Integer stallType, String thirdStallId) { + this.stallId = stallId; + this.canteenId = canteenId; + this.stallName = stallName; + this.stallType = stallType; + this.thirdStallId = thirdStallId; + } + + public String getImgUrl() { + return SysUtil.getCutPath(this.imgUrl); + } + + public String getPayCodeUrl() { + return SysUtil.getCutPath(this.payCodeUrl); + } + + public Long getId() { + return this.id; + } + + public Long getStallId() { + return this.stallId; + } + + public String getStallNum() { + return this.stallNum; + } + + public String getStallName() { + return this.stallName; + } + + public Long getCanteenId() { + return this.canteenId; + } + + public Long getAreaId() { + return this.areaId; + } + + public Integer getStallType() { + return this.stallType; + } + + public String getThirdStallId() { + return this.thirdStallId; + } + + public Long getCustId() { + return this.custId; + } + + public String getContactTel() { + return this.contactTel; + } + + public String getMainProject() { + return this.mainProject; + } + + public Integer getBusinessState() { + return this.businessState; + } + + public LocalTime getStartBusinessTime() { + return this.startBusinessTime; + } + + public LocalTime getEndBusinessTime() { + return this.endBusinessTime; + } + + public Integer getIfUseCallNum() { + return this.ifUseCallNum; + } + + public String getOnLineMealCodePrefix() { + return this.onLineMealCodePrefix; + } + + public String getOffLineMealCodePrefix() { + return this.offLineMealCodePrefix; + } + + public Integer getIfEnableDelivery() { + return this.ifEnableDelivery; + } + + public String getDeliveries() { + return this.deliveries; + } + + public Integer getIfEnableOrder() { + return this.ifEnableOrder; + } + + public Integer getIfBook() { + return this.ifBook; + } + + public Integer getIfReserve() { + return this.ifReserve; + } + + public Integer getIfEnablePayCode() { + return this.ifEnablePayCode; + } + + public Integer getIfDel() { + return this.ifDel; + } + + public String getCrby() { + return this.crby; + } + + public LocalDateTime getCrtime() { + return this.crtime; + } + + public String getUpby() { + return this.upby; + } + + public LocalDateTime getUptime() { + return this.uptime; + } + + public void setId(final Long id) { + this.id = id; + } + + public void setStallId(final Long stallId) { + this.stallId = stallId; + } + + public void setStallNum(final String stallNum) { + this.stallNum = stallNum; + } + + public void setStallName(final String stallName) { + this.stallName = stallName; + } + + public void setCanteenId(final Long canteenId) { + this.canteenId = canteenId; + } + + public void setAreaId(final Long areaId) { + this.areaId = areaId; + } + + public void setStallType(final Integer stallType) { + this.stallType = stallType; + } + + public void setThirdStallId(final String thirdStallId) { + this.thirdStallId = thirdStallId; + } + + public void setCustId(final Long custId) { + this.custId = custId; + } + + public void setContactTel(final String contactTel) { + this.contactTel = contactTel; + } + + public void setMainProject(final String mainProject) { + this.mainProject = mainProject; + } + + public void setBusinessState(final Integer businessState) { + this.businessState = businessState; + } + + @JsonDeserialize( + using = LocalTimeDeserializer.class + ) + public void setStartBusinessTime(final LocalTime startBusinessTime) { + this.startBusinessTime = startBusinessTime; + } + + @JsonDeserialize( + using = LocalTimeDeserializer.class + ) + public void setEndBusinessTime(final LocalTime endBusinessTime) { + this.endBusinessTime = endBusinessTime; + } + + public void setIfUseCallNum(final Integer ifUseCallNum) { + this.ifUseCallNum = ifUseCallNum; + } + + public void setOnLineMealCodePrefix(final String onLineMealCodePrefix) { + this.onLineMealCodePrefix = onLineMealCodePrefix; + } + + public void setOffLineMealCodePrefix(final String offLineMealCodePrefix) { + this.offLineMealCodePrefix = offLineMealCodePrefix; + } + + public void setIfEnableDelivery(final Integer ifEnableDelivery) { + this.ifEnableDelivery = ifEnableDelivery; + } + + public void setDeliveries(final String deliveries) { + this.deliveries = deliveries; + } + + public void setIfEnableOrder(final Integer ifEnableOrder) { + this.ifEnableOrder = ifEnableOrder; + } + + public void setImgUrl(final String imgUrl) { + this.imgUrl = imgUrl; + } + + public void setIfBook(final Integer ifBook) { + this.ifBook = ifBook; + } + + public void setIfReserve(final Integer ifReserve) { + this.ifReserve = ifReserve; + } + + public void setIfEnablePayCode(final Integer ifEnablePayCode) { + this.ifEnablePayCode = ifEnablePayCode; + } + + public void setPayCodeUrl(final String payCodeUrl) { + this.payCodeUrl = payCodeUrl; + } + + public void setIfDel(final Integer ifDel) { + this.ifDel = ifDel; + } + + public void setCrby(final String crby) { + this.crby = crby; + } + + @JsonDeserialize( + using = LocalDateTimeDeserializer.class + ) + public void setCrtime(final LocalDateTime crtime) { + this.crtime = crtime; + } + + public void setUpby(final String upby) { + this.upby = upby; + } + + @JsonDeserialize( + using = LocalDateTimeDeserializer.class + ) + public void setUptime(final LocalDateTime uptime) { + this.uptime = uptime; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocStallService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocStallService.java new file mode 100644 index 00000000..41b051d5 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocStallService.java @@ -0,0 +1,10 @@ +package com.bonus.core.allocation.canteen.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bonus.core.allocation.canteen.model.AllocStall; + +public interface AllocStallService extends IService { + + AllocStall getAllocStallCache(Long stallId); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocStallServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocStallServiceImpl.java new file mode 100644 index 00000000..a3c38151 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocStallServiceImpl.java @@ -0,0 +1,48 @@ +package com.bonus.core.allocation.canteen.service.impl; + +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.IService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bonus.core.allocation.canteen.mapper.AllocStallMapper; +import com.bonus.core.allocation.canteen.model.AllocStall; +import com.bonus.core.allocation.canteen.service.AllocStallService; +import com.bonus.core.common.redis.RedisUtil; +import com.bonus.core.common.utils.TenantContextHolder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +@Service +public class AllocStallServiceImpl extends ServiceImpl implements AllocStallService{ + private static final Logger log = LoggerFactory.getLogger(AllocStallServiceImpl.class); + private static final String CACHE_PREFIX = "yst:"; + private static final String CACHE_KEY = "alloc-stall"; + private static final long CACHE_SECONDS = 3600L; + + @Override + public AllocStall getAllocStallCache(Long stallId) { + if (ObjectUtil.isNull(stallId)) { + return null; + } else { + String cacheKey = this.getCacheKey(stallId); + String allocStallStr = RedisUtil.getString(cacheKey); + if (CharSequenceUtil.isNotBlank(allocStallStr)) { + return (AllocStall)JSONUtil.toBean(allocStallStr, AllocStall.class); + } else { + AllocStall allocStall = this.getOne(new LambdaQueryWrapper().eq(AllocStall::getStallId, stallId)); + allocStallStr = JSONUtil.toJsonStr(allocStall); + RedisUtil.setString(cacheKey, allocStallStr, 3600L); + return allocStall; + } + } + } + + private String getCacheKey(Long stallId) { + Long var10000 = TenantContextHolder.getTenantId(); + return "yst:" + var10000 + ":alloc-stall:" + stallId; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/util/MetadataUtil.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/util/MetadataUtil.java new file mode 100644 index 00000000..9245263d --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/util/MetadataUtil.java @@ -0,0 +1,103 @@ +package com.bonus.core.allocation.util; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.json.JSONUtil; +import com.bonus.core.allocation.alloc.model.AllocMetadata; +import com.bonus.core.allocation.alloc.model.MetadataModel; +import com.sun.org.slf4j.internal.Logger; +import com.sun.org.slf4j.internal.LoggerFactory; +import io.swagger.annotations.ApiModelProperty; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.stream.Collectors; + +public class MetadataUtil { + private static final Logger log = LoggerFactory.getLogger(MetadataUtil.class); + private static final String URL = "url"; + private static final String PATH = "path"; + private static final String CERT = "cert"; + + private MetadataUtil() { + } + + public static T transferToPayModel(List payMetadataList, T t) { + T t1 = (T) JSONUtil.toBean(JSONUtil.toJsonStr(t), t.getClass()); + if (CollUtil.isEmpty(payMetadataList)) { + return t1; + } else { + Map metadataMap = (Map)payMetadataList.stream().collect(Collectors.toMap((s) -> { + return CharSequenceUtil.nullToEmpty(s.getModelKey()); + }, (s) -> { + return CharSequenceUtil.nullToEmpty(s.getModelValue()); + })); + BeanUtil.fillBeanWithMapIgnoreCase(metadataMap, t1, true); + return t1; + } + } + + public static Map getStringMetadataMap(T t) { + Map methodMap = new HashMap(); + Method[] methods = t.getClass().getMethods(); + Method[] var3 = methods; + int var4 = methods.length; + + for(int var5 = 0; var5 < var4; ++var5) { + Method method = var3[var5]; + String methodName = method.getName(); + if (methodName.startsWith("get") && !methodName.contains("Class") && !methodName.contains("AreaId")) { + String modelKey = CharSequenceUtil.lowerFirst(methodName.substring(3)); + String modelValue = null; + + try { + modelValue = String.valueOf(method.invoke(t, (Object[])null)); + } catch (InvocationTargetException | IllegalAccessException var13) { + System.out.println(modelKey + ",数据转换时,未获取到对应方法"); + } + + if (CharSequenceUtil.isNotBlank(modelValue) && !modelValue.contains("null")) { + methodMap.put(modelKey, modelValue); + } else { + methodMap.put(modelKey, ""); + } + } + } + + Map fieldMap = new HashMap(); + Field[] declaredFields = t.getClass().getDeclaredFields(); + Field[] declaredSuperFields = t.getClass().getSuperclass().getDeclaredFields(); + List fieldList = new ArrayList(Arrays.asList(declaredFields)); + fieldList.addAll(Arrays.asList(declaredSuperFields)); + Iterator var18 = fieldList.iterator(); + + while(var18.hasNext()) { + Field field = (Field)var18.next(); + if (field.getAnnotation(ApiModelProperty.class) != null) { + fieldMap.put(field.getName().toLowerCase(), ((ApiModelProperty)field.getAnnotation(ApiModelProperty.class)).value()); + } + } + + Map metadataMap = new HashMap(); + Iterator var21 = methodMap.entrySet().iterator(); + + while(var21.hasNext()) { + Map.Entry entry = (Map.Entry)var21.next(); + String filed = (String)entry.getKey(); + String lowerCaseField = filed.toLowerCase(); + if (fieldMap.containsKey(lowerCaseField)) { + MetadataModel metadata = new MetadataModel(); + metadata.setModelKey(filed); + metadata.setModelValue((String)entry.getValue()); + metadata.setModelKeyRemark(lowerCaseField); + metadataMap.put(filed, metadata); + } + } + + return metadataMap; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/enums/MetadataModelTypeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/enums/MetadataModelTypeEnum.java new file mode 100644 index 00000000..bb833e22 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/enums/MetadataModelTypeEnum.java @@ -0,0 +1,85 @@ +package com.bonus.core.common.enums; + +import cn.hutool.core.collection.CollUtil; + +import java.util.List; + +public enum MetadataModelTypeEnum { + ACC("acc", "账户配置"), + ATTENDANCE("Attendance", "考勤配置"), + CUSTOMER("customer", "人员配置"), + CUSTOMER_FACE("customer", "人员-人脸特征值配置"), + DELIVERY("delivery", "配送配置"), + DEVICE("device", "设备配置"), + DEVICE_CABINET("device", "设备-取餐柜配置"), + DEVICE_WEIGHT("device", "设备-计量主机配置"), + DEVICE_CONSUME("device", "设备-消费机配置"), + ENTERPRISE_CODE("enterpriseCode", "支付宝企业码"), + MARKETING("supermarket", "商超配置"), + MEALTIME("mealtime", "餐次配置"), + MENU("menu", "菜品菜谱配置"), + MERCHANT("merchant", "商家配置"), + MOBILE("mobile", "移动端配置"), + MOBILE_COMMON("mobile", "移动端通用配置"), + NOTICE("notice", "通知配置"), + NOTICE_PRINT("notice", "通知-打印配置"), + NUTRITION("nutrition", "营养模块配置"), + ORDER("order", "订单配置"), + ORDER_CHARGEBACK("order", "订单-退单配置"), + ORDER_RESERVE("order", "订单-订餐配置"), + ORDER_DELIVERY("order", "订单-配送配置"), + PAY("pay", "支付配置"), + PAY_ALIPAY("pay", "支付-支付宝配置"), + PAY_WECHATPAY("pay", "支付-微信配置"), + PAY_WECHATPAY_SCORE("pay", "支付-微信支付分配置"), + PAY_SHOUQIANBA("pay", "支付-收钱吧配置"), + PAY_UNIONPAY_QUICK("pay", "支付-银联云闪付配置"), + PAY_ABC("pay", "支付-农业银行配置"), + PAY_ICBC("pay", "支付-工商银行配置"), + PAY_OTHER("pay", "支付-其他支付配置"), + REPORT("report", "报表配置"), + REPORT_DATA_SCREEN("report", "数据大屏"), + DRP_SUPPLIER_SCORE("drp", "出入库-供应商评分"), + DRP("drp", "出入库"); + + private final String key; + private final String desc; + + public boolean supportSeparated() { + return CollUtil.contains(supportSeparatedTypes(), this.key); + } + + public static List supportSeparatedTypes() { + return CollUtil.toList(new String[]{MEALTIME.getKey(), DELIVERY.getKey(), ORDER.getKey(), PAY.getKey()}); + } + + public static String modelKeyOfSeparatedType(String key) { + if (DELIVERY.getKey().equals(key)) { + return "ifEnableDelivery"; + } else if (ORDER.getKey().equals(key)) { + return "ifEnableOrder"; + } else if (PAY.getKey().equals(key)) { + return "ifEnablePay"; + } else { + return MEALTIME.getKey().equals(key) ? "ifEnableMealtime" : ""; + } + } + + private MetadataModelTypeEnum(String key, String desc) { + this.key = key; + this.desc = desc; + } + + public String getKey() { + return this.key; + } + + public String getDesc() { + return this.desc; + } + + // $FF: synthetic method + private static MetadataModelTypeEnum[] $values() { + return new MetadataModelTypeEnum[]{ACC, ATTENDANCE, CUSTOMER, CUSTOMER_FACE, DELIVERY, DEVICE, DEVICE_CABINET, DEVICE_WEIGHT, DEVICE_CONSUME, ENTERPRISE_CODE, MARKETING, MEALTIME, MENU, MERCHANT, MOBILE, MOBILE_COMMON, NOTICE, NOTICE_PRINT, NUTRITION, ORDER, ORDER_CHARGEBACK, ORDER_RESERVE, ORDER_DELIVERY, PAY, PAY_ALIPAY, PAY_WECHATPAY, PAY_WECHATPAY_SCORE, PAY_SHOUQIANBA, PAY_UNIONPAY_QUICK, PAY_ABC, PAY_ICBC, PAY_OTHER, REPORT, REPORT_DATA_SCREEN, DRP_SUPPLIER_SCORE, DRP}; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/redis/RedisUtil.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/redis/RedisUtil.java new file mode 100644 index 00000000..954ccfb2 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/redis/RedisUtil.java @@ -0,0 +1,125 @@ +package com.bonus.core.common.redis; + +import cn.hutool.core.collection.CollUtil; +import com.bonus.core.common.utils.SpringContextHolder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.env.Environment; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.data.redis.core.ZSetOperations; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +public class RedisUtil { + private static final Logger log = LoggerFactory.getLogger(RedisUtil.class); + + public static void setString(String key, String value) { + setString(key, value, (Long)null); + } + + public static void setString(String key, String value, Long timeOut) { + timeOut = timeoutFilter(timeOut); + if (value != null) { + if (timeOut != null) { + stringRedisTemplate().opsForValue().set(key, value, timeOut, TimeUnit.SECONDS); + } else { + stringRedisTemplate().opsForValue().set(key, value); + } + } + + } + + public static Boolean setIfPresentString(String key, String value, Long timeOut) { + timeOut = timeoutFilter(timeOut); + if (value != null) { + return timeOut != null ? stringRedisTemplate().opsForValue().setIfPresent(key, value, timeOut, TimeUnit.SECONDS) : stringRedisTemplate().opsForValue().setIfPresent(key, value); + } else { + return false; + } + } + + public static String getString(String key) { + return (String)stringRedisTemplate().opsForValue().get(key); + } + + public static void setObj(String key, Object value) { + setObj(key, value, (Long)null); + } + + public static void setObj(String key, Object value, Long timeOut) { + timeOut = timeoutFilter(timeOut); + if (value != null) { + if (timeOut != null) { + redisTemplate().opsForValue().set(key, value, timeOut, TimeUnit.SECONDS); + } else { + redisTemplate().opsForValue().set(key, value); + } + } + + } + + public static Object getObj(String key) { + return redisTemplate().opsForValue().get(key); + } + + public static void delete(String key) { + redisTemplate().delete(key); + } + + public static void deleteByPattern(String keyPattern) { + Set keys = redisTemplate().keys(keyPattern); + if (CollUtil.isNotEmpty(keys)) { + redisTemplate().delete(keys); + } + + } + + + private static Long timeoutFilter(Long timeout) { + Long maxExpSecond = (Long)environment().getProperty("spring.redis.custom-max-expiration-second", Long.class); + if (maxExpSecond != null && (timeout == null || timeout > maxExpSecond)) { + timeout = maxExpSecond; + } + + return timeout; + } + + public static List keysByPattern(String pattern) { + Set keys = redisTemplate().keys(pattern); + return (List)(CollUtil.isEmpty(keys) ? new ArrayList() : (List)keys.stream().map(Object::toString).collect(Collectors.toList())); + } + + public static void multiSet(Map map) { + redisTemplate().opsForValue().multiSet(map); + } + + public static List multiGet(List keys) { + return redisTemplate().opsForValue().multiGet(keys); + } + + public static void zAdd(String key, Object value, double score) { + redisTemplate().opsForZSet().add(key, value, score); + } + + public static Set> zGetList(String key, long start, long end) { + return redisTemplate().opsForZSet().rangeWithScores(key, start, end); + } + + private static StringRedisTemplate stringRedisTemplate() { + return (StringRedisTemplate) SpringContextHolder.getBean(StringRedisTemplate.class); + } + + private static RedisTemplate redisTemplate() { + return (RedisTemplate)SpringContextHolder.getBean("redisTemplate"); + } + + private static Environment environment() { + return (Environment)SpringContextHolder.getBean(Environment.class); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/OssProperties.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/OssProperties.java new file mode 100644 index 00000000..01130a68 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/OssProperties.java @@ -0,0 +1,108 @@ +package com.bonus.core.common.utils; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties( + prefix = "oss" +) +public class OssProperties { + private String endpoint; + private String customDomain; + private Boolean pathStyleAccess = true; + private String appId; + private String region; + private String accessKey; + private String secretKey; + private String bucketName = "lnyst"; + private Boolean useHttp = false; + private Integer expiresTime = 604800; + private Boolean useToken = false; + + public String getEndpoint() { + return this.endpoint; + } + + public String getCustomDomain() { + return this.customDomain; + } + + public Boolean getPathStyleAccess() { + return this.pathStyleAccess; + } + + public String getAppId() { + return this.appId; + } + + public String getRegion() { + return this.region; + } + + public String getAccessKey() { + return this.accessKey; + } + + public String getSecretKey() { + return this.secretKey; + } + + public String getBucketName() { + return this.bucketName; + } + + public Boolean getUseHttp() { + return this.useHttp; + } + + public Integer getExpiresTime() { + return this.expiresTime; + } + + public Boolean getUseToken() { + return this.useToken; + } + + public void setEndpoint(final String endpoint) { + this.endpoint = endpoint; + } + + public void setCustomDomain(final String customDomain) { + this.customDomain = customDomain; + } + + public void setPathStyleAccess(final Boolean pathStyleAccess) { + this.pathStyleAccess = pathStyleAccess; + } + + public void setAppId(final String appId) { + this.appId = appId; + } + + public void setRegion(final String region) { + this.region = region; + } + + public void setAccessKey(final String accessKey) { + this.accessKey = accessKey; + } + + public void setSecretKey(final String secretKey) { + this.secretKey = secretKey; + } + + public void setBucketName(final String bucketName) { + this.bucketName = bucketName; + } + + public void setUseHttp(final Boolean useHttp) { + this.useHttp = useHttp; + } + + public void setExpiresTime(final Integer expiresTime) { + this.expiresTime = expiresTime; + } + + public void setUseToken(final Boolean useToken) { + this.useToken = useToken; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/OssTemplate.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/OssTemplate.java new file mode 100644 index 00000000..1093208c --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/OssTemplate.java @@ -0,0 +1,36 @@ +package com.bonus.core.common.utils; + +import com.amazonaws.services.s3.AmazonS3; +import org.springframework.beans.factory.InitializingBean; + +import java.net.URL; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +public class OssTemplate implements InitializingBean { + private final OssProperties ossProperties; + private AmazonS3 amazonS3; + + + public String getObjectURL(String bucketName, String objectName, Integer expires) { + try { + Date date = new Date(); + Calendar calendar = new GregorianCalendar(); + calendar.setTime(date); + calendar.add(13, expires); + URL url = this.amazonS3.generatePresignedUrl(bucketName, objectName, calendar.getTime()); + return url.toString(); + } catch (Throwable var7) { + throw var7; + } + } + public OssTemplate(final OssProperties ossProperties) { + this.ossProperties = ossProperties; + } + + @Override + public void afterPropertiesSet() throws Exception { + + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SpringContextHolder.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SpringContextHolder.java new file mode 100644 index 00000000..cd8909f4 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SpringContextHolder.java @@ -0,0 +1,53 @@ +package com.bonus.core.common.utils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +@Service +@Lazy(false) +public class SpringContextHolder implements ApplicationContextAware, DisposableBean { + private static final Logger log = LoggerFactory.getLogger(SpringContextHolder.class); + private static ApplicationContext applicationContext = null; + + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) { + SpringContextHolder.applicationContext = applicationContext; + } + + public static T getBean(String name) { + return (T) applicationContext.getBean(name); + } + + public static T getBean(Class requiredType) { + return applicationContext.getBean(requiredType); + } + + public static void clearHolder() { + if (log.isDebugEnabled()) { + log.debug("清除SpringContextHolder中的ApplicationContext:" + String.valueOf(applicationContext)); + } + + applicationContext = null; + } + + public static void publishEvent(ApplicationEvent event) { + if (applicationContext != null) { + applicationContext.publishEvent(event); + } + } + + @Override + public void destroy() { + clearHolder(); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/StandardCharsets.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/StandardCharsets.java new file mode 100644 index 00000000..1902212f --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/StandardCharsets.java @@ -0,0 +1,36 @@ +package com.bonus.core.common.utils; + +import java.nio.charset.Charset; + +public final class StandardCharsets { + + private StandardCharsets() { + throw new AssertionError("No java.nio.charset.StandardCharsets instances for you!"); + } + /** + * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the + * Unicode character set + */ + public static final Charset US_ASCII = Charset.forName("US-ASCII"); + /** + * ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 + */ + public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); + /** + * Eight-bit UCS Transformation Format + */ + public static final Charset UTF_8 = Charset.forName("UTF-8"); + /** + * Sixteen-bit UCS Transformation Format, big-endian byte order + */ + public static final Charset UTF_16BE = Charset.forName("UTF-16BE"); + /** + * Sixteen-bit UCS Transformation Format, little-endian byte order + */ + public static final Charset UTF_16LE = Charset.forName("UTF-16LE"); + /** + * Sixteen-bit UCS Transformation Format, byte order identified by an + * optional byte-order mark + */ + public static final Charset UTF_16 = Charset.forName("UTF-16"); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SysUtil.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SysUtil.java new file mode 100644 index 00000000..ee10da86 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SysUtil.java @@ -0,0 +1,137 @@ +package com.bonus.core.common.utils; + +import cn.hutool.core.text.CharSequenceUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.stream.Collectors; + +@Component +public class SysUtil { + private static final Logger log = LoggerFactory.getLogger(SysUtil.class); + @Value("${system.sysfile.prefixOffline}") + private String prefixOffline; + @Value("${system.sysfile.bucket}") + private String prefixBucket; + @Value("${system.sysfile.prefixOnline}") + private String prefixOnline; + private static final SysUtilProxy sysUtilProxy = new SysUtilProxy(); + private static String prefixOn; + private static String bucket; + private static String prefixOff; + + @PostConstruct + public void init() { + prefixOn = this.prefixOnline; + bucket = this.prefixBucket; + prefixOff = this.prefixOffline; + } + + public static String getPrefix() { + return sysUtilProxy.getPrefix(prefixOn, prefixOff); + } + + public static String getBucket() { + return bucket; + } + + public static String getCutFileUrl(String fileUrl) { + log.info("出参_补图_原路径:{},前缀:{},存储桶:{}", new Object[]{fileUrl, getPrefix(), getBucket()}); + String cutFileUrl = getCutFileUrl(fileUrl, getPrefix(), getBucket()); + log.info("出参_补图_补图后路径:{}", cutFileUrl); + return cutFileUrl; + } + + public static String getCutPath(String fileUrl) { + log.info("入参_裁图_原路径:{},前缀:{},存储桶:{}", new Object[]{fileUrl, getPrefix(), getBucket()}); + if (!CharSequenceUtil.isBlank(fileUrl) && !fileUrl.startsWith(getBucket())) { + if (Boolean.FALSE.equals(getOssProperties().getUseToken())) { + return fileUrl.replace(getPrefix(), getBucket()); + } else { + fileUrl = getUnEncodeUrl(fileUrl); + fileUrl = fileUrl.replace(getPrefix(), getBucket()); + fileUrl = getCutSignUrl(fileUrl); + log.info("入参_裁图_裁剪后路径:{}", fileUrl); + return fileUrl; + } + } else { + return fileUrl; + } + } + + public static String getCutPathMulti(String fileUrl) { + return CharSequenceUtil.contains(fileUrl, ",") ? (String)CharSequenceUtil.split(fileUrl, ",", true, true).stream().map(SysUtil::getCutPath).collect(Collectors.joining(",")) : getCutPath(fileUrl); + } + + public static String getFilePath(String fileUrl) { + if (CharSequenceUtil.isBlank(fileUrl)) { + return fileUrl; + } else { + String cutPath = getCutPath(fileUrl); + return cutPath.replace(getBucket(), ""); + } + } + + public static String getObjectName(String fileUrl) { + if (CharSequenceUtil.isBlank(fileUrl)) { + return fileUrl; + } else { + String cutPath = getCutPath(fileUrl); + String replace = cutPath.replace(getBucket(), ""); + if (CharSequenceUtil.startWith(replace, "/")) { + replace = replace.substring(1); + } + + return replace; + } + } + + public static OssTemplate getOssTemplate() { + return (OssTemplate)SpringContextHolder.getBean(OssTemplate.class); + } + + public static OssProperties getOssProperties() { + return (OssProperties)SpringContextHolder.getBean(OssProperties.class); + } + + public static String getUnEncodeUrl(String url) { + if (CharSequenceUtil.isBlank(url)) { + return url; + } else { + try { + String decodedUrl = URLDecoder.decode(url, String.valueOf(StandardCharsets.UTF_8)); + return !decodedUrl.equals(url) ? decodedUrl : url; + } catch (IllegalArgumentException var2) { + log.info("图片url解码失败,图片url:{},异常信息_:{},详情_:", new Object[]{url, var2.getMessage(), var2}); + return url; + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + } + + public static String getCutSignUrl(String fileUrl) { + return CharSequenceUtil.isNotBlank(fileUrl) && fileUrl.contains("?") ? fileUrl.substring(0, fileUrl.indexOf("?")) : fileUrl; + } + + public static String getCutFileUrl(String fileUrl, String filePrefix, String prefixBucket) { + if (CharSequenceUtil.isBlank(fileUrl)) { + return fileUrl; + } else if (Boolean.FALSE.equals(getOssProperties().getUseToken())) { + return !fileUrl.startsWith("http") && !fileUrl.startsWith("https") ? fileUrl.replace(prefixBucket, filePrefix) : fileUrl; + } else { + if (fileUrl.startsWith("http") || fileUrl.startsWith("https")) { + fileUrl = fileUrl.replace(filePrefix + "/", ""); + } + + fileUrl = getCutSignUrl(fileUrl); + fileUrl = fileUrl.replace(prefixBucket + "/", ""); + return getOssTemplate().getObjectURL(prefixBucket, fileUrl, getOssProperties().getExpiresTime()); + } + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SysUtilProxy.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SysUtilProxy.java new file mode 100644 index 00000000..a4df7802 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/SysUtilProxy.java @@ -0,0 +1,19 @@ +package com.bonus.core.common.utils; + +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.Objects; + +public class SysUtilProxy { + public String getPrefix(String prefixOn, String prefixOff) { + if (RequestContextHolder.getRequestAttributes() != null) { + HttpServletRequest request = ((ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); + String headerValue = request.getHeader("X-Env"); + return "online".equals(headerValue) ? prefixOn : prefixOff; + } else { + return prefixOff; + } + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/TenantContextHolder.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/TenantContextHolder.java new file mode 100644 index 00000000..836c424b --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/common/utils/TenantContextHolder.java @@ -0,0 +1,21 @@ +package com.bonus.core.common.utils; + +public final class TenantContextHolder { + private static final ThreadLocal THREAD_LOCAL_TENANT = new InheritableThreadLocal(); + + public static Long getTenantId() { + return (Long)THREAD_LOCAL_TENANT.get(); + } + + public static void setTenantId(Long tenantId) { + THREAD_LOCAL_TENANT.set(tenantId); + } + + public static void clear() { + THREAD_LOCAL_TENANT.remove(); + } + + private TenantContextHolder() { + throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } +} diff --git a/pom.xml b/pom.xml index 6788d7a8..07f54e2e 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ 4.1.2 2.14.4 3.0.2 + 3.5.10.1 @@ -240,6 +241,15 @@ bonus-api-system ${bonus.version} + + + com.baomidou + mybatis-plus-boot-starter + ${mybatis-plus.version} + pom + import + +