feat(本地缓存): 加入本地缓存功能
1.项目第一次启动 查数据库 加入redis 加入本地缓存 2.第二次启动 查询redis 加入本地缓存
This commit is contained in:
parent
89f8550dff
commit
a6a12a3b04
|
@ -1,5 +1,6 @@
|
|||
package com.guwan.backend.controller;
|
||||
|
||||
import com.guwan.backend.common.BusinessException;
|
||||
import com.guwan.backend.common.Result;
|
||||
import com.guwan.backend.pojo.entity.BookCategory;
|
||||
import com.guwan.backend.service.BookCategoryService;
|
||||
|
@ -46,8 +47,7 @@ public class BookCategoryController {
|
|||
*/
|
||||
@GetMapping("{id}")
|
||||
public Result<BookCategory> queryById(@PathVariable("id") Integer id) {
|
||||
// return Result.success(this.bookCategoryService.queryById(id));
|
||||
return Result.success();
|
||||
return Result.success(bookCategoryService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +58,11 @@ public class BookCategoryController {
|
|||
*/
|
||||
@PostMapping
|
||||
public Result<BookCategory> add(BookCategory bookCategory) {
|
||||
// return Result.success(this.bookCategoryService.insert(bookCategory));
|
||||
|
||||
if (bookCategoryService.lambdaQuery()
|
||||
.eq(BookCategory::getCategoryName, bookCategory.getCategoryName()).one() != null){
|
||||
throw new BusinessException("该图书种类已经存在");
|
||||
}
|
||||
|
||||
if (bookCategoryService.save(bookCategory)) {
|
||||
return Result.success();
|
||||
|
@ -88,7 +92,7 @@ public class BookCategoryController {
|
|||
*/
|
||||
@DeleteMapping
|
||||
public Result<Boolean> deleteById(Integer id) {
|
||||
// return Result.success(this.bookCategoryService.deleteById(id));
|
||||
bookCategoryService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.guwan.backend.controller.monitor;
|
|||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.stats.CacheStats;
|
||||
import com.guwan.backend.annotation.OperationLog;
|
||||
import com.guwan.backend.common.BusinessException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
@ -25,6 +26,7 @@ public class CacheMonitor {
|
|||
}
|
||||
|
||||
@GetMapping("/stats")
|
||||
@OperationLog(description = "根据名称获取本地缓存使用情况")
|
||||
public Map<String, Object> getStats(String cacheName) {
|
||||
CaffeineCacheManager caffeineCacheManager = (CaffeineCacheManager) cacheManager;
|
||||
Cache<Object, Object> nativeCache = null;
|
||||
|
|
|
@ -200,6 +200,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||
|
||||
|
||||
@Override
|
||||
@OperationLog(description = "修改密码")
|
||||
public void resetPassword(ChangePasswordDTO changePasswordDTO) {
|
||||
|
||||
if(changePasswordDTO.getChangeWay().equals(UserEnums.ACCOUNT.getValue())){
|
||||
|
@ -238,6 +239,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||
}
|
||||
|
||||
@Override
|
||||
@OperationLog(description = "刷新token")
|
||||
public String refreshToken(String token) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@ $!callback.setSavePath($tool.append($tableInfo.savePath, "/controller"))
|
|||
|
||||
#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;
|
||||
|
||||
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};
|
||||
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -57,8 +55,7 @@ public Result<Page<$!{tableInfo.name}>> queryByPage($!{tableInfo.name} $!{tool.f
|
|||
*/
|
||||
@GetMapping("{id}")
|
||||
public Result<$!{tableInfo.name}> queryById(@PathVariable("id") $!pk.shortType id) {
|
||||
// return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.queryById(id));
|
||||
return Result.success();
|
||||
return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +66,7 @@ public Result<$!{tableInfo.name}> queryById(@PathVariable("id") $!pk.shortType i
|
|||
*/
|
||||
@PostMapping
|
||||
public Result<$!{tableInfo.name}> add($!{tableInfo.name} $!{tool.firstLowerCase($tableInfo.name)}) {
|
||||
// return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.insert($!{tool.firstLowerCase($tableInfo.name)}));
|
||||
this.$!{tool.firstLowerCase($tableInfo.name)}Service.save($!{tool.firstLowerCase($tableInfo.name)});
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
@ -93,8 +90,7 @@ public Result<$!{tableInfo.name}> edit($!{tableInfo.name} $!{tool.firstLowerCase
|
|||
*/
|
||||
@DeleteMapping
|
||||
public Result<Boolean> deleteById($!pk.shortType id) {
|
||||
// return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.deleteById(id));
|
||||
return Result.success();
|
||||
return Result.success(this.$!{tool.firstLowerCase($tableInfo.name)}Service.removeById(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue