枚举问题

This commit is contained in:
2025-12-18 20:33:08 +08:00
parent 0b9ebaaa96
commit e4f51f2dec
7 changed files with 88 additions and 35 deletions

View File

@@ -3,7 +3,6 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.czg.account.dto.PageDTO;
@@ -14,6 +13,7 @@ import com.czg.account.enums.ShopTypeEnum;
import com.czg.account.service.*;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.constants.ShopSwitchTypeEnum;
import com.czg.enums.StatusEnum;
import com.czg.enums.YesNoEnum;
import com.czg.exception.CzgException;
@@ -32,10 +32,6 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.table.TableInfo;
import com.mybatisflex.core.table.TableInfoFactory;
import com.mybatisflex.core.util.LambdaGetter;
import com.mybatisflex.core.util.LambdaUtil;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@@ -47,14 +43,12 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.lang.invoke.SerializedLambda;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@@ -63,7 +57,7 @@ import java.util.stream.Collectors;
@Slf4j
@DubboService
@CacheConfig(cacheNames = "shopInfo")
public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements ShopInfoService, Serializable {
public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements ShopInfoService{
@Resource
private RabbitPublisher rabbitPublisher;
@Resource
@@ -101,17 +95,11 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
}
@Override
public <T> boolean checkSwitch(Long shopId, Function<ShopInfo, T> switchGetter) throws ValidateException {
public boolean checkSwitch(Long shopId, ShopSwitchTypeEnum switchType) throws ValidateException {
AssertUtil.isNull(shopId, "店铺ID不能为空");
ShopInfo shopInfo = getById(shopId);
AssertUtil.isNull(shopInfo, "店铺不存在");
T switchValue = switchGetter.apply(shopInfo);
if (switchValue == null) {
return false;
}
return convertToBoolean(switchValue);
return switchType.getValue(shopInfo);
}
private ShopInfo getShopInfo(Long shopId) {

View File

@@ -2,8 +2,8 @@ package com.czg.service.market.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.entity.ShopInfo;
import com.czg.account.service.ShopInfoService;
import com.czg.constants.ShopSwitchTypeEnum;
import com.czg.market.dto.GbWareDTO;
import com.czg.market.dto.GbWareQueryParamDTO;
import com.czg.market.entity.GbWare;
@@ -17,8 +17,6 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import java.io.Serializable;
/**
* 拼团商品 服务层实现。
*
@@ -26,14 +24,14 @@ import java.io.Serializable;
* @since 2025-12-15
*/
@Service
public class GbWareServiceImpl extends ServiceImpl<GbWareMapper, GbWare> implements GbWareService, Serializable {
public class GbWareServiceImpl extends ServiceImpl<GbWareMapper, GbWare> implements GbWareService {
@DubboReference
private ShopInfoService shopInfoService;
@Override
public Page<GbWare> getGbWarePage(GbWareQueryParamDTO param, Long shopId) {
if (!shopInfoService.checkSwitch(shopId, ShopInfo::getIsGroupBuy)) {
if (!shopInfoService.checkSwitch(shopId, ShopSwitchTypeEnum.GROUP_BUY)) {
return new Page<>();
}
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);