8.11 缓存优化,添加增删改时缓存失效逻辑
This commit is contained in:
parent
34909150be
commit
45fd2f6534
@ -212,47 +212,47 @@ public class PictureController {
|
||||
return ResultUtils.success(picturePage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取图片列表(封装类,脱敏),普通用户使用,且不能看到未过审的图片
|
||||
*/
|
||||
@PostMapping("/list/page/vo")
|
||||
public BaseResponse<Page<PictureVO>> listPictureVOByPage(@RequestBody PictureQueryRequest pictureQueryRequest,
|
||||
HttpServletRequest request) {
|
||||
long current = pictureQueryRequest.getCurrent();
|
||||
long size = pictureQueryRequest.getPageSize();
|
||||
// 限制爬虫,一次不能请求超过20页
|
||||
ThrowUtils.throwIf(size > 20, ErrorCode.PARAMS_ERROR);
|
||||
// 空间权限校验
|
||||
Long spaceId = pictureQueryRequest.getSpaceId();
|
||||
if (spaceId == null) {
|
||||
// 公开图库
|
||||
// 普通用户默认只能看到审核通过的数据
|
||||
pictureQueryRequest.setReviewStatus(PictureReviewStatusEnum.PASS.getValue());
|
||||
pictureQueryRequest.setNullSpaceId(true);
|
||||
} else {
|
||||
// 私有空间、团队空间,无需过审
|
||||
boolean hasPermission = StpKit.SPACE.hasPermission(SpaceUserPermissionConstant.PICTURE_VIEW);
|
||||
ThrowUtils.throwIf(!hasPermission, ErrorCode.NO_AUTH_ERROR);
|
||||
//已改为编程式鉴权
|
||||
// User loginUser = userService.getLoginUser(request);
|
||||
// Space space = spaceService.getById(spaceId);
|
||||
// ThrowUtils.throwIf(space == null, ErrorCode.NOT_FOUND_ERROR, "空间不存在");
|
||||
// if (!loginUser.getId().equals(space.getUserId())) {
|
||||
// throw new BusinessException(ErrorCode.NO_AUTH_ERROR, "没有空间权限");
|
||||
// }
|
||||
}
|
||||
// 查询数据库
|
||||
Page<Picture> picturePage = pictureService.page(new Page<>(current, size),
|
||||
pictureService.getQueryWrapper(pictureQueryRequest));
|
||||
// 获取封装类
|
||||
return ResultUtils.success(pictureService.getPictureVOPage(picturePage, request));
|
||||
}
|
||||
// /**
|
||||
// * 分页获取图片列表(封装类,脱敏),普通用户使用,且不能看到未过审的图片
|
||||
// */
|
||||
// @PostMapping("/list/page/vo")
|
||||
// public BaseResponse<Page<PictureVO>> listPictureVOByPage(@RequestBody PictureQueryRequest pictureQueryRequest,
|
||||
// HttpServletRequest request) {
|
||||
// long current = pictureQueryRequest.getCurrent();
|
||||
// long size = pictureQueryRequest.getPageSize();
|
||||
// // 限制爬虫,一次不能请求超过20页
|
||||
// ThrowUtils.throwIf(size > 20, ErrorCode.PARAMS_ERROR);
|
||||
// // 空间权限校验
|
||||
// Long spaceId = pictureQueryRequest.getSpaceId();
|
||||
// if (spaceId == null) {
|
||||
// // 公开图库
|
||||
// // 普通用户默认只能看到审核通过的数据
|
||||
// pictureQueryRequest.setReviewStatus(PictureReviewStatusEnum.PASS.getValue());
|
||||
// pictureQueryRequest.setNullSpaceId(true);
|
||||
// } else {
|
||||
// // 私有空间、团队空间,无需过审
|
||||
// boolean hasPermission = StpKit.SPACE.hasPermission(SpaceUserPermissionConstant.PICTURE_VIEW);
|
||||
// ThrowUtils.throwIf(!hasPermission, ErrorCode.NO_AUTH_ERROR);
|
||||
// //已改为编程式鉴权
|
||||
//// User loginUser = userService.getLoginUser(request);
|
||||
//// Space space = spaceService.getById(spaceId);
|
||||
//// ThrowUtils.throwIf(space == null, ErrorCode.NOT_FOUND_ERROR, "空间不存在");
|
||||
//// if (!loginUser.getId().equals(space.getUserId())) {
|
||||
//// throw new BusinessException(ErrorCode.NO_AUTH_ERROR, "没有空间权限");
|
||||
//// }
|
||||
// }
|
||||
// // 查询数据库
|
||||
// Page<Picture> picturePage = pictureService.page(new Page<>(current, size),
|
||||
// pictureService.getQueryWrapper(pictureQueryRequest));
|
||||
// // 获取封装类
|
||||
// return ResultUtils.success(pictureService.getPictureVOPage(picturePage, request));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 分页获取图片列表(封装类,有缓存)
|
||||
*/
|
||||
@Deprecated
|
||||
@PostMapping("/list/page/vo/cache")
|
||||
@PostMapping("/list/page/vo")
|
||||
public BaseResponse<Page<PictureVO>> listPictureVOByPageWithCache(
|
||||
@RequestBody PictureQueryRequest pictureQueryRequest,
|
||||
HttpServletRequest request) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user