feat:
1. add cache for category and stickers
This commit is contained in:
@@ -36,6 +36,8 @@ import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.modules.kiosk.pojo.entity.CategoryEntity;
|
||||
@@ -97,6 +99,7 @@ public class CategoryController extends BladeController {
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入category")
|
||||
@CacheEvict(cacheNames = "kiosk:category:list", key = "'all-categories'")
|
||||
public R save(@Valid @RequestBody CategoryEntity category) {
|
||||
return R.status(categoryService.save(category));
|
||||
}
|
||||
@@ -107,6 +110,7 @@ public class CategoryController extends BladeController {
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入category")
|
||||
@CacheEvict(cacheNames = "kiosk:category:list", key = "'all-categories'")
|
||||
public R update(@Valid @RequestBody CategoryEntity category) {
|
||||
return R.status(categoryService.updateById(category));
|
||||
}
|
||||
@@ -117,6 +121,7 @@ public class CategoryController extends BladeController {
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入category")
|
||||
@CacheEvict(cacheNames = "kiosk:category:list", key = "'all-categories'")
|
||||
public R submit(@Valid @RequestBody CategoryEntity category) {
|
||||
return R.status(categoryService.saveOrUpdate(category));
|
||||
}
|
||||
@@ -127,6 +132,7 @@ public class CategoryController extends BladeController {
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
@CacheEvict(cacheNames = "kiosk:category:list", key = "'all-categories'")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(categoryService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springblade.modules.kiosk.pojo.vo.DictBizApiVO;
|
||||
import org.springblade.modules.kiosk.pojo.vo.PhotoAttachmentApiVO;
|
||||
import org.springblade.modules.kiosk.pojo.vo.StickersApiVO;
|
||||
import org.springblade.modules.kiosk.service.IKioskApiService;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@@ -31,11 +32,26 @@ public class KioskApiController {
|
||||
*/
|
||||
@GetMapping("/category-list")
|
||||
@Operation(summary = "产品目录")
|
||||
@Cacheable(cacheNames = "kiosk:category:list", key = "'all-categories'")
|
||||
public R<List<CategoryApiVO>> categoryList() {
|
||||
List<CategoryApiVO> list = kioskApiService.categoryList();
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 照片列表查询
|
||||
*
|
||||
* @return List<StickersApiVO>
|
||||
*/
|
||||
@GetMapping("/stickers-list")
|
||||
@Operation(summary = "贴纸列表查询")
|
||||
@Cacheable(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R<List<StickersApiVO>> stickersList() {
|
||||
List<StickersApiVO> list = kioskApiService.stickersList();
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 材质目录查询
|
||||
*
|
||||
@@ -97,18 +113,6 @@ public class KioskApiController {
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 照片列表查询
|
||||
*
|
||||
* @return List<StickersApiVO>
|
||||
*/
|
||||
@GetMapping("/stickers-list")
|
||||
@Operation(summary = "贴纸列表查询")
|
||||
public R<List<StickersApiVO>> stickersList() {
|
||||
List<StickersApiVO> list = kioskApiService.stickersList();
|
||||
return R.data(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单提交
|
||||
*
|
||||
|
||||
@@ -36,6 +36,8 @@ import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.modules.kiosk.pojo.entity.StickersEntity;
|
||||
@@ -97,6 +99,7 @@ public class StickersController extends BladeController {
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入stickers")
|
||||
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R save(@Valid @RequestBody StickersEntity stickers) {
|
||||
return R.status(stickersService.save(stickers));
|
||||
}
|
||||
@@ -107,6 +110,7 @@ public class StickersController extends BladeController {
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入stickers")
|
||||
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R update(@Valid @RequestBody StickersEntity stickers) {
|
||||
return R.status(stickersService.updateById(stickers));
|
||||
}
|
||||
@@ -117,6 +121,7 @@ public class StickersController extends BladeController {
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入stickers")
|
||||
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R submit(@Valid @RequestBody StickersEntity stickers) {
|
||||
return R.status(stickersService.saveOrUpdate(stickers));
|
||||
}
|
||||
@@ -127,6 +132,7 @@ public class StickersController extends BladeController {
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(stickersService.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -56,7 +57,7 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
|
||||
private final IStickersAttachmentRService stickersAttachmentRService;
|
||||
|
||||
private static final String codePrefix = "kiosk:code:";
|
||||
private static final String codePrefix = "kiosk:upload:code:";
|
||||
|
||||
private static final String shapeType = "shape_type";
|
||||
|
||||
@@ -73,7 +74,7 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
vo.setType(category.getType());
|
||||
vo.setImageUrl(category.getImageUrl());
|
||||
return vo;
|
||||
}).toList();
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,7 +140,7 @@ public class KioskServiceImpl implements IKioskApiService {
|
||||
vo.setLink(stickers.getLink());
|
||||
vo.setId(stickers.getId());
|
||||
return vo;
|
||||
}).toList();
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user