Commit 7edc80c6 authored by yanzg's avatar yanzg

不记录系统日志

parent b2443702
......@@ -13,10 +13,10 @@
<dependencies>
<!-- 添加springboot对redis的支持 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-data-redis</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-starter-redis-lettuce</artifactId>
......
import com.alicp.jetcache.anno.CacheInvalidate;
import com.alicp.jetcache.anno.CacheUpdate;
import com.alicp.jetcache.anno.Cached;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.stereotype.Component;
@Component
public class TestCache {
@Cached(name = "test.", cacheNullValue = true)
public SecurityProperties.User load(SecurityProperties.User tokenVo) {
return tokenVo;
}
/**
* 保存接口请求日志
*
* @param tokenVo
*/
@CacheUpdate(name = "test.", key = "args[0].token", value = "#tokenVo")
public String save(SecurityProperties.User tokenVo) {
return tokenVo.getName();
}
/**
* 保存接口请求日志
*
* @param tokenVo 请求数据
* @retur 保存主键
*/
@CacheInvalidate(name = "test.", key = "args[0].token")
public int remove(SecurityProperties.User tokenVo) {
return 0;
}
}
import com.tourbida.login.vo.TokenVo;
import com.yanzuoguang.util.vo.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.MediaType;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 颜佐光
*
* @author huangzheng
*/
@RestController
@RequestMapping("/redis")
@Api(value = "测试redis", description = "测试redis")
public class TestController {
@Resource
private RedisTemplate redisTemplate;
@Autowired
private TestCache testCache;
@GetMapping("/setUser")
public String setUser() {
SecurityProperties.User user = new SecurityProperties.User();
user.setName("yanzuoguang");
user.setPassword("123456");
List<String> list = new ArrayList<>();
list.add("小学");
list.add("初中");
list.add("高中");
list.add("大学");
user.setRoles(list);
redisTemplate.opsForValue().set("test.userInfo", user);
return "success";
}
@GetMapping("/getUser")
public SecurityProperties.User getUser() {
return (SecurityProperties.User) redisTemplate.opsForValue().get("test.userInfo");
}
/**
* 测试加载
*
* @return
*/
@PostMapping(value = "/load", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "测试加载", notes = "测试加载")
public ResponseResult<TokenVo> load(@RequestBody TokenVo req) {
return ResponseResult.result(testCache.load(req));
}
/**
* 测试保存
*
* @return
*/
@PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "测试保存", notes = "测试保存")
public ResponseResult<String> save(@RequestBody TokenVo req) {
return ResponseResult.result(testCache.save(req));
}
/**
* 测试删除
*
* @return
*/
@PostMapping(value = "/remove", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ApiOperation(value = "测试删除", notes = "测试删除")
public ResponseResult<Integer> remove(@RequestBody TokenVo req) {
return ResponseResult.result(testCache.remove(req));
}
}
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