Commit b2e98322 authored by tangtuo's avatar tangtuo

类目|主题等加入缓存

parent edff9f7d
...@@ -30,6 +30,6 @@ public class CategoryController { ...@@ -30,6 +30,6 @@ public class CategoryController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value = "查询所有类目信息") @ApiOperation(value = "查询所有类目信息")
public ResponseModel<List<Category>> list() { public ResponseModel<List<Category>> list() {
return ResponseModel.success(categoryService.list()); return ResponseModel.success(categoryService.listAll());
} }
} }
...@@ -30,6 +30,6 @@ public class LabelController { ...@@ -30,6 +30,6 @@ public class LabelController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value = "查询所有标签信息") @ApiOperation(value = "查询所有标签信息")
public ResponseModel<List<Label>> list() { public ResponseModel<List<Label>> list() {
return ResponseModel.success(labelService.list()); return ResponseModel.success(labelService.listAll());
} }
} }
...@@ -3,6 +3,8 @@ package com.fzm.common.service; ...@@ -3,6 +3,8 @@ package com.fzm.common.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.Category; import com.fzm.common.entity.Category;
import java.util.List;
/** /**
* @author tangtuo * @author tangtuo
* @date 2021/7/1 14:35 * @date 2021/7/1 14:35
...@@ -10,4 +12,7 @@ import com.fzm.common.entity.Category; ...@@ -10,4 +12,7 @@ import com.fzm.common.entity.Category;
public interface CategoryService extends IService<Category> { public interface CategoryService extends IService<Category> {
Category getCategoryById(Integer categoryId); Category getCategoryById(Integer categoryId);
List<Category> listAll();
} }
...@@ -4,10 +4,14 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -4,10 +4,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.common.entity.Category; import com.fzm.common.entity.Category;
import com.fzm.common.entity.Label; import com.fzm.common.entity.Label;
import java.util.List;
/** /**
* @author tangtuo * @author tangtuo
* @date 2021/7/1 14:35 * @date 2021/7/1 14:35
*/ */
public interface LabelService extends IService<Label> { public interface LabelService extends IService<Label> {
List<Label> listAll();
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.common.entity.Category; import com.fzm.common.entity.Category;
import com.fzm.common.mapper.CategoryMapper; import com.fzm.common.mapper.CategoryMapper;
import com.fzm.common.service.CategoryService; import com.fzm.common.service.CategoryService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -25,4 +26,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i ...@@ -25,4 +26,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
} }
return null; return null;
} }
@Override
@Cacheable(value = "category", key = "'list'")
public List<Category> listAll() {
return list();
}
} }
...@@ -7,6 +7,7 @@ import com.fzm.common.mapper.CategoryMapper; ...@@ -7,6 +7,7 @@ import com.fzm.common.mapper.CategoryMapper;
import com.fzm.common.mapper.LabelMapper; import com.fzm.common.mapper.LabelMapper;
import com.fzm.common.service.CategoryService; import com.fzm.common.service.CategoryService;
import com.fzm.common.service.LabelService; import com.fzm.common.service.LabelService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -18,4 +19,10 @@ import java.util.List; ...@@ -18,4 +19,10 @@ import java.util.List;
@Service @Service
public class LabelServiceImpl extends ServiceImpl<LabelMapper, Label> implements LabelService { public class LabelServiceImpl extends ServiceImpl<LabelMapper, Label> implements LabelService {
@Override
@Cacheable(value = "label",key = "'list'")
public List<Label> listAll() {
return list();
}
} }
...@@ -27,6 +27,6 @@ public class CategoryController { ...@@ -27,6 +27,6 @@ public class CategoryController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value = "查询所有类目信息") @ApiOperation(value = "查询所有类目信息")
public ResponseModel<List<Category>> list() { public ResponseModel<List<Category>> list() {
return ResponseModel.success(categoryService.list()); return ResponseModel.success(categoryService.listAll());
} }
} }
...@@ -29,6 +29,6 @@ public class LabelController { ...@@ -29,6 +29,6 @@ public class LabelController {
@GetMapping("/list") @GetMapping("/list")
@ApiOperation(value = "查询所有主题信息") @ApiOperation(value = "查询所有主题信息")
public ResponseModel<List<Label>> list() { public ResponseModel<List<Label>> list() {
return ResponseModel.success(labelService.list()); return ResponseModel.success(labelService.listAll());
} }
} }
...@@ -21,6 +21,7 @@ import com.fzm.common.utils.QRCodeUtil; ...@@ -21,6 +21,7 @@ import com.fzm.common.utils.QRCodeUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -36,6 +37,7 @@ import java.util.stream.Collectors; ...@@ -36,6 +37,7 @@ import java.util.stream.Collectors;
* @author tangtuo * @author tangtuo
* @date 2021/6/30 15:08 * @date 2021/6/30 15:08
*/ */
@Slf4j
@RestController @RestController
@RequestMapping(value = "/nft") @RequestMapping(value = "/nft")
@Api(tags = "nft管理") @Api(tags = "nft管理")
...@@ -79,10 +81,14 @@ public class NftController { ...@@ -79,10 +81,14 @@ public class NftController {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "当选择加密存档的时候,文件和授权阅读不能为空"); throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "当选择加密存档的时候,文件和授权阅读不能为空");
} }
// 判断文件的hash是否被篡改过 // 判断文件的hash是否被篡改过
log.info("verify fileHash start");
if (!SecureUtil.md5(file.getInputStream()).equals(fileHash)) { if (!SecureUtil.md5(file.getInputStream()).equals(fileHash)) {
throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "文件hash和文件内容不匹配"); throw GlobalException.newException(ResultCode.VALIDATE_FAILED, "文件hash和文件内容不匹配");
} }
log.info("verify fileHash end");
log.info("upload file start");
String fileUrl = ossUtil.putEncryptObject(file); String fileUrl = ossUtil.putEncryptObject(file);
log.info("upload file end");
nft.setFileUrl(fileUrl).setIsGrant(isGrant).setFileName(file.getOriginalFilename()); nft.setFileUrl(fileUrl).setIsGrant(isGrant).setFileName(file.getOriginalFilename());
} }
nft.setCategoryId(categoryId) nft.setCategoryId(categoryId)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment