新增页面

有登陆过滤器
正式上线1.0
This commit is contained in:
2020-05-04 03:26:52 +08:00
parent 6cb1c0f9eb
commit 6627f00d3e
41 changed files with 6561 additions and 129 deletions

View File

@@ -1,25 +0,0 @@
package com.yutou.tools.nas;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.utils.RedisTools;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@Controller
public class AdminManager {
@Resource
RedisTools redisTools;
public String getAdminAddress(HttpServletRequest request){
JSONObject json=new JSONObject();
String address=redisTools.get("adminAddress");
if(address==null){
json.put("code",-1);
json.put("msg","暂未设置管理后台");
}
return json.toJSONString();
}
}

View File

@@ -0,0 +1,148 @@
package com.yutou.tools.nas;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.mybatis.dao.NasAdminAddressDao;
import com.yutou.tools.mybatis.model.NasAdminAddress;
import com.yutou.tools.mybatis.model.NasAdminAddressExample;
import com.yutou.tools.utils.RedisTools;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@Controller
public class NasManager {
@Resource
RedisTools redisTools;
@Resource
NasAdminAddressDao adminAddressDao;
@ResponseBody
@RequestMapping(value = "/auth/nas/address/get.do",method = RequestMethod.GET)
public String getAdminAddress(HttpServletRequest request){
JSONObject json=new JSONObject();
String address=redisTools.get("adminAddress");
if(address==null){
json.put("code",-1);
json.put("msg","暂未设置管理后台");
}else{
JSONObject js=JSONObject.parseObject(address);
json.put("code",0);
json.put("msg","当前状态:"+js.getString("url")+":"+js.getString("port"));
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/auth/nas/address/list.do",method = RequestMethod.GET)
public String addressList(HttpServletRequest request){
JSONObject json =new JSONObject();
try{
List<NasAdminAddress> list=adminAddressDao.selectByExample(new NasAdminAddressExample());
json.put("code",0);
json.put("msg","ok");
json.put("count",list.size());
if(list.size()==0){
json.put("data",new JSONArray());
}else {
json.put("data", JSONArray.toJSON(list));
}
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("count",0);
json.put("msg",e.getMessage());
json.put("data","[]");
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/auth/nas/address/add.do",method = RequestMethod.POST)
public String addAddress(HttpServletRequest request,String url,String port,String title) {
JSONObject json=new JSONObject();
try {
NasAdminAddress address=new NasAdminAddress();
address.setUrl(url);
address.setPort(Integer.parseInt(port));
address.setTitle(title);
adminAddressDao.insert(address);
json.put("code",0);
json.put("msg","ok");
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/auth/nas/address/update.do",method = RequestMethod.POST)
public String updateAddress(HttpServletRequest request,String url,String port,String title,String id){
JSONObject json=new JSONObject();
try {
NasAdminAddress address=adminAddressDao.selectByPrimaryKey(Integer.parseInt(id));
if(address!=null) {
if (!StringUtils.isEmpty(url)) {
address.setUrl(url);
}
if (!StringUtils.isEmpty(port)) {
address.setPort(Integer.parseInt(port));
}
if (!StringUtils.isEmpty(title)) {
address.setTitle(title);
}
adminAddressDao.updateByPrimaryKey(address);
json.put("code",0);
json.put("msg","ok");
}else {
json.put("code",1);
json.put("msg","无更新");
}
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/auth/nas/address/remove.do",method = RequestMethod.POST)
public String removeAddress(HttpServletRequest request,String id){
JSONObject json=new JSONObject();
try{
int code=adminAddressDao.deleteByPrimaryKey(Integer.parseInt(id));
json.put("code",code);
json.put("msg","ok");
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/auth/nas/address/set.do",method = RequestMethod.POST)
public String setAddress(HttpServletRequest request,String id){
JSONObject json=new JSONObject();
try {
NasAdminAddress address=adminAddressDao.selectByPrimaryKey(Integer.parseInt(id));
if(address!=null){
redisTools.set("adminAddress",JSONObject.toJSONString(address));
}
json.put("code",0);
json.put("msg","ok");
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
}

View File

@@ -88,7 +88,7 @@ public class UpdateIp {
}
updateList();
File file = new File("/etc/nginx/nginx.conf");
file = new File("D:\\nginx.conf");
//file = new File("D:\\nginx.conf");
if (file.exists()) {
String testIp = "0.0.0.0";
try {