53 lines
1.6 KiB
Java
53 lines
1.6 KiB
Java
package com.yutou.tools.utils;
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
@Controller
|
|
public class NasDepotManager {
|
|
private static final String DEPOT_NAME = "nas_depot";
|
|
|
|
@ResponseBody
|
|
@RequestMapping("/nas/depot/add.do")
|
|
public JSONObject addNasPath(String path,String type) {
|
|
JSONObject json=new JSONObject();
|
|
JSONObject item=new JSONObject();
|
|
item.put("path",path);
|
|
item.put("type",type);
|
|
long size=RedisTools.list_add(DEPOT_NAME,item.toJSONString());
|
|
if(size==0){
|
|
json.put("code",0);
|
|
json.put("msg","添加失败");
|
|
}else{
|
|
json.put("code",1);
|
|
json.put("msg","添加成功");
|
|
}
|
|
json.put("data", JSON.toJSON(RedisTools.list_get(DEPOT_NAME)));
|
|
return json;
|
|
|
|
}
|
|
@ResponseBody
|
|
@RequestMapping("/nas/depot/list.do")
|
|
public JSONObject getNasList() {
|
|
JSONObject json=new JSONObject();
|
|
json.put("code",1);
|
|
json.put("msg","ok");
|
|
json.put("data", JSON.toJSON(RedisTools.list_get(DEPOT_NAME)));
|
|
return json;
|
|
}
|
|
@ResponseBody
|
|
@RequestMapping("/nas/depot/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;
|
|
}
|
|
}
|