新增控制nas上传oss的入口

This commit is contained in:
yutou 2021-06-09 18:29:57 +08:00
parent b714eebaa5
commit 5cbe9af85e
2 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,49 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/nas/depot/")
public class NasDepotManager {
private static final String DEPOT_NAME = "nas_depot";
@ResponseBody
@RequestMapping("/add.do")
public JSONObject addNasPath(String path) {
JSONObject json=new JSONObject();
long size=RedisTools.list_add(DEPOT_NAME, path);
if(size==0){
json.put("code",0);
json.put("msg","添加失败");
}else{
json.put("code",1);
json.put("msg","添加成功");
}
json.put("data", JSONArray.toJSON(RedisTools.list_get(DEPOT_NAME)));
return json;
}
@ResponseBody
@RequestMapping("/list.do")
public JSONObject getNasList() {
JSONObject json=new JSONObject();
json.put("code",1);
json.put("msg","ok");
json.put("data", JSONArray.toJSON(RedisTools.list_get(DEPOT_NAME)));
return json;
}
@ResponseBody
@RequestMapping("/remove.do")
public JSONObject removeNas(String path) {
JSONObject json=new JSONObject();
json.put("code",1);
json.put("msg","ok");
json.put("data", RedisTools.list_remove(DEPOT_NAME, path));
return json;
}
}

View File

@ -4,6 +4,7 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
@ -146,6 +147,33 @@ public class RedisTools {
} }
} }
public static long list_add(String listName, String... value) {
Jedis jedis=getRedis();
long index=jedis.sadd(listName,value);
jedis.close();
return index;
}
public static Set<String> list_get(String listName){
Jedis jedis=getRedis();
Set<String> set=jedis.smembers(listName);
jedis.close();
if(set==null){
set=new HashSet<>();
}
return set;
}
public static boolean list_remove(String listName,String... value){
Jedis jedis=getRedis();
long index=jedis.srem(listName,value);
jedis.close();
return index != 0;
}
public static boolean list_isExist(String listName,String value){
Jedis jedis=getRedis();
boolean flag=jedis.sismember(listName,value);
jedis.close();
return flag;
}
private static class PropertyUtil { private static class PropertyUtil {
// 加载property文件到io流里面 // 加载property文件到io流里面