Commit 0cdf75c5 authored by 郝彦辉's avatar 郝彦辉

方法update_huiTohei_type1

parent 5d9bf11c
...@@ -2,11 +2,20 @@ package cn.quantgroup.qgblservice.controller; ...@@ -2,11 +2,20 @@ package cn.quantgroup.qgblservice.controller;
import cn.quantgroup.qgblservice.response.GlobalResponse; import cn.quantgroup.qgblservice.response.GlobalResponse;
import cn.quantgroup.qgblservice.service.IBlackListToolsManagerService; import cn.quantgroup.qgblservice.service.IBlackListToolsManagerService;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.management.StringValueExp;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/** /**
* -----------------------------------------------------------------------------<br> * -----------------------------------------------------------------------------<br>
* 描述: 黑名单表操作工具类<br> * 描述: 黑名单表操作工具类<br>
...@@ -16,7 +25,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -16,7 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
* 公司: 北京众信利民信息技术有限公司 <br> * 公司: 北京众信利民信息技术有限公司 <br>
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/tools") @RequestMapping("/tools")
public class BlackListToolsManagerController { public class BlackListToolsManagerController {
...@@ -64,4 +73,64 @@ public class BlackListToolsManagerController { ...@@ -64,4 +73,64 @@ public class BlackListToolsManagerController {
} }
} }
@Autowired
private RedisTemplate<String,String> redisTemplate;
@RequestMapping("/deleteRedisKey")
public Map<String,Object> deleteRedisKey(String key1, String key2, String key3){
try{
String full_rediskey = "";
if (org.apache.commons.lang3.StringUtils.isNotEmpty(key1)) {
full_rediskey += key1;
}
if (org.apache.commons.lang3.StringUtils.isNotEmpty(key2)) {
full_rediskey += key2;
}
if (org.apache.commons.lang3.StringUtils.isNotEmpty(key3)) {
full_rediskey += key3;
}
redisTemplate.delete(full_rediskey);
log.info("删除RedisKey成功, key1: {} , key2: {} , key3: {} , full_rediskey: {} ", key1, key2, key3, full_rediskey);
return ImmutableMap.of("code", 0, "msg", "手动删除redisKey成功");
}catch(Exception e){
return ImmutableMap.of("code", 1, "msg", "手动设置redisKey异常");
}
}
@RequestMapping("/getRedisVal")
public String getRedisVal(String key){
try{
Map<String,Object> map = new HashMap<>();
map.put("key",key);
if(org.apache.commons.lang3.StringUtils.isBlank(key)){
return JSONObject.toJSONString(map);
}
try{
String value = redisTemplate.opsForValue().get(key);
Long expire = redisTemplate.getExpire(key);
map.put("value",value);
map.put("expire", expire);
}catch (Exception e){
log.error("获取redis里值异常, key: {} ", key, e);
}
return map.toString();
}catch(Exception e){
return "获取redis值异常";
}
}
@RequestMapping("/setRedisVal")
public String setRedisVal(String key, String value, String tmie){
if(org.apache.commons.lang3.StringUtils.isAnyBlank(key, value, tmie)){
return ImmutableMap.of("code", 1, "msg", "手动设置redisKey参数不能为空").toString();
}
try{
redisTemplate.opsForValue().set(key, value, Long.parseLong(tmie), TimeUnit.MINUTES);
return ImmutableMap.of("code", 0, "msg", "手动设置redisKey成功").toString();
}catch (Exception e){
log.error("获取redis里值异常, key: {} ", key, e);
return ImmutableMap.of("code", 1, "msg", "手动设置redisKey异常").toString();
}
}
} }
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