Skip to content

Commit

Permalink
去除redis的新增编辑功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengjie committed Jun 4, 2019
1 parent 2b931a5 commit f9ff6d8
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import java.time.Duration;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@ public ResponseEntity getRedis(String key, Pageable pageable){
return new ResponseEntity(redisService.findByKey(key,pageable), HttpStatus.OK);
}

@Log("新增Redis缓存")
@PostMapping(value = "/redis")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_CREATE')")
public ResponseEntity create(@Validated @RequestBody RedisVo resources){
redisService.save(resources);
return new ResponseEntity(HttpStatus.CREATED);
}

@Log("修改Redis缓存")
@PutMapping(value = "/redis")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_EDIT')")
public ResponseEntity update(@Validated @RequestBody RedisVo resources){
redisService.save(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
}

@Log("删除Redis缓存")
@DeleteMapping(value = "/redis")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_DELETE')")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public interface RedisService {
*/
public Page findByKey(String key, Pageable pageable);

/**
* create
* @param redisVo
*/
public void save(RedisVo redisVo);

/**
* delete
* @param key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -31,6 +29,10 @@ public Page findByKey(String key, Pageable pageable){
key = "*" + key + "*";
}
for (Object s : redisTemplate.keys(key)) {
// 过滤掉权限的缓存
if (s.toString().indexOf("role::loadPermissionByUser") != -1 || s.toString().indexOf("user::loadUserByUsername") != -1) {
continue;
}
RedisVo redisVo = new RedisVo(s.toString(),redisTemplate.opsForValue().get(s.toString()).toString());
redisVos.add(redisVo);
}
Expand All @@ -41,11 +43,6 @@ public Page findByKey(String key, Pageable pageable){
return page;
}

@Override
public void save(RedisVo redisVo) {
redisTemplate.opsForValue().set(redisVo.getKey(),redisVo.getValue());
}

@Override
public void delete(String key) {
redisTemplate.delete(key);
Expand Down
13 changes: 0 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@
</dependency>
<!--Spring boot end-->

<!--jedis-->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>

<!--spring2.0集成redis所需common-pool2-->
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -91,12 +84,6 @@
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>

<!--监控sql日志-->
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
Expand Down

0 comments on commit f9ff6d8

Please sign in to comment.