缓存注解
This commit is contained in:
@@ -32,6 +32,9 @@ import com.czg.service.market.mapper.MkBirthdayGiftMapper;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@@ -52,6 +55,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "birthdayGift")
|
||||||
public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper, MkBirthdayGift> implements MkBirthdayGiftService {
|
public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper, MkBirthdayGift> implements MkBirthdayGiftService {
|
||||||
@Resource
|
@Resource
|
||||||
private MkBirthdayGiftRecordService birthdayGiftRecordService;
|
private MkBirthdayGiftRecordService birthdayGiftRecordService;
|
||||||
@@ -72,6 +76,7 @@ public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper,
|
|||||||
private ShopUserService shopUserService;
|
private ShopUserService shopUserService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(key = "#shopId")
|
||||||
public MkBirthdayGiftVO detail(Long shopId) {
|
public MkBirthdayGiftVO detail(Long shopId) {
|
||||||
MkBirthdayGift gift = getOne(new QueryWrapper().eq(MkBirthdayGift::getMainShopId, shopId));
|
MkBirthdayGift gift = getOne(new QueryWrapper().eq(MkBirthdayGift::getMainShopId, shopId));
|
||||||
if (gift == null) {
|
if (gift == null) {
|
||||||
@@ -88,6 +93,7 @@ public class MkBirthdayGiftServiceImpl extends ServiceImpl<MkBirthdayGiftMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@CacheEvict(key = "#shopId")
|
||||||
public Boolean edit(Long shopId, MkBirthdayGiftDTO giftDTO) {
|
public Boolean edit(Long shopId, MkBirthdayGiftDTO giftDTO) {
|
||||||
MkBirthdayGift birthdayGift = getOne(new QueryWrapper().eq(MkBirthdayGift::getMainShopId, shopId));
|
MkBirthdayGift birthdayGift = getOne(new QueryWrapper().eq(MkBirthdayGift::getMainShopId, shopId));
|
||||||
BeanUtil.copyProperties(giftDTO, birthdayGift);
|
BeanUtil.copyProperties(giftDTO, birthdayGift);
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ import com.czg.service.market.mapper.MkConsumeCashbackMapper;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "consumeCashback")
|
||||||
public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackMapper, MkConsumeCashback> implements MkConsumeCashbackService {
|
public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackMapper, MkConsumeCashback> implements MkConsumeCashbackService {
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private ShopInfoService shopInfoService;
|
private ShopInfoService shopInfoService;
|
||||||
@@ -61,6 +65,7 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
|
|||||||
private MkConsumeCashbackRecordService consumeCashbackRecordService;
|
private MkConsumeCashbackRecordService consumeCashbackRecordService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(key = "#shopId")
|
||||||
public MkConsumeCashbackVO detail(Long shopId) {
|
public MkConsumeCashbackVO detail(Long shopId) {
|
||||||
MkConsumeCashback consumeCashback = getOne(new QueryWrapper().eq(MkConsumeCashback::getMainShopId, shopId));
|
MkConsumeCashback consumeCashback = getOne(new QueryWrapper().eq(MkConsumeCashback::getMainShopId, shopId));
|
||||||
if (consumeCashback == null) {
|
if (consumeCashback == null) {
|
||||||
@@ -82,6 +87,7 @@ public class MkConsumeCashbackServiceImpl extends ServiceImpl<MkConsumeCashbackM
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@CacheEvict(key = "#shopId")
|
||||||
public Boolean edit(Long shopId, MkConsumeCashbackDTO consumeDiscountDTO) {
|
public Boolean edit(Long shopId, MkConsumeCashbackDTO consumeDiscountDTO) {
|
||||||
MkConsumeCashback consumeCashback = getOne(new QueryWrapper().eq(MkConsumeCashback::getMainShopId, shopId));
|
MkConsumeCashback consumeCashback = getOne(new QueryWrapper().eq(MkConsumeCashback::getMainShopId, shopId));
|
||||||
BeanUtil.copyProperties(consumeDiscountDTO, consumeCashback);
|
BeanUtil.copyProperties(consumeDiscountDTO, consumeCashback);
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|||||||
import com.czg.market.entity.MkConsumeDiscount;
|
import com.czg.market.entity.MkConsumeDiscount;
|
||||||
import com.czg.market.service.MkConsumeDiscountService;
|
import com.czg.market.service.MkConsumeDiscountService;
|
||||||
import com.czg.service.market.mapper.MkConsumeDiscountMapper;
|
import com.czg.service.market.mapper.MkConsumeDiscountMapper;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -24,8 +27,10 @@ import java.math.BigDecimal;
|
|||||||
* @since 2025-09-16
|
* @since 2025-09-16
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "consumeDiscount")
|
||||||
public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountMapper, MkConsumeDiscount> implements MkConsumeDiscountService {
|
public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountMapper, MkConsumeDiscount> implements MkConsumeDiscountService {
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(key = "#shopId")
|
||||||
public MkConsumeDiscountVO detail(Long shopId) {
|
public MkConsumeDiscountVO detail(Long shopId) {
|
||||||
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
|
MkConsumeDiscount consumeDiscount = getOne(new QueryWrapper().eq(MkConsumeDiscount::getShopId, shopId));
|
||||||
if (consumeDiscount == null) {
|
if (consumeDiscount == null) {
|
||||||
@@ -47,6 +52,7 @@ public class MkConsumeDiscountServiceImpl extends ServiceImpl<MkConsumeDiscountM
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@CacheEvict(key = "#shopId")
|
||||||
public Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) {
|
public Boolean edit(Long shopId, MkConsumeDiscountDTO consumeDiscountDTO) {
|
||||||
if (consumeDiscountDTO.getRandomDiscountList() == null && consumeDiscountDTO.getDiscountAmount() == null) {
|
if (consumeDiscountDTO.getRandomDiscountList() == null && consumeDiscountDTO.getDiscountAmount() == null) {
|
||||||
throw new ApiNotPrintException("优惠金额和随机优惠金额不能同时为空");
|
throw new ApiNotPrintException("优惠金额和随机优惠金额不能同时为空");
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|||||||
import com.czg.market.entity.MkEnableConfig;
|
import com.czg.market.entity.MkEnableConfig;
|
||||||
import com.czg.market.service.MkEnableConfigService;
|
import com.czg.market.service.MkEnableConfigService;
|
||||||
import com.czg.service.market.mapper.MkEnableConfigMapper;
|
import com.czg.service.market.mapper.MkEnableConfigMapper;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,9 +25,11 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2025-10-21
|
* @since 2025-10-21
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "enableConfig")
|
||||||
public class MkEnableConfigServiceImpl extends ServiceImpl<MkEnableConfigMapper, MkEnableConfig> implements MkEnableConfigService{
|
public class MkEnableConfigServiceImpl extends ServiceImpl<MkEnableConfigMapper, MkEnableConfig> implements MkEnableConfigService{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Cacheable(key = "#mainShopId + ':' + #shopId")
|
||||||
public MkEnableConfigVO detail(Long mainShopId, Long shopId, TableValueConstant.EnableConfig.Type type) {
|
public MkEnableConfigVO detail(Long mainShopId, Long shopId, TableValueConstant.EnableConfig.Type type) {
|
||||||
MkEnableConfig one = getOne(new QueryWrapper().eq(MkEnableConfig::getMainShopId, mainShopId).eq(MkEnableConfig::getType, type.getCode()));
|
MkEnableConfig one = getOne(new QueryWrapper().eq(MkEnableConfig::getMainShopId, mainShopId).eq(MkEnableConfig::getType, type.getCode()));
|
||||||
if (one == null) {
|
if (one == null) {
|
||||||
@@ -43,6 +48,7 @@ public class MkEnableConfigServiceImpl extends ServiceImpl<MkEnableConfigMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@CacheEvict(key = "#mainShopId + ':' + #shopId")
|
||||||
public Boolean upEnable(Long mainShopId, Long shopId, MkEnableConfigDTO dto, TableValueConstant.EnableConfig.Type type) {
|
public Boolean upEnable(Long mainShopId, Long shopId, MkEnableConfigDTO dto, TableValueConstant.EnableConfig.Type type) {
|
||||||
MkEnableConfig one = getOne(new QueryWrapper().eq(MkEnableConfig::getMainShopId, mainShopId).eq(MkEnableConfig::getType, type.getCode()));
|
MkEnableConfig one = getOne(new QueryWrapper().eq(MkEnableConfig::getMainShopId, mainShopId).eq(MkEnableConfig::getType, type.getCode()));
|
||||||
if (one == null) {
|
if (one == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user