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