店铺信息getById加入缓存

This commit is contained in:
张松
2025-03-01 18:06:41 +08:00
parent 4b5f62705d
commit 65cd160e61
2 changed files with 18 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import cn.hutool.http.server.HttpServerResponse;
import com.czg.account.dto.SysLoginDTO; import com.czg.account.dto.SysLoginDTO;
import com.czg.account.service.AuthorizationService; import com.czg.account.service.AuthorizationService;
import com.czg.account.service.PermissionService; import com.czg.account.service.PermissionService;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopTableService; import com.czg.account.service.ShopTableService;
import com.czg.account.vo.LoginVO; import com.czg.account.vo.LoginVO;
import com.czg.annotation.SaAdminCheckPermission; import com.czg.annotation.SaAdminCheckPermission;
@@ -32,6 +33,8 @@ public class AuthorizationController {
private AuthorizationService authorizationService; private AuthorizationService authorizationService;
@Resource @Resource
private PermissionService permissionService; private PermissionService permissionService;
@Resource
private ShopInfoService shopInfoService;
/** /**
@@ -64,11 +67,12 @@ public class AuthorizationController {
ShopTableService shopTableService; ShopTableService shopTableService;
@GetMapping("test") @GetMapping("test")
public CzgResult<?> login(HttpServletRequest request, HttpServletResponse response) throws IOException { public CzgResult<?> login(HttpServletRequest request, HttpServletResponse response) throws IOException {
shopTableService.createQrCode(1L, 1, response, request); // shopTableService.createQrCode(1L, 1, response, request);
// rabbitPublisher.sendOrderPrintMsg("552"); // rabbitPublisher.sendOrderPrintMsg("552");
// printMqListener.orderPrint("1"); // printMqListener.orderPrint("1");
// return CzgResult.success(Map.of("token", StpKit.USER.getShopId())); // return CzgResult.success(Map.of("token", StpKit.USER.getShopId()));
return CzgResult.success(); return CzgResult.success( shopInfoService.getById(1));
} }
} }

View File

@@ -19,9 +19,13 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService; 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 org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@@ -32,6 +36,7 @@ import java.util.stream.Collectors;
*/ */
@DubboService @DubboService
@Service @Service
@CacheConfig(cacheNames = "shopInfo")
public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements ShopInfoService { public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements ShopInfoService {
@Resource @Resource
private SysUserService sysUserService; private SysUserService sysUserService;
@@ -44,6 +49,12 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
@Resource @Resource
private ShopExtendService shopExtendService; private ShopExtendService shopExtendService;
@Override
@Cacheable(value = "#id")
public ShopInfo getById(Serializable id) {
return super.getById(id);
}
private ShopInfo getShopInfo(Long shopId) { private ShopInfo getShopInfo(Long shopId) {
ShopInfo shopInfo = getById(shopId); ShopInfo shopInfo = getById(shopId);
if (shopInfo == null) { if (shopInfo == null) {
@@ -112,6 +123,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
} }
@Override @Override
@CacheEvict(key = "#shopInfoEditDTO.id")
public Boolean edit(ShopInfoEditDTO shopInfoEditDTO) { public Boolean edit(ShopInfoEditDTO shopInfoEditDTO) {
ShopInfo shopInfo; ShopInfo shopInfo;
if (!StpKit.USER.isAdmin()) { if (!StpKit.USER.isAdmin()) {