From babf3609c90fb5ce3c7bc2a6771fb0978df9ae7d Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 19 Dec 2025 09:24:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=A4=B1=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20=E5=BA=97=E9=93=BA=E5=BC=80=E5=85=B3=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/service/ShopConfigService.java | 4 ++++ .../czg/account/service/ShopInfoService.java | 2 +- .../com/czg/constants/ShopSwitchTypeEnum.java | 20 ++-------------- .../account/mapper/ShopInfoMapper.java | 1 + .../service/impl/ShopConfigServiceImpl.java | 24 +++++++++++-------- .../service/impl/ShopInfoServiceImpl.java | 11 ++------- 6 files changed, 24 insertions(+), 38 deletions(-) diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopConfigService.java b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopConfigService.java index 62c659a4a..1d1ff671e 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopConfigService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopConfigService.java @@ -1,8 +1,10 @@ package com.czg.account.service; import com.czg.account.entity.ShopConfig; +import com.czg.account.entity.ShopInfo; import com.mybatisflex.core.service.IService; +import java.io.Serializable; import java.util.List; /** @@ -13,6 +15,8 @@ import java.util.List; */ public interface ShopConfigService extends IService { + ShopInfo getShopInfoAndConfig(Serializable id); + void editStatusByShopIdList(Long mainShopId, Integer isEnable, boolean onyUpValid, String name, String useShopType, List shopIdList); boolean editConfig(Long shopId, ShopConfig shopConfig); diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopInfoService.java b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopInfoService.java index 468c552a1..e475b7127 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopInfoService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopInfoService.java @@ -24,7 +24,7 @@ public interface ShopInfoService extends IService { /** * 检测开关 * @param shopId 店铺id - * @param switchType ShopInfo的某列 开关 + * @param switchType ShopInfo的某列 开关 目前只支持Integer类型字段 * @return true:开启 false:关闭 */ boolean checkSwitch(Long shopId, ShopSwitchTypeEnum switchType) throws ValidateException; diff --git a/cash-common/cash-common-service/src/main/java/com/czg/constants/ShopSwitchTypeEnum.java b/cash-common/cash-common-service/src/main/java/com/czg/constants/ShopSwitchTypeEnum.java index 2cc498a8e..edeb9d344 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/constants/ShopSwitchTypeEnum.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/constants/ShopSwitchTypeEnum.java @@ -8,24 +8,18 @@ import com.czg.account.entity.ShopInfo; * @author ww */ public enum ShopSwitchTypeEnum { - GROUP_BUY("groupBuy", "拼团开关", ShopInfo::getIsGroupBuy), + GROUP_BUY("拼团开关", ShopInfo::getIsGroupBuy), ; - private final String code; private final String description; private final SerializableFunction getter; - ShopSwitchTypeEnum(String code, String description, + ShopSwitchTypeEnum(String description, SerializableFunction getter) { - this.code = code; this.description = description; this.getter = getter; } - public String getCode() { - return code; - } - public String getDescription() { return description; } @@ -44,14 +38,4 @@ public enum ShopSwitchTypeEnum { public SerializableFunction getGetter() { return getter; } - - // 根据code获取枚举 - public static ShopSwitchTypeEnum getByCode(String code) { - for (ShopSwitchTypeEnum type : values()) { - if (type.code.equals(code)) { - return type; - } - } - throw new IllegalArgumentException("未知的开关类型: " + code); - } } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/mapper/ShopInfoMapper.java b/cash-service/account-service/src/main/java/com/czg/service/account/mapper/ShopInfoMapper.java index d5d39a3ac..e698ffb1c 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/mapper/ShopInfoMapper.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/mapper/ShopInfoMapper.java @@ -6,6 +6,7 @@ import com.mybatisflex.core.BaseMapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; +import org.springframework.cache.annotation.Cacheable; import java.math.BigDecimal; import java.util.List; diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopConfigServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopConfigServiceImpl.java index 31df60b02..1d1917f10 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopConfigServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopConfigServiceImpl.java @@ -5,6 +5,7 @@ import com.czg.account.dto.ShopConfigDTO; import com.czg.account.entity.ShopConfig; import com.czg.account.entity.ShopInfo; import com.czg.account.service.ShopConfigService; +import com.czg.exception.CzgException; import com.czg.sa.StpKit; import com.czg.service.RedisService; import com.czg.service.account.mapper.ShopConfigMapper; @@ -14,7 +15,9 @@ import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.spring.service.impl.ServiceImpl; import jakarta.annotation.Resource; import org.apache.dubbo.config.annotation.DubboService; +import org.springframework.cache.annotation.Cacheable; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -34,17 +37,18 @@ public class ShopConfigServiceImpl extends ServiceImpl implements ShopInfoService{ +public class ShopInfoServiceImpl extends ServiceImpl implements ShopInfoService { @Resource private RabbitPublisher rabbitPublisher; @Resource @@ -83,15 +83,8 @@ public class ShopInfoServiceImpl extends ServiceImpl i private SysParamsService sysParamsService; @Override - @Cacheable(key = "#id") public ShopInfo getById(Serializable id) throws CzgException { - ShopInfo shopInfo = super.getById(id); - if (shopInfo == null) { - throw new CzgException("店铺不存在"); - } - ShopConfig shopConfig = shopConfigService.getById(shopInfo.getId()); - BeanUtil.copyProperties(shopConfig, shopInfo); - return shopInfo; + return shopConfigService.getShopInfoAndConfig(id); } @Override