ShopMerchant缓存

This commit is contained in:
2025-03-12 10:38:50 +08:00
parent 7de83f5dc9
commit 8aa5e98317
5 changed files with 36 additions and 19 deletions

View File

@@ -9,6 +9,9 @@ import com.czg.service.account.mapper.ShopMerchantMapper;
import com.czg.utils.AssertUtil;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
@@ -18,6 +21,7 @@ import java.io.Serializable;
* @author Administrator
* @since 2025-02-11
*/
@CacheConfig(cacheNames = "shop:merchant")
@DubboService
public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, ShopMerchant> implements ShopMerchantService {
@@ -27,12 +31,12 @@ public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, Sho
return one == null ? new ShopMerchant() : one;
}
@CacheEvict(key = "#shopMerchantEditDTO.id")
@Override
public Boolean edit(ShopMerchantEditDTO shopMerchantEditDTO) {
ShopMerchant shopMerchant = queryChain().eq(ShopMerchant::getShopId, StpKit.USER.getLoginIdAsLong()).one();
ShopMerchant shopMerchant = queryChain().eq(ShopMerchant::getShopId, shopMerchantEditDTO.getShopId()).one();
if (shopMerchant == null) {
shopMerchant = new ShopMerchant();
shopMerchant.setShopId(StpKit.USER.getLoginIdAsLong());
BeanUtil.copyProperties(shopMerchantEditDTO, shopMerchant);
return save(shopMerchant);
}
@@ -40,10 +44,11 @@ public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, Sho
return updateById(shopMerchant);
}
@Cacheable(key = "#id")
@Override
public ShopMerchant getById(Serializable id) {
ShopMerchant shopMerchant = getMapper().selectOneById(id);
AssertUtil.isNull(shopMerchant, "暂未开通支付");
return getMapper().selectOneById(id);
return shopMerchant;
}
}