新增页面

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

View File

@ -10,7 +10,7 @@
</parent> </parent>
<groupId>com.yutou</groupId> <groupId>com.yutou</groupId>
<artifactId>tools</artifactId> <artifactId>tools</artifactId>
<version>1.0.3</version> <version>1.0.4</version>
<name>tools</name> <name>tools</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>

View File

@ -7,6 +7,7 @@ import com.yutou.tools.mybatis.model.BilibiliLive;
import com.yutou.tools.mybatis.model.BilibiliLiveExample; import com.yutou.tools.mybatis.model.BilibiliLiveExample;
import com.yutou.tools.utils.RedisTools; import com.yutou.tools.utils.RedisTools;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
@ -56,4 +57,45 @@ public class Live {
json.put("data",JSONArray.toJSON(list)); json.put("data",JSONArray.toJSON(list));
return json.toJSONString(); return json.toJSONString();
} }
@ResponseBody
@RequestMapping("set/update.do")
public String configDown(String id,String url,String cid,String status){
JSONObject json=new JSONObject();
BilibiliLive live=bilibiliLiveDao.selectByPrimaryKey(Integer.parseInt(id));
if(!StringUtils.isEmpty(url)){
if(url.startsWith("https://")){
cid=url.replace("https://live.bilibili.com/","").split("\\?")[0];
}else{
cid=url;
url="https://live.bilibili.com/"+cid;
}
live.setUrl(url);
live.setCid(Integer.parseInt(cid));
}
if(!StringUtils.isEmpty(cid)){
live.setCid(Integer.parseInt(cid));
}
if(!StringUtils.isEmpty(status)){
live.setStatus(Integer.parseInt(status));
}
int code=bilibiliLiveDao.updateByPrimaryKey(live);
json.put("code",code);
json.put("msg","ok");
return json.toJSONString();
}
@ResponseBody
@RequestMapping("set/delete.do")
public String delUrl(String id){
JSONObject json=new JSONObject();
try{
int code=bilibiliLiveDao.deleteByPrimaryKey(Integer.parseInt(id));
json.put("code",code);
json.put("msg","ret "+code);
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
} }

View File

@ -0,0 +1,196 @@
package com.yutou.tools.Tools;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.mybatis.dao.ToolsPasswordDao;
import com.yutou.tools.mybatis.dao.ToolsPasswordTypeDao;
import com.yutou.tools.mybatis.model.ToolsPassword;
import com.yutou.tools.mybatis.model.ToolsPasswordExample;
import com.yutou.tools.mybatis.model.ToolsPasswordType;
import com.yutou.tools.mybatis.model.ToolsPasswordTypeExample;
import com.yutou.tools.utils.AESTools;
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 java.util.List;
@Controller
@RequestMapping("/tools/password/")
public class PasswordManager {
@Resource
ToolsPasswordDao passwordDao;
@Resource
ToolsPasswordTypeDao passwordTypeDao;
@ResponseBody
@RequestMapping(value = "get/list.do",method = RequestMethod.GET)
public String getPasswordList(String type){
JSONObject json=new JSONObject();
ToolsPasswordExample example=new ToolsPasswordExample();
example.createCriteria().andTypeEqualTo(Integer.parseInt(type));
List<ToolsPassword> passwords=passwordDao.selectByExample(example);
for (ToolsPassword password : passwords) {
password.setPassword("*****");
}
json.put("code",0);
json.put("msg","ok");
json.put("data", JSONArray.toJSON(passwords));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "get/password.do",method = RequestMethod.GET)
public String getPassword(String id){
JSONObject json=new JSONObject();
ToolsPassword password=passwordDao.selectByPrimaryKey(Integer.parseInt(id));
json.put("code",0);
json.put("data",AESTools.decrypt(password.getPassword()));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "type/get/list.do",method = RequestMethod.GET)
public String getPasswordType(){
JSONObject json=new JSONObject();
List<ToolsPasswordType> toolsPasswordTypes=passwordTypeDao.selectByExample(new ToolsPasswordTypeExample());
json.put("code",0);
json.put("msg","ok");
json.put("data", JSONArray.toJSON(toolsPasswordTypes));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "type/set/add.do",method = RequestMethod.POST)
public String addPasswordType(String type){
JSONObject json=new JSONObject();
try{
ToolsPasswordType passwordType=new ToolsPasswordType();
passwordType.setTitle(type);
int code=passwordTypeDao.insert(passwordType);
json.put("code",0);
json.put("msg","修改结果:"+code);
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "set/add.do",method = RequestMethod.POST)
public String addPassword(String title,String username,String password,String url,String info,String type){
JSONObject json=new JSONObject();
try{
if(StringUtils.isEmpty(title)||StringUtils.isEmpty(username)||StringUtils.isEmpty(password)||StringUtils.isEmpty(type)){
json.put("code",-1);
json.put("msg","有参数为空");
return json.toJSONString();
}
ToolsPassword toolsPassword=new ToolsPassword();
toolsPassword.setTitle(title);
toolsPassword.setUsername(username);
toolsPassword.setPassword(AESTools.encrypt(password));
toolsPassword.setType(Integer.parseInt(type));
if(url!=null){
toolsPassword.setUrl(url);
}
if(info!=null){
toolsPassword.setInfo(info);
}
int code=passwordDao.insert(toolsPassword);
json.put("code",0);
json.put("msg","添加结果:"+code);
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "set/update.do",method = RequestMethod.POST)
public String updatePassword(String title,String username,String password,String url,String info,String id){
JSONObject json=new JSONObject();
try{
ToolsPassword toolsPassword=passwordDao.selectByPrimaryKey(Integer.parseInt(id));
if(!StringUtils.isEmpty(title)){
toolsPassword.setTitle(title);
}
if(!StringUtils.isEmpty(username)){
toolsPassword.setUsername(username);
}
if(!StringUtils.isEmpty(password)){
toolsPassword.setPassword(AESTools.encrypt(password));
}
if(!StringUtils.isEmpty(url)){
toolsPassword.setUrl(url);
}
if(!StringUtils.isEmpty(info)){
toolsPassword.setInfo(info);
}
int code=passwordDao.updateByPrimaryKey(toolsPassword);
json.put("code",0);
json.put("msg","修改结果:"+code);
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "type/set/update.do",method = RequestMethod.POST)
public String updatePasswordType(String type,String id){
JSONObject json=new JSONObject();
try {
ToolsPasswordType passwordType=passwordTypeDao.selectByPrimaryKey(Integer.parseInt(id));
if(!StringUtils.isEmpty(type)){
passwordType.setTitle(type);
}
int code=passwordTypeDao.updateByPrimaryKey(passwordType);
json.put("code",0);
json.put("msg","修改结果:"+code);
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "set/remove.do",method = RequestMethod.POST)
public String removePassword(String id){
JSONObject json=new JSONObject();
try {
int code=passwordDao.deleteByPrimaryKey(Integer.parseInt(id));
json.put("code",0);
json.put("msg","删除结果:"+code);
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "type/set/remove.do",method = RequestMethod.POST)
public String removePasswordType(String id){
JSONObject json=new JSONObject();
try {
ToolsPasswordExample example=new ToolsPasswordExample();
example.createCriteria().andTypeEqualTo(Integer.parseInt(id));
int passwordCode=passwordDao.deleteByExample(example);
System.out.println("删除结果:"+passwordCode);
int code=passwordTypeDao.deleteByPrimaryKey(Integer.parseInt(id));
json.put("code",0);
json.put("msg","删除结果:"+code);
}catch (Exception e){
e.printStackTrace();
json.put("code",-1);
json.put("msg",e.getMessage());
}
return json.toJSONString();
}
}

View File

@ -0,0 +1,33 @@
package com.yutou.tools.mybatis.dao;
import com.yutou.tools.mybatis.model.NasAdminAddress;
import com.yutou.tools.mybatis.model.NasAdminAddressExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface NasAdminAddressDao {
long countByExample(NasAdminAddressExample example);
int deleteByExample(NasAdminAddressExample example);
int deleteByPrimaryKey(Integer id);
int insert(NasAdminAddress record);
int insertSelective(NasAdminAddress record);
List<NasAdminAddress> selectByExample(NasAdminAddressExample example);
NasAdminAddress selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") NasAdminAddress record, @Param("example") NasAdminAddressExample example);
int updateByExample(@Param("record") NasAdminAddress record, @Param("example") NasAdminAddressExample example);
int updateByPrimaryKeySelective(NasAdminAddress record);
int updateByPrimaryKey(NasAdminAddress record);
}

View File

@ -0,0 +1,33 @@
package com.yutou.tools.mybatis.dao;
import com.yutou.tools.mybatis.model.ToolsPassword;
import com.yutou.tools.mybatis.model.ToolsPasswordExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ToolsPasswordDao {
long countByExample(ToolsPasswordExample example);
int deleteByExample(ToolsPasswordExample example);
int deleteByPrimaryKey(Integer id);
int insert(ToolsPassword record);
int insertSelective(ToolsPassword record);
List<ToolsPassword> selectByExample(ToolsPasswordExample example);
ToolsPassword selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") ToolsPassword record, @Param("example") ToolsPasswordExample example);
int updateByExample(@Param("record") ToolsPassword record, @Param("example") ToolsPasswordExample example);
int updateByPrimaryKeySelective(ToolsPassword record);
int updateByPrimaryKey(ToolsPassword record);
}

View File

@ -0,0 +1,33 @@
package com.yutou.tools.mybatis.dao;
import com.yutou.tools.mybatis.model.ToolsPasswordType;
import com.yutou.tools.mybatis.model.ToolsPasswordTypeExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ToolsPasswordTypeDao {
long countByExample(ToolsPasswordTypeExample example);
int deleteByExample(ToolsPasswordTypeExample example);
int deleteByPrimaryKey(Integer id);
int insert(ToolsPasswordType record);
int insertSelective(ToolsPasswordType record);
List<ToolsPasswordType> selectByExample(ToolsPasswordTypeExample example);
ToolsPasswordType selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") ToolsPasswordType record, @Param("example") ToolsPasswordTypeExample example);
int updateByExample(@Param("record") ToolsPasswordType record, @Param("example") ToolsPasswordTypeExample example);
int updateByPrimaryKeySelective(ToolsPasswordType record);
int updateByPrimaryKey(ToolsPasswordType record);
}

View File

@ -0,0 +1,23 @@
package com.yutou.tools.mybatis.model;
import java.io.Serializable;
import lombok.Data;
/**
* nas_admin_address
* @author
*/
@Data
public class NasAdminAddress implements Serializable {
private Integer id;
private String title;
private String url;
private Integer port;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,461 @@
package com.yutou.tools.mybatis.model;
import java.util.ArrayList;
import java.util.List;
public class NasAdminAddressExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public NasAdminAddressExample() {
oredCriteria = new ArrayList<>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTitleIsNull() {
addCriterion("title is null");
return (Criteria) this;
}
public Criteria andTitleIsNotNull() {
addCriterion("title is not null");
return (Criteria) this;
}
public Criteria andTitleEqualTo(String value) {
addCriterion("title =", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotEqualTo(String value) {
addCriterion("title <>", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThan(String value) {
addCriterion("title >", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThanOrEqualTo(String value) {
addCriterion("title >=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThan(String value) {
addCriterion("title <", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThanOrEqualTo(String value) {
addCriterion("title <=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLike(String value) {
addCriterion("title like", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotLike(String value) {
addCriterion("title not like", value, "title");
return (Criteria) this;
}
public Criteria andTitleIn(List<String> values) {
addCriterion("title in", values, "title");
return (Criteria) this;
}
public Criteria andTitleNotIn(List<String> values) {
addCriterion("title not in", values, "title");
return (Criteria) this;
}
public Criteria andTitleBetween(String value1, String value2) {
addCriterion("title between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andTitleNotBetween(String value1, String value2) {
addCriterion("title not between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andUrlIsNull() {
addCriterion("url is null");
return (Criteria) this;
}
public Criteria andUrlIsNotNull() {
addCriterion("url is not null");
return (Criteria) this;
}
public Criteria andUrlEqualTo(String value) {
addCriterion("url =", value, "url");
return (Criteria) this;
}
public Criteria andUrlNotEqualTo(String value) {
addCriterion("url <>", value, "url");
return (Criteria) this;
}
public Criteria andUrlGreaterThan(String value) {
addCriterion("url >", value, "url");
return (Criteria) this;
}
public Criteria andUrlGreaterThanOrEqualTo(String value) {
addCriterion("url >=", value, "url");
return (Criteria) this;
}
public Criteria andUrlLessThan(String value) {
addCriterion("url <", value, "url");
return (Criteria) this;
}
public Criteria andUrlLessThanOrEqualTo(String value) {
addCriterion("url <=", value, "url");
return (Criteria) this;
}
public Criteria andUrlLike(String value) {
addCriterion("url like", value, "url");
return (Criteria) this;
}
public Criteria andUrlNotLike(String value) {
addCriterion("url not like", value, "url");
return (Criteria) this;
}
public Criteria andUrlIn(List<String> values) {
addCriterion("url in", values, "url");
return (Criteria) this;
}
public Criteria andUrlNotIn(List<String> values) {
addCriterion("url not in", values, "url");
return (Criteria) this;
}
public Criteria andUrlBetween(String value1, String value2) {
addCriterion("url between", value1, value2, "url");
return (Criteria) this;
}
public Criteria andUrlNotBetween(String value1, String value2) {
addCriterion("url not between", value1, value2, "url");
return (Criteria) this;
}
public Criteria andPortIsNull() {
addCriterion("port is null");
return (Criteria) this;
}
public Criteria andPortIsNotNull() {
addCriterion("port is not null");
return (Criteria) this;
}
public Criteria andPortEqualTo(Integer value) {
addCriterion("port =", value, "port");
return (Criteria) this;
}
public Criteria andPortNotEqualTo(Integer value) {
addCriterion("port <>", value, "port");
return (Criteria) this;
}
public Criteria andPortGreaterThan(Integer value) {
addCriterion("port >", value, "port");
return (Criteria) this;
}
public Criteria andPortGreaterThanOrEqualTo(Integer value) {
addCriterion("port >=", value, "port");
return (Criteria) this;
}
public Criteria andPortLessThan(Integer value) {
addCriterion("port <", value, "port");
return (Criteria) this;
}
public Criteria andPortLessThanOrEqualTo(Integer value) {
addCriterion("port <=", value, "port");
return (Criteria) this;
}
public Criteria andPortIn(List<Integer> values) {
addCriterion("port in", values, "port");
return (Criteria) this;
}
public Criteria andPortNotIn(List<Integer> values) {
addCriterion("port not in", values, "port");
return (Criteria) this;
}
public Criteria andPortBetween(Integer value1, Integer value2) {
addCriterion("port between", value1, value2, "port");
return (Criteria) this;
}
public Criteria andPortNotBetween(Integer value1, Integer value2) {
addCriterion("port not between", value1, value2, "port");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,27 @@
package com.yutou.tools.mybatis.model;
import java.io.Serializable;
import lombok.Data;
/**
* tools_password
* @author
*/
@Data
public class ToolsPassword implements Serializable {
private Integer id;
private String title;
private String username;
private String password;
private String url;
private String info;
private Integer type;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,671 @@
package com.yutou.tools.mybatis.model;
import java.util.ArrayList;
import java.util.List;
public class ToolsPasswordExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public ToolsPasswordExample() {
oredCriteria = new ArrayList<>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTitleIsNull() {
addCriterion("title is null");
return (Criteria) this;
}
public Criteria andTitleIsNotNull() {
addCriterion("title is not null");
return (Criteria) this;
}
public Criteria andTitleEqualTo(String value) {
addCriterion("title =", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotEqualTo(String value) {
addCriterion("title <>", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThan(String value) {
addCriterion("title >", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThanOrEqualTo(String value) {
addCriterion("title >=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThan(String value) {
addCriterion("title <", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThanOrEqualTo(String value) {
addCriterion("title <=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLike(String value) {
addCriterion("title like", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotLike(String value) {
addCriterion("title not like", value, "title");
return (Criteria) this;
}
public Criteria andTitleIn(List<String> values) {
addCriterion("title in", values, "title");
return (Criteria) this;
}
public Criteria andTitleNotIn(List<String> values) {
addCriterion("title not in", values, "title");
return (Criteria) this;
}
public Criteria andTitleBetween(String value1, String value2) {
addCriterion("title between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andTitleNotBetween(String value1, String value2) {
addCriterion("title not between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andUsernameIsNull() {
addCriterion("username is null");
return (Criteria) this;
}
public Criteria andUsernameIsNotNull() {
addCriterion("username is not null");
return (Criteria) this;
}
public Criteria andUsernameEqualTo(String value) {
addCriterion("username =", value, "username");
return (Criteria) this;
}
public Criteria andUsernameNotEqualTo(String value) {
addCriterion("username <>", value, "username");
return (Criteria) this;
}
public Criteria andUsernameGreaterThan(String value) {
addCriterion("username >", value, "username");
return (Criteria) this;
}
public Criteria andUsernameGreaterThanOrEqualTo(String value) {
addCriterion("username >=", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLessThan(String value) {
addCriterion("username <", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLessThanOrEqualTo(String value) {
addCriterion("username <=", value, "username");
return (Criteria) this;
}
public Criteria andUsernameLike(String value) {
addCriterion("username like", value, "username");
return (Criteria) this;
}
public Criteria andUsernameNotLike(String value) {
addCriterion("username not like", value, "username");
return (Criteria) this;
}
public Criteria andUsernameIn(List<String> values) {
addCriterion("username in", values, "username");
return (Criteria) this;
}
public Criteria andUsernameNotIn(List<String> values) {
addCriterion("username not in", values, "username");
return (Criteria) this;
}
public Criteria andUsernameBetween(String value1, String value2) {
addCriterion("username between", value1, value2, "username");
return (Criteria) this;
}
public Criteria andUsernameNotBetween(String value1, String value2) {
addCriterion("username not between", value1, value2, "username");
return (Criteria) this;
}
public Criteria andPasswordIsNull() {
addCriterion("`password` is null");
return (Criteria) this;
}
public Criteria andPasswordIsNotNull() {
addCriterion("`password` is not null");
return (Criteria) this;
}
public Criteria andPasswordEqualTo(String value) {
addCriterion("`password` =", value, "password");
return (Criteria) this;
}
public Criteria andPasswordNotEqualTo(String value) {
addCriterion("`password` <>", value, "password");
return (Criteria) this;
}
public Criteria andPasswordGreaterThan(String value) {
addCriterion("`password` >", value, "password");
return (Criteria) this;
}
public Criteria andPasswordGreaterThanOrEqualTo(String value) {
addCriterion("`password` >=", value, "password");
return (Criteria) this;
}
public Criteria andPasswordLessThan(String value) {
addCriterion("`password` <", value, "password");
return (Criteria) this;
}
public Criteria andPasswordLessThanOrEqualTo(String value) {
addCriterion("`password` <=", value, "password");
return (Criteria) this;
}
public Criteria andPasswordLike(String value) {
addCriterion("`password` like", value, "password");
return (Criteria) this;
}
public Criteria andPasswordNotLike(String value) {
addCriterion("`password` not like", value, "password");
return (Criteria) this;
}
public Criteria andPasswordIn(List<String> values) {
addCriterion("`password` in", values, "password");
return (Criteria) this;
}
public Criteria andPasswordNotIn(List<String> values) {
addCriterion("`password` not in", values, "password");
return (Criteria) this;
}
public Criteria andPasswordBetween(String value1, String value2) {
addCriterion("`password` between", value1, value2, "password");
return (Criteria) this;
}
public Criteria andPasswordNotBetween(String value1, String value2) {
addCriterion("`password` not between", value1, value2, "password");
return (Criteria) this;
}
public Criteria andUrlIsNull() {
addCriterion("url is null");
return (Criteria) this;
}
public Criteria andUrlIsNotNull() {
addCriterion("url is not null");
return (Criteria) this;
}
public Criteria andUrlEqualTo(String value) {
addCriterion("url =", value, "url");
return (Criteria) this;
}
public Criteria andUrlNotEqualTo(String value) {
addCriterion("url <>", value, "url");
return (Criteria) this;
}
public Criteria andUrlGreaterThan(String value) {
addCriterion("url >", value, "url");
return (Criteria) this;
}
public Criteria andUrlGreaterThanOrEqualTo(String value) {
addCriterion("url >=", value, "url");
return (Criteria) this;
}
public Criteria andUrlLessThan(String value) {
addCriterion("url <", value, "url");
return (Criteria) this;
}
public Criteria andUrlLessThanOrEqualTo(String value) {
addCriterion("url <=", value, "url");
return (Criteria) this;
}
public Criteria andUrlLike(String value) {
addCriterion("url like", value, "url");
return (Criteria) this;
}
public Criteria andUrlNotLike(String value) {
addCriterion("url not like", value, "url");
return (Criteria) this;
}
public Criteria andUrlIn(List<String> values) {
addCriterion("url in", values, "url");
return (Criteria) this;
}
public Criteria andUrlNotIn(List<String> values) {
addCriterion("url not in", values, "url");
return (Criteria) this;
}
public Criteria andUrlBetween(String value1, String value2) {
addCriterion("url between", value1, value2, "url");
return (Criteria) this;
}
public Criteria andUrlNotBetween(String value1, String value2) {
addCriterion("url not between", value1, value2, "url");
return (Criteria) this;
}
public Criteria andInfoIsNull() {
addCriterion("info is null");
return (Criteria) this;
}
public Criteria andInfoIsNotNull() {
addCriterion("info is not null");
return (Criteria) this;
}
public Criteria andInfoEqualTo(String value) {
addCriterion("info =", value, "info");
return (Criteria) this;
}
public Criteria andInfoNotEqualTo(String value) {
addCriterion("info <>", value, "info");
return (Criteria) this;
}
public Criteria andInfoGreaterThan(String value) {
addCriterion("info >", value, "info");
return (Criteria) this;
}
public Criteria andInfoGreaterThanOrEqualTo(String value) {
addCriterion("info >=", value, "info");
return (Criteria) this;
}
public Criteria andInfoLessThan(String value) {
addCriterion("info <", value, "info");
return (Criteria) this;
}
public Criteria andInfoLessThanOrEqualTo(String value) {
addCriterion("info <=", value, "info");
return (Criteria) this;
}
public Criteria andInfoLike(String value) {
addCriterion("info like", value, "info");
return (Criteria) this;
}
public Criteria andInfoNotLike(String value) {
addCriterion("info not like", value, "info");
return (Criteria) this;
}
public Criteria andInfoIn(List<String> values) {
addCriterion("info in", values, "info");
return (Criteria) this;
}
public Criteria andInfoNotIn(List<String> values) {
addCriterion("info not in", values, "info");
return (Criteria) this;
}
public Criteria andInfoBetween(String value1, String value2) {
addCriterion("info between", value1, value2, "info");
return (Criteria) this;
}
public Criteria andInfoNotBetween(String value1, String value2) {
addCriterion("info not between", value1, value2, "info");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Integer value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Integer value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Integer> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

View File

@ -0,0 +1,17 @@
package com.yutou.tools.mybatis.model;
import java.io.Serializable;
import lombok.Data;
/**
* tools_password_type
* @author
*/
@Data
public class ToolsPasswordType implements Serializable {
private Integer id;
private String title;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,331 @@
package com.yutou.tools.mybatis.model;
import java.util.ArrayList;
import java.util.List;
public class ToolsPasswordTypeExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public ToolsPasswordTypeExample() {
oredCriteria = new ArrayList<>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andTitleIsNull() {
addCriterion("title is null");
return (Criteria) this;
}
public Criteria andTitleIsNotNull() {
addCriterion("title is not null");
return (Criteria) this;
}
public Criteria andTitleEqualTo(String value) {
addCriterion("title =", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotEqualTo(String value) {
addCriterion("title <>", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThan(String value) {
addCriterion("title >", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThanOrEqualTo(String value) {
addCriterion("title >=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThan(String value) {
addCriterion("title <", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThanOrEqualTo(String value) {
addCriterion("title <=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLike(String value) {
addCriterion("title like", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotLike(String value) {
addCriterion("title not like", value, "title");
return (Criteria) this;
}
public Criteria andTitleIn(List<String> values) {
addCriterion("title in", values, "title");
return (Criteria) this;
}
public Criteria andTitleNotIn(List<String> values) {
addCriterion("title not in", values, "title");
return (Criteria) this;
}
public Criteria andTitleBetween(String value1, String value2) {
addCriterion("title between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andTitleNotBetween(String value1, String value2) {
addCriterion("title not between", value1, value2, "title");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

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(); updateList();
File file = new File("/etc/nginx/nginx.conf"); File file = new File("/etc/nginx/nginx.conf");
file = new File("D:\\nginx.conf"); //file = new File("D:\\nginx.conf");
if (file.exists()) { if (file.exists()) {
String testIp = "0.0.0.0"; String testIp = "0.0.0.0";
try { try {

View File

@ -0,0 +1,52 @@
package com.yutou.tools.utils;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class AESTools {
private static final String key="fJjSoOM7tDIQN0Ne";
private static final String model="AES/ECB/PKCS5Padding";
/**
* 加密
* @param value 原文
* @return 密文
*/
public static String encrypt(String value){
try {
KeyGenerator generator=KeyGenerator.getInstance("AES");
generator.init(128);
Cipher cipher=Cipher.getInstance(model);
cipher.init(Cipher.ENCRYPT_MODE,new SecretKeySpec(key.getBytes(),"AES"));
byte[] bytes=cipher.doFinal(value.getBytes(StandardCharsets.UTF_8));
return new String(Base64.getEncoder().encode(bytes));
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 解密
* @param value 密文
* @return 原文
*/
public static String decrypt(String value){
try {
KeyGenerator generator=KeyGenerator.getInstance("AES");
generator.init(128);
Cipher cipher=Cipher.getInstance(model);
cipher.init(Cipher.DECRYPT_MODE,new SecretKeySpec(key.getBytes(),"AES"));
byte[] encodeBytes=Base64.getDecoder().decode(value);
byte[] bytes=cipher.doFinal(encodeBytes);
return new String(bytes);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -1,11 +1,14 @@
package com.yutou.tools.utils; package com.yutou.tools.utils;
import com.yutou.tools.mybatis.dao.UKeyDao; import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.UKeyExample;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.annotation.WebFilter; import javax.servlet.annotation.WebFilter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
@ -18,19 +21,39 @@ public class APIFilter implements Filter {
UKeyDao keyDao; UKeyDao keyDao;
@Resource @Resource
RedisTools redisTools; RedisTools redisTools;
@Override @Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request= (HttpServletRequest) servletRequest; HttpServletRequest request = (HttpServletRequest) servletRequest;
String token=request.getParameter("token"); HttpServletResponse response= (HttpServletResponse) servletResponse;
System.out.println("接收到请求:"+request.getRequestURI()+" "+token); String token = request.getParameter("token");
if(token==null&&redisTools.get(request.getSession().getId())==null&&!request.getRequestURI().equals("/")){ Cookie cookie = Tools.getCookie(request, "user");
System.out.println("请求无令牌,拦截"); System.out.println("接收到请求:" + request.getRequestURI() + " " + token);
//((HttpServletResponse)servletResponse).sendRedirect("/"); boolean isToken = false;
//return; boolean isCookie = false;
if (!StringUtils.isEmpty(token)) {
UKeyExample example = new UKeyExample();
example.createCriteria().andKeyEqualTo(token);
if (keyDao.selectByExample(example).size() > 0) {
isToken = true;
}
} }
if (token==null||keyDao.selectByKey(token)==null) { if (cookie != null) {
if ("ok".equals(redisTools.get(cookie.getValue()))) {
isCookie = true;
}
}
if (!isToken) {
System.out.println("token验证不通过:" + token); System.out.println("token验证不通过:" + token);
//return; } else if (!isCookie) {
System.out.println("请求无令牌,拦截");
}
if (!isCookie && !isToken) {
//response.sendRedirect("/");
if(!request.getRequestURI().contains("/login/")){
response.sendRedirect("/");
return;
}
} }
filterChain.doFilter(servletRequest, servletResponse); filterChain.doFilter(servletRequest, servletResponse);
} }

View File

@ -6,18 +6,28 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;
@Component @Component
public class RedisTools { public class RedisTools {
@Resource @Resource
RedisTemplate<String,String> redisTemplate; RedisTemplate<String, String> redisTemplate;
public void set(String key,String value){
redisTemplate.opsForValue().set(key,value); public void set(String key, String value) {
redisTemplate.opsForValue().set(key, value);
} }
public void set(String key,String value,long time){
redisTemplate.opsForValue().set(key, value, time); public void set(String key, String value, long time) {
System.out.println("key=" + key + " value=" + value + " time=" + time);
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
} }
public String get(String key){
return redisTemplate.opsForValue().get(key); public String get(String key) {
try {
return redisTemplate.opsForValue().get(key);
} catch (Exception e) {
return null;
}
} }
} }

View File

@ -25,26 +25,9 @@ public class Tools {
if(time!=-1) { if(time!=-1) {
cookie.setMaxAge(time); cookie.setMaxAge(time);
} }
cookie.setPath("/");
response.addCookie(cookie); response.addCookie(cookie);
}
/**
* 设置Cookie
* @param request
* @param response
* @param key
* @param time 生命周期为0时即为删除
* @return
*/
private static String setCookie(HttpServletRequest request, HttpServletResponse response, String key,int time) {
Cookie name = new Cookie("uname", key);
Cookie session = new Cookie("session", request.getSession().getId());
if(time!=-1) {
name.setMaxAge(time);
session.setMaxAge(time);
}
response.addCookie(name);
response.addCookie(session);
return request.getSession().getId();
} }
/** /**
* 获取Cookie * 获取Cookie
@ -54,11 +37,16 @@ public class Tools {
*/ */
public static Cookie getCookie(HttpServletRequest request,String key) { public static Cookie getCookie(HttpServletRequest request,String key) {
Cookie[] cookies = request.getCookies(); Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) { try {
if (key!=null&&cookie.getName().equals(key)) { for (Cookie cookie : cookies) {
return cookie; if (key!=null&&cookie.getName().equals(key)) {
return cookie;
}
} }
}catch (Exception ignored){
} }
return null; return null;
} }
/** /**
@ -69,18 +57,27 @@ public class Tools {
* @return * @return
*/ */
public static String deleteCookie(HttpServletRequest request, HttpServletResponse response, String key) { public static String deleteCookie(HttpServletRequest request, HttpServletResponse response, String key) {
return setCookie(request, response, key, 0); for (Cookie cookie : request.getCookies()) {
if(cookie.getName().equals(key)) {
System.out.println("删除key="+key);
cookie.setMaxAge(0);
cookie.setPath("/");
cookie.setValue(null);
response.addCookie(cookie);
}
}
return "ok";
} }
public static void sendServer(String title,String msg){ public static void sendServer(String title,String msg){
try{ try{
System.out.println("title="+title+" msg="+msg); System.out.println("title="+title+" msg="+msg);
/*HttpURLConnection connection= (HttpURLConnection) new URL("https://sc.ftqq.com/SCU64034T5adf5c5940dcecc016e0e9d0cf9b1e725da126ff47475.send?text=" HttpURLConnection connection= (HttpURLConnection) new URL("https://sc.ftqq.com/SCU64034T5adf5c5940dcecc016e0e9d0cf9b1e725da126ff47475.send?text="
+ URLEncoder.encode(title,"UTF-8")+"&desp="+URLEncoder.encode(msg,"UTF-8")).openConnection(); + URLEncoder.encode(title,"UTF-8")+"&desp="+URLEncoder.encode(msg,"UTF-8")).openConnection();
connection.connect(); connection.connect();
InputStream inputStream=connection.getInputStream(); InputStream inputStream=connection.getInputStream();
int i=inputStream.read(); int i=inputStream.read();
inputStream.close(); inputStream.close();
connection.disconnect();*/ connection.disconnect();
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -7,6 +7,7 @@ import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools; import com.yutou.tools.utils.Tools;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -27,11 +28,13 @@ public class userController {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("code", -1); json.put("code", -1);
json.put("msg", "未登录"); json.put("msg", "未登录");
JSONArray array=new JSONArray(); JSONArray array = new JSONArray();
if(redisTools.get("bean")!=null){ if (redisTools.get("ban") != null) {
array=JSONArray.parseArray(redisTools.get("bean")); array = JSONArray.parseArray(redisTools.get("ban"));
} }
if(array.contains(Tools.getRemoteAddress(request))){ if (array.contains(Tools.getRemoteAddress(request))) {
json.put("code", -2);
json.put("msg", "未登录");
System.out.println("IP已被封禁"); System.out.println("IP已被封禁");
return json.toJSONString(); return json.toJSONString();
} }
@ -39,7 +42,7 @@ public class userController {
if (cookie == null) { if (cookie == null) {
return json.toJSONString(); return json.toJSONString();
} }
if (redisTools.get(cookie.getValue()).equals("ok")) { if ("ok".equals(redisTools.get(cookie.getValue()))) {
json.put("code", 0); json.put("code", 0);
json.put("msg", "登录成功"); json.put("msg", "登录成功");
return json.toJSONString(); return json.toJSONString();
@ -52,31 +55,78 @@ public class userController {
@RequestMapping("/login/sendCaptcha.do") @RequestMapping("/login/sendCaptcha.do")
@ResponseBody @ResponseBody
public String captcha(HttpServletRequest request) { public String captcha(HttpServletRequest request) {
int[] captcha = Tools.randomCommon(0, 9, 5); JSONArray array = new JSONArray();
if (redisTools.get("ban") != null) {
array = JSONArray.parseArray(redisTools.get("ban"));
}
if (array.contains(Tools.getRemoteAddress(request))) {
System.out.println("IP已被封禁");
return "ERROR!";
}
int[] captcha = Tools.randomCommon(0, 9, 6);
String cc = ""; String cc = "";
for (int value : captcha) { for (int value : captcha) {
cc += value; cc += value;
} }
redisTools.set("login",cc,5*60*1000); redisTools.set("login", cc, 5 * 60 * 1000);
String token=UUID.randomUUID().toString().replace("-","");
redisTools.set(token,Tools.getRemoteAddress(request),10 * 60 * 1000);
String url="http://tools.yutou233.cn/login/ban.do?token="+token;
Tools.sendServer("管理后台登录验证码", "本次登录验证码为:" + cc Tools.sendServer("管理后台登录验证码", "本次登录验证码为:" + cc
+ ",登录IP:" + Tools.getRemoteAddress(request) + ",登录IP:" + Tools.getRemoteAddress(request)
+ ",非正常登录封禁IP:http://www.baidu.com"); + ",非正常登录封禁IP:"+url);
return "ok"; return "ok";
} }
@RequestMapping("/login/login.do") @RequestMapping("/login/ban.do")
@ResponseBody @ResponseBody
public String login(HttpServletResponse response,String code){ public String banIp(String token){
JSONObject json=new JSONObject(); String ip=redisTools.get(token);
if(redisTools.get("login").equals(code.trim())){ if(ip!=null){
String uuid=UUID.randomUUID().toString(); JSONArray array = new JSONArray();
Tools.setCookie(response,"user",uuid.replace("-",""),30*24*60*60*1000); if (redisTools.get("ban") != null) {
redisTools.set(uuid.replace("-",""),"ok",30*24*60*60*1000); array = JSONArray.parseArray(redisTools.get("bean"));
json.put("code",0); }
json.put("msg","登录成功"); array.add(ip);
redisTools.set("ban",array.toJSONString());
return "已封禁";
}
return "ERROR";
}
@RequestMapping(value = "/login/login.do", method = RequestMethod.POST)
@ResponseBody
public String login(HttpServletResponse response, String code) {
JSONObject json = new JSONObject();
if (redisTools.get("login").equals(code.trim())) {
String uuid = UUID.randomUUID().toString();
Tools.setCookie(response, "user", uuid.replace("-", ""), 30 * 24 * 60 * 60);
redisTools.set(uuid.replace("-", ""), "ok", 30 * 24 * 60 * 60);
json.put("code", 0);
json.put("msg", "登录成功");
return json.toJSONString(); return json.toJSONString();
} }
json.put("code",-2); json.put("code", -2);
json.put("msg","登录安全码错误"); json.put("msg", "登录安全码错误");
return json.toJSONString(); return json.toJSONString();
}
@RequestMapping(value = "/login/logout.do", method = RequestMethod.POST)
@ResponseBody
public String logout(HttpServletRequest request, HttpServletResponse response) {
JSONObject json = new JSONObject();
Cookie cookie = Tools.getCookie(request, "user");
json.put("code", -1);
json.put("msg", "退出失败");
if (cookie != null) {
if ("ok".equals(redisTools.get(cookie.getValue()))) {
redisTools.set(cookie.getValue(), "ok", 1);
Tools.deleteCookie(request, response, "user");
json.put("code", 0);
json.put("msg", "退出成功");
}
}
return json.toJSONString();
} }
} }

View File

@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yutou.tools.mybatis.dao.NasAdminAddressDao">
<resultMap id="BaseResultMap" type="com.yutou.tools.mybatis.model.NasAdminAddress">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="port" jdbcType="INTEGER" property="port" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, title, url, port
</sql>
<select id="selectByExample" parameterType="com.yutou.tools.mybatis.model.NasAdminAddressExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from nas_admin_address
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from nas_admin_address
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from nas_admin_address
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.yutou.tools.mybatis.model.NasAdminAddressExample">
delete from nas_admin_address
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.NasAdminAddress" useGeneratedKeys="true">
insert into nas_admin_address (title, url, port
)
values (#{title,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{port,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.NasAdminAddress" useGeneratedKeys="true">
insert into nas_admin_address
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">
title,
</if>
<if test="url != null">
url,
</if>
<if test="port != null">
port,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="url != null">
#{url,jdbcType=VARCHAR},
</if>
<if test="port != null">
#{port,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.yutou.tools.mybatis.model.NasAdminAddressExample" resultType="java.lang.Long">
select count(*) from nas_admin_address
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update nas_admin_address
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.title != null">
title = #{record.title,jdbcType=VARCHAR},
</if>
<if test="record.url != null">
url = #{record.url,jdbcType=VARCHAR},
</if>
<if test="record.port != null">
port = #{record.port,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update nas_admin_address
set id = #{record.id,jdbcType=INTEGER},
title = #{record.title,jdbcType=VARCHAR},
url = #{record.url,jdbcType=VARCHAR},
port = #{record.port,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.tools.mybatis.model.NasAdminAddress">
update nas_admin_address
<set>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="url != null">
url = #{url,jdbcType=VARCHAR},
</if>
<if test="port != null">
port = #{port,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yutou.tools.mybatis.model.NasAdminAddress">
update nas_admin_address
set title = #{title,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
port = #{port,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,235 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yutou.tools.mybatis.dao.ToolsPasswordDao">
<resultMap id="BaseResultMap" type="com.yutou.tools.mybatis.model.ToolsPassword">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="username" jdbcType="VARCHAR" property="username" />
<result column="password" jdbcType="VARCHAR" property="password" />
<result column="url" jdbcType="VARCHAR" property="url" />
<result column="info" jdbcType="VARCHAR" property="info" />
<result column="type" jdbcType="INTEGER" property="type" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, title, username, `password`, url, info, `type`
</sql>
<select id="selectByExample" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from tools_password
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tools_password
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tools_password
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordExample">
delete from tools_password
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.ToolsPassword" useGeneratedKeys="true">
insert into tools_password (title, username, `password`,
url, info, `type`)
values (#{title,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{url,jdbcType=VARCHAR}, #{info,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.ToolsPassword" useGeneratedKeys="true">
insert into tools_password
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">
title,
</if>
<if test="username != null">
username,
</if>
<if test="password != null">
`password`,
</if>
<if test="url != null">
url,
</if>
<if test="info != null">
info,
</if>
<if test="type != null">
`type`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="url != null">
#{url,jdbcType=VARCHAR},
</if>
<if test="info != null">
#{info,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordExample" resultType="java.lang.Long">
select count(*) from tools_password
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update tools_password
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.title != null">
title = #{record.title,jdbcType=VARCHAR},
</if>
<if test="record.username != null">
username = #{record.username,jdbcType=VARCHAR},
</if>
<if test="record.password != null">
`password` = #{record.password,jdbcType=VARCHAR},
</if>
<if test="record.url != null">
url = #{record.url,jdbcType=VARCHAR},
</if>
<if test="record.info != null">
info = #{record.info,jdbcType=VARCHAR},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update tools_password
set id = #{record.id,jdbcType=INTEGER},
title = #{record.title,jdbcType=VARCHAR},
username = #{record.username,jdbcType=VARCHAR},
`password` = #{record.password,jdbcType=VARCHAR},
url = #{record.url,jdbcType=VARCHAR},
info = #{record.info,jdbcType=VARCHAR},
`type` = #{record.type,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.tools.mybatis.model.ToolsPassword">
update tools_password
<set>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="username != null">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
`password` = #{password,jdbcType=VARCHAR},
</if>
<if test="url != null">
url = #{url,jdbcType=VARCHAR},
</if>
<if test="info != null">
info = #{info,jdbcType=VARCHAR},
</if>
<if test="type != null">
`type` = #{type,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yutou.tools.mybatis.model.ToolsPassword">
update tools_password
set title = #{title,jdbcType=VARCHAR},
username = #{username,jdbcType=VARCHAR},
`password` = #{password,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
info = #{info,jdbcType=VARCHAR},
`type` = #{type,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yutou.tools.mybatis.dao.ToolsPasswordTypeDao">
<resultMap id="BaseResultMap" type="com.yutou.tools.mybatis.model.ToolsPasswordType">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="title" jdbcType="VARCHAR" property="title" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, title
</sql>
<select id="selectByExample" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordTypeExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from tools_password_type
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tools_password_type
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tools_password_type
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordTypeExample">
delete from tools_password_type
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordType" useGeneratedKeys="true">
insert into tools_password_type (title)
values (#{title,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordType" useGeneratedKeys="true">
insert into tools_password_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null">
title,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordTypeExample" resultType="java.lang.Long">
select count(*) from tools_password_type
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update tools_password_type
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.title != null">
title = #{record.title,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update tools_password_type
set id = #{record.id,jdbcType=INTEGER},
title = #{record.title,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordType">
update tools_password_type
<set>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordType">
update tools_password_type
set title = #{title,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,123 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>NAS</title>
<link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
<div id="header"></div>
<div class="layui-body" style="left: 200px;">
<div id="side"></div>
<blockquote class="layui-elem-quote"><span id="ip">B站直播下载器</span></blockquote>
<table id="address" lay-filter="listTools"></table>
<div id="footer"></div>
</div>
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script>
<script type="text/html" id="listTools">
<a class="layui-btn layui-btn-xs" lay-event="set">设置</a>
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
$.get("/login/check.do", function (data) {
let json = JSON.parse(data);
if (json.code != 0) {
window.location.href = "/"
}
})
layui.use(['layer', 'form', 'element', 'table'], function () {
var layer = layui.layer
, form = layui.form
, table = layui.table;
table.render({
elem: "#address"
, url: '/bili/live/get/url.do'
, page: true
, cols: [[
{ field: "id", title: "id", width: 80, sort: true, fixed: 'left' }
, { field: 'cid', title: 'cid', width: 100 }
, { field: 'url', title: 'url', width: 400 }
, { field: 'status', title: '状态', width: 80 }
, { field: "right", width: 200, toolbar: '#listTools' }
]]
});
table.on('tool(listTools)', function (obj) {
let data = obj.data;
if (obj.event === 'set') {
layer.open({
title: '设置'
, content: '切换状态'
, btn: ['启动', '关闭']
, yes: function (index, obj) {
$.post('/bili/live/set/update.do', { id: data.id, status: '1' }, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg);
table.reload('address')
})
layer.close(index)
},
btn2: function (index, obj) {
$.post('/bili/live/set/update.do', { id: data.id, status: '0' }, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg);
table.reload('address')
})
table.reload('address')
layer.close(index)
}
})
} else if (obj.event === 'edit') {
layer.prompt({
title: "请输入链接或cid"
}, function (value, index) {
$.post('/bili/live/set/update.do', { id: data.id, url: value }, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg);
table.reload('address')
})
table.reload('address')
layer.close(index)
})
} else {
layer.open({
title: "删除提示"
, content: "确认删除?"
, btn: ['确认', '取消']
, yes: function (index, layero) {
$.post('bili/live/set/delete.do', { id: data.id }, function () {
table.reload('address')
});
layer.close(index)
},
btn2: function (index, layero) {
layer.close(index)
}
})
}
})
});
$.ajax({ cache: false })
$('#header').load("/html/header.html");
$('#footer').load("/html/footer.html");
$('#side').load("/html/body/nas/side.html");
</script>
<style>
#icon {
float: right;
}
.body {
bottom: 0;
}
</style>
</body>
</html>

View File

@ -30,12 +30,17 @@
$('#header').load("/html/header.html"); $('#header').load("/html/header.html");
$('#footer').load("/html/footer.html"); $('#footer').load("/html/footer.html");
$('#side').load("/html/body/nas/side.html"); $('#side').load("/html/body/nas/side.html");
$.get("/login/check.do", function (data) {
let json = JSON.parse(data);
if (json.code != 0) {
window.location.href = "/"
}
})
</script> </script>
<style> <style>
#icon { #icon {
float: right; float: right;
} }
.body { .body {
bottom: 0; bottom: 0;
} }

View File

@ -13,14 +13,19 @@
<div id="header"></div> <div id="header"></div>
<div class="layui-body" style="left: 200px;"> <div class="layui-body" style="left: 200px;">
<div id="side"></div> <div id="side"></div>
<blockquote class="layui-elem-quote" ><span id="ip">当前IP:</span></blockquote> <blockquote class="layui-elem-quote"><span id="ip">当前IP:</span></blockquote>
<div id="footer"></div> <div id="footer"></div>
</div> </div>
<script src="/layui/layui.js"></script> <script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script> <script src="/js/jquery-3.2.1.js"></script>
<script> <script>
$.get("/login/check.do", function (data) {
let json = JSON.parse(data);
if (json.code != 0) {
window.location.href = "/"
}
})
layui.use(['layer', 'form', 'element'], function () { layui.use(['layer', 'form', 'element'], function () {
var layer = layui.layer var layer = layui.layer
, form = layui.form; , form = layui.form;
@ -30,20 +35,26 @@
$('#header').load("/html/header.html"); $('#header').load("/html/header.html");
$('#footer').load("/html/footer.html"); $('#footer').load("/html/footer.html");
$('#side').load("/html/body/nas/side.html"); $('#side').load("/html/body/nas/side.html");
$.post("/nas/getIp.do",function(data){ $.post("/nas/getIp.do", function (data) {
var json=JSON.parse(data); try {
if(json.code!=0){ var json = JSON.parse(data);
} catch (error) {
window.location.href = "/"
return
}
if (json.code != 0) {
$('#ip').html(json.msg); $('#ip').html(json.msg);
}else{ } else {
$('#ip').html("当前服务器IP:"+json.data); $('#ip').html("当前服务器IP:" + json.data);
} }
}) })
</script> </script>
<style> <style>
#icon { #icon {
float: right; float: right;
} }
.body { .body {
bottom: 0; bottom: 0;
} }

View File

@ -1,7 +1,7 @@
<div class="layui-side layui-bg-black"> <div class="layui-side layui-bg-black" id='myside'>
<div class="layui-side-scroll layui-bg-blue"> <div class="layui-side-scroll layui-bg-blue" id="myside_div">
<!-- 左侧导航区域可配合layui已有的垂直导航 --> <!-- 左侧导航区域可配合layui已有的垂直导航 -->
<ul class="layui-nav layui-nav-tree layui-bg-blue" lay-filter="test"> <ul class="layui-nav layui-nav-tree layui-bg-blue" lay-filter="test" >
<li class="layui-nav-item"> <li class="layui-nav-item">
<a class="" href="javascript:;">本体管理</a> <a class="" href="javascript:;">本体管理</a>
<dl class="layui-nav-child"> <dl class="layui-nav-child">
@ -9,20 +9,30 @@
</dl> </dl>
</li> </li>
<li class="layui-nav-item"> <li class="layui-nav-item">
<a class="" href="javascript:;">管理后台</a> <a class="" href="/html/body/nas/switchAdmin.html">管理后台</a>
<dl class="layui-nav-child">
<dd><a href="javascript:;">切换管理后台</a></dd>
<dd><a href="javascript:;">管理后台</a></dd>
<dd><a href="javascript:;">Jellyfin</a></dd>
</dl>
</li> </li>
<li class="layui-nav-item"> <li class="layui-nav-item">
<a href="javascript:;">功能管理</a> <a href="javascript:;">功能管理</a>
<dl class="layui-nav-child"> <dl class="layui-nav-child">
<dd><a href="javascript:;">B站直播下载器</a></dd> <dd><a href="/html/body/nas/bilidown.html">B站直播下载器</a></dd>
</dl> </dl>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
<script>
$(document).ready(function () {
let mobile = navigator.userAgent.toLowerCase().match(/android/i) == "android" || navigator.userAgent.toLowerCase().match(/iphone os/i) == "iphone os";
if (mobile) {
$('#myside').removeClass('layui-side')
$('#myside_div').removeClass('layui-side-scroll')
$('#myside').addClass('layui-header')
$('#myside').css('height','100%')
} else {
$('#myside').removeClass('layui-header')
$('#myside').addClass('layui-side')
$('#myside_div').addClass('layui-side-scroll')
}
})
</script>

View File

@ -13,37 +13,138 @@
<div id="header"></div> <div id="header"></div>
<div class="layui-body" style="left: 200px;"> <div class="layui-body" style="left: 200px;">
<div id="side"></div> <div id="side"></div>
<blockquote class="layui-elem-quote" ><span id="ip">当前IP:</span></blockquote> <blockquote class="layui-elem-quote"><span id="ip">当前状态:</span></blockquote>
<div style="margin-left: 10px;">
<button type="button" id='add' class="layui-btn layui-btn-normal">新增</button>
<div style="width: 30%; margin-top: 10px; display: none;" id="adddata">
<form class="layui-form" action="">
<input type="text" name="title" id="title" required lay-verify="required" placeholder="请输入标题"
autocomplete="off" class="layui-input">
<input type="text" name="url" id="url" required lay-verify="required" placeholder="请输入URL"
autocomplete="off" class="layui-input" style="margin-top: 10px;">
<input type="number" name="port" id="port" required lay-verify="required" placeholder="请输入端口"
autocomplete="off" class="layui-input" style="margin-top: 10px;">
<div class="layui-form-item">
<button class="layui-btn" lay-submit lay-filter="formDemo"
style="margin-top: 10px;">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary"
style="margin-top: 10px;">重置</button>
</div>
</form>
</div>
<table id="address" lay-filter="listTools"></table>
</div>
<div id="footer"></div> <div id="footer"></div>
</div> </div>
<script src="/layui/layui.js"></script> <script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script> <script src="/js/jquery-3.2.1.js"></script>
<script>
layui.use(['layer', 'form', 'element'], function () { <script type="text/html" id="listTools">
<a class="layui-btn layui-btn-xs" lay-event="set">设置</a>
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
$.get("/login/check.do", function (data) {
let json = JSON.parse(data);
if (json.code != 0) {
window.location.href = "/"
}
})
let editModel = 'edit';
let dataId = -1;
layui.use(['layer', 'form', 'element', 'table'], function () {
var layer = layui.layer var layer = layui.layer
, form = layui.form; , form = layui.form
, table = layui.table;
table.render({
elem: "#address"
, url: '/auth/nas/address/list.do'
, page: true
, cols: [[
{ field: "id", title: "id", width: 80, sort: true, fixed: 'left' }
, { field: 'title', title: '标题', width: 80 }
, { field: 'url', title: 'url', width: 400 }
, { field: 'port', title: '端口', width: 80 }
, { field: "right", width: 200, toolbar: '#listTools' }
]]
});
table.on('tool(listTools)', function (obj) {
let data = obj.data;
if (obj.event === 'set') {
$.post('/auth/nas/address/set.do', { id: data.id }, function (deta) {
let json = JSON.parse(deta);
layer.msg(json.msg)
setTimeout(function () {
table.reload('address')
}, 2000)
});
} else if (obj.event === 'edit') {
editModel = 'update';
dataId = data.id;
$('#title').val(data.title)
$('#url').val(data.url)
$('#port').val(data.port)
$('#adddata').css('display', '')
} else {
layer.open({
title: "删除提示"
, content: "确认删除?"
, btn: ['确认', '取消']
, yes: function (index, layero) {
$.post('/auth/nas/address/remove.do', { id: data.id }, function () {
table.reload('address')
});
layer.close(index)
},
btn2: function (index, layero) {
layer.close(index)
}
})
}
});
form.on('submit(formDemo)', function (data) {
//layer.msg(JSON.stringify(data.field));
$('#adddata').css("display", 'none')
let url = '/auth/nas/address/add.do'
if (editModel === 'update') {
url = '/auth/nas/address/update.do'
}
$.post(url, { title: data.field.title, url: data.field.url, port: data.field.port, id: dataId }, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg)
table.reload('address')
});
return false;
});
}); });
$.ajax({ cache: false }) $.ajax({ cache: false })
$('#header').load("/html/header.html"); $('#header').load("/html/header.html");
$('#footer').load("/html/footer.html"); $('#footer').load("/html/footer.html");
$('#side').load("/html/body/nas/side.html"); $('#side').load("/html/body/nas/side.html");
$.post("/nas/getIp.do",function(data){ $.get("/auth/nas/address/get.do", function (data) {
var json=JSON.parse(data); var json = JSON.parse(data);
if(json.code!=0){ if (json.code != 0) {
$('#ip').html(json.msg);
} else {
$('#ip').html(json.msg); $('#ip').html(json.msg);
}else{
$('#ip').html("当前服务器IP:"+json.data);
} }
}) })
$('#add').click(function () {
editModel = 'edit'
$('#adddata').css("display", '')
})
</script> </script>
<style> <style>
#icon { #icon {
float: right; float: right;
} }
.body { .body {
bottom: 0; bottom: 0;
} }

View File

@ -0,0 +1,281 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>NAS</title>
<link rel="stylesheet" href="/layui/css/layui.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
<div id="header"></div>
<div class="layui-body" style="top: 100px; ">
<!-- <div id="side"></div> -->
<blockquote class="layui-elem-quote"><span id="ip">密码管理器</span></blockquote>
<button type="button" id="addType" class="layui-btn layui-btn-normal">新增分类</button>
<div class="layui-tab" lay-filter="type" lay-allowclose="true">
<ul class="layui-tab-title">
</ul>
<div class="layui-tab-content">
</div>
</div>
<iframe src="../../randompassword/index.html" style="width: 100%; height: 120%; " frameborder="0"
scrolling="no"></iframe>
<div id="footer"></div>
</div>
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script>
<script type="text/html" id="topTools">
<a class="layui-btn layui-btn-xs" lay-event="addAddress">新增账号</a>
</script>
<script type="text/html" id="listTools">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
$.get("/login/check.do", function (data) {
let json = JSON.parse(data);
if (json.code != 0) {
window.location.href = "/"
}
})
let tabid = -1;
layui.use(['layer', 'form', 'element', 'table'], function () {
var layer = layui.layer
, form = layui.form
, table = layui.table
, element = layui.element;
$.get("/tools/password/type/get/list.do", function (data) {
let json = JSON.parse(data);
if (json.code == 0) {
for (let index = 0; index < json.data.length; index++) {
const ret = json.data[index];
element.tabAdd('type', {
title: ret.title
, content: '<table id="passwordlist' + ret.id + '" lay-filter="listTools"></table>'
, id: ret.id
})
}
element.tabChange('type', '1');
}
});
form.render()
element.on('tab(type)', function (data) {
console.log(this)
tabid = $(this).attr('lay-id')
table.render({
elem: "#passwordlist" + tabid
, url: '/tools/password/get/list.do?type=' + tabid
, toolbar: '#topTools'
, page: true
, cols: [[
{ field: "id", title: "id", width: 80, sort: true, fixed: 'left' }
, { field: 'title', title: '标题', width: 80 }
, { field: 'username', title: '账号', width: 200 }
, { field: 'password', title: '密码', width: 200 }
, { field: 'url', title: '网址', width: 400, templet: '<div><a href="{{d.url}}" target="_blank">{{d.url}}</a></div>' }
, { field: 'info', title: '备注', width: 200 }
, { field: "right", width: 200, toolbar: '#listTools' }
]]
});
})
element.on('tabDelete(type)', function (data) {
let name = $(data.elem.prevObject.prevObject[0]).text().replace("ဆ", "")
let id = $(data.elem.prevObject.prevObject[0]).attr('lay-id')
layer.open({
title: "警告"
, content: "确认删除 " + name
, btn: ['确认', '取消']
, yes: function (index) {
$.post('/tools/password/type/set/remove.do', { id: id }, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg);
})
layer.close(index)
}
, btn2: function (index) {
layer.close(index)
}
})
});
table.on('rowDouble(listTools)', function (data) {
$.get('/tools/password/get/password.do?id=' + data.data.id, function (udata) {
let json = JSON.parse(udata);
data.data.password = json.data;
data.update(data.data)
})
})
table.on('tool(listTools)', function (obj) {
if (obj.event === 'edit') {
$.get('/tools/password/get/password.do?id=' + obj.data.id, function (udata) {
let json = JSON.parse(udata);
layer.open({
title: "添加账号",
type: 1,
content: $('#adduser'),
btn: ['提交', '关闭'],
yes: function (index) {
$.post('/tools/password/set/update.do', {
title: $('#title').val()
, username: $('#username').val(), password: $('#password').val()
, url: $('#url').val(), info: $('#info').val()
, type: tabid
, id: obj.data.id
}, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg)
table.reload('passwordlist' + obj.data.id)
$('#title').val('')
$('#username').val('')
$('#password').val('')
$('#url').val('')
$('#info').val('')
layer.close(index)
})
},
btn2: function (index) {
layer.msg(tabid)
layer.close(index)
},
success: function (layero, index) {
$('#title').val(obj.data.title)
$('#username').val(obj.data.username)
$('#password').val(json.data)
$('#url').val(obj.data.url)
$('#info').val(obj.data.info)
}
})
})
} else if (obj.event === 'del') {
layer.open({
title: "警告!"
, content: "删除操作无法回滚,是否确认删除:" + obj.data.title
, btn: ['确认', '取消']
, yes: function (index) {
$.post('/tools/password/set/remove.do', { id: obj.data.id }, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg)
})
},
btn2: function (index) {
layer.close(index);
}
})
}
})
table.on('toolbar(listTools)', function (obj) {
if (obj.event === 'addAddress') {
layer.open({
title: "添加账号",
type: 1,
content: $('#adduser'),
btn: ['提交', '关闭'],
yes: function (index) {
$.post('/tools/password/set/add.do', {
title: $('#title').val()
, username: $('#username').val(), password: $('#password').val()
, url: $('#url').val(), info: $('#info').val()
, type: tabid
}, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg)
table.reload('passwordlist' + tabid)
$('#title').val('')
$('#username').val('')
$('#password').val('')
$('#url').val('')
$('#info').val('')
layer.close(index)
})
},
btn2: function (index) {
layer.msg(tabid)
layer.close(index)
}
})
}
})
$('#addType').click(function () {
layer.prompt({
title: '新增分类'
}, function (value, index, elem) {
$.post('/tools/password/type/set/add.do', { type: value }, function (data) {
window.location.reload()
})
layer.close(index)
})
})
});
$.ajax({ cache: false })
$('#header').load("/html/header.html");
$('#footer').load("/html/footer.html");
$('#side').load("/html/body/nas/side.html");
</script>
<style>
</style>
<div style="display: none; margin: 20px;" id="adduser">
<form class="layui-form" action="">
<div class="layui-form-item">
<label class="layui-form-label">标题</label>
<div class="layui-input-block">
<input type="text" id="title" required lay-verify="required" placeholder="请输入标题"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">账号</label>
<div class="layui-input-block">
<input type="text" id="username" required lay-verify="required" placeholder="请输入账号"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-block">
<input type="text" id="password" required lay-verify="required" placeholder="请输入密码"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">网址</label>
<div class="layui-input-block">
<input type="text" id="url" required lay-verify="required" placeholder="请输入网址URL"
autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">备注信息</label>
<div class="layui-input-block">
<textarea type="text" id="info" name="" required lay-verify="required" class="layui-textarea"
placeholder="请输入备注信息"></textarea>
</div>
</div>
</form>
</div>
</body>
<style>
#icon {
float: right;
}
</style>
</html>

View File

@ -18,7 +18,7 @@
<li class="layui-nav-item"> <li class="layui-nav-item">
<a href="javascript:;">工具集</a> <a href="javascript:;">工具集</a>
<dl class="layui-nav-child"> <dl class="layui-nav-child">
<dd><a href="javascript:;" target="_blank">密码管理器</a></dd> <dd><a href="/html/body/tools/password.html">密码管理器</a></dd>
</dl> </dl>
</li> </li>
<li class="layui-nav-item"> <li class="layui-nav-item">
@ -29,27 +29,63 @@
</dl> </dl>
</li> </li>
<li class="layui-nav-item" id='icon'> <li class="layui-nav-item" id='icon'>
<a href="javascript:;" id="login"><img src="//t.cn/RCzsdCq" class="layui-nav-img">登录</a> <a href="javascript:;" id="login"><img src="//t.cn/RCzsdCq" class="layui-nav-img"><span
id='login_text'>登录</span></a>
<dl class="layui-nav-child"> <dl class="layui-nav-child">
<dd><a href="javascript:;">退了</a></dd> <dd><a href="javascript:;" id="logout">退了</a></dd>
</dl> </dl>
</li> </li>
</ul> </ul>
</div> </div>
</body> </body>
<script> <script>
let loginStatus = false;
$.get("/login/check.do", function (data) {
let json = JSON.parse(data);
if (json.code == 0) {
$('#login_text').text('已登录')
loginStatus = true;
}
})
$('#login').click(function () { $('#login').click(function () {
if (loginStatus) {
return;
}
$.post('/login/sendCaptcha.do', function () { $.post('/login/sendCaptcha.do', function () {
layer.prompt({ layer.prompt({
title: '安全登录码' title: '安全登录码'
}, function (value, index, elem) { }, function (value, index, elem) {
alert(value); //得到value $.post('/login/login.do', { code: value }, function (data) {
let json = JSON.parse(data);
layer.msg(json.msg)
window.location.reload()
});
layer.close(index); layer.close(index);
}) })
}) })
})
$('#logout').click(function () {
$.post('/login/logout.do', function (data) {
let json = JSON.parse(data);
layer.msg(json.msg)
window.location.href = "/"
})
})
$(document).ready(function () {
let mobile = navigator.userAgent.toLowerCase().match(/android/i) == "android" || navigator.userAgent.toLowerCase().match(/iphone os/i) == "iphone os";
if (mobile) {
$('.layui-body').css('left', '0')
$('.layui-body').css('top', '150px')
$('.layui-body').css('height', '200%')
$('#icon').css('float', 'none')
} else {
$('.layui-body').css('padding-right', '100px')
$('#icon').css('float', 'right')
}
}) })
</script> </script>
<style>
</style>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,273 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
}
button {
border: 0;
outline: 0;
}
.container {
margin: 40px 0;
width: 400px;
padding: 10px 25px;
background: #0a0e31;
border-radius: 10px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.45), 0 4px 8px rgba(0, 0, 0, 0.35), 0 8px 12px rgba(0, 0, 0, 0.15);
font-family: "Montserrat";
}
.container h2.title {
font-size: 1.75rem;
margin: 10px -5px;
margin-bottom: 30px;
color: #fff;
}
.result {
position: relative;
width: 100%;
height: 65px;
overflow: hidden;
}
.result__info {
position: absolute;
bottom: 4px;
color: #fff;
font-size: 0.8rem;
transition: all 150ms ease-in-out;
transform: translateY(200%);
opacity: 0;
}
.result__info.right {
right: 8px;
}
.result__info.left {
left: 8px;
}
.result__viewbox {
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.08);
border-radius: 8px;
color: #fff;
text-align: center;
line-height: 65px;
}
.result #copy-btn {
position: absolute;
top: var(--y);
left: var(--x);
width: 38px;
height: 38px;
background: #fff;
border-radius: 50%;
opacity: 0;
transform: translate(-50%, -50%) scale(0);
transition: all 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
cursor: pointer;
z-index: 2;
}
.result #copy-btn:active {
box-shadow: 0 0 0 200px rgba(255, 255, 255, 0.08);
}
.result:hover #copy-btn {
opacity: 1;
transform: translate(-50%, -50%) scale(1.35);
}
.field-title {
position: absolute;
top: -10px;
left: 8px;
transform: translateY(-50%);
font-weight: 800;
color: rgba(255, 255, 255, 0.5);
text-transform: uppercase;
font-size: 0.65rem;
pointer-events: none;
user-select: none;
}
.options {
width: 100%;
height: auto;
margin: 50px 0;
}
.range__slider {
position: relative;
width: 100%;
height: calc(65px - 10px);
display: flex;
justify-content: center;
align-items: center;
background: rgba(255, 255, 255, 0.08);
border-radius: 8px;
margin: 30px 0;
}
.range__slider::before, .range__slider::after {
position: absolute;
color: #fff;
font-size: 0.9rem;
font-weight: bold;
}
.range__slider::before {
content: attr(data-min);
left: 10px;
}
.range__slider::after {
content: attr(data-max);
right: 10px;
}
.range__slider .length__title::after {
content: attr(data-length);
position: absolute;
right: -16px;
font-variant-numeric: tabular-nums;
color: #fff;
}
#slider {
-webkit-appearance: none;
width: calc(100% - (70px));
height: 2px;
border-radius: 5px;
background: rgba(255, 255, 255, 0.314);
outline: none;
padding: 0;
margin: 0;
cursor: pointer;
}
#slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: white;
cursor: pointer;
transition: all 0.15s ease-in-out;
}
#slider::-webkit-slider-thumb:hover {
background: #d4d4d4;
transform: scale(1.2);
}
#slider::-moz-range-thumb {
width: 20px;
height: 20px;
border: 0;
border-radius: 50%;
background: white;
cursor: pointer;
transition: background 0.15s ease-in-out;
}
#slider::-moz-range-thumb:hover {
background: #d4d4d4;
}
.settings {
position: relative;
height: auto;
widows: 100%;
display: flex;
flex-direction: column;
}
.settings .setting {
position: relative;
width: 100%;
height: calc(65px - 10px);
background: rgba(255, 255, 255, 0.08);
border-radius: 8px;
display: flex;
align-items: center;
padding: 10px 25px;
color: #fff;
margin-bottom: 8px;
}
.settings .setting input {
opacity: 0;
position: absolute;
}
.settings .setting input + label {
user-select: none;
}
.settings .setting input + label::before, .settings .setting input + label::after {
content: "";
position: absolute;
transition: 150ms cubic-bezier(0.24, 0, 0.5, 1);
transform: translateY(-50%);
top: 50%;
right: 10px;
cursor: pointer;
}
.settings .setting input + label::before {
height: 30px;
width: 50px;
border-radius: 30px;
background: rgba(214, 214, 214, 0.434);
}
.settings .setting input + label::after {
height: 24px;
width: 24px;
border-radius: 60px;
right: 32px;
background: #fff;
}
.settings .setting input:checked + label:before {
background: #5d68e2;
transition: all 150ms cubic-bezier(0, 0, 0, 0.1);
}
.settings .setting input:checked + label:after {
right: 14px;
}
.settings .setting input:focus + label:before {
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
}
.btn.generate {
user-select: none;
position: relative;
width: 100%;
height: 50px;
margin: 10px 0;
border-radius: 8px;
color: #fff;
border: none;
background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
letter-spacing: 1px;
font-weight: bold;
text-transform: uppercase;
cursor: pointer;
transition: all 150ms ease;
}
.btn.generate:active {
transform: translateY(-3%);
box-shadow: 0 4px 8px rgba(255, 255, 255, 0.08);
}
.support {
position: fixed;
right: 10px;
bottom: 10px;
padding: 10px;
display: flex;
}
a {
margin: 0 20px;
color: #fff;
font-size: 2rem;
transition: all 400ms ease;
}
a:hover {
color: #222;
}

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,60 @@
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>js随机密码生成器插件 - 源码之家</title>
<!--图标库-->
<link rel='stylesheet' href='css/font-awesome.min.css'>
<!--字体库-->
<!--<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Montserrat&amp;display=swap'>-->
<!--主要样式-->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<h2 class="title">密码生成器</h2>
<div class="result">
<div class="result__title field-title">生成的密码</div>
<div class="result__info right">点击复制</div>
<div class="result__info left">复制</div>
<div class="result__viewbox" id="result">点击生成</div>
<button id="copy-btn" style="--x: 0; --y: 0"><i class="far fa-copy"></i></button>
</div>
<div class="length range__slider" data-min="4" data-max="128">
<div class="length__title field-title" data-length='0'>长度:</div>
<input id="slider" type="range" min="4" max="128" value="16" />
</div>
<div class="settings">
<span class="settings__title field-title">settings</span>
<div class="setting">
<input type="checkbox" id="uppercase" checked />
<label for="uppercase">包含大写</label>
</div>
<div class="setting">
<input type="checkbox" id="lowercase" checked />
<label for="lowercase">包含小写</label>
</div>
<div class="setting">
<input type="checkbox" id="number" checked />
<label for="number">包括数字</label>
</div>
<div class="setting">
<input type="checkbox" id="symbol" />
<label for="symbol">包括符号</label>
</div>
</div>
<button class="btn generate" id="generate">生成密码</button>
</div>
<script src="js/script.js"></script>
<div style="text-align:center;">
</div>
</body>
</html>

View File

@ -0,0 +1,152 @@
// This is a simple Password Generator App that will generate random password maybe you can you them to secure your account.
// I tried my best to make the code as simple as possible please dont mind the variable names.
// Also this idea came in my mind after checking Traversy Media's latest video.
// Clear the concole on every refresh
console.clear();
// Range Slider Properties.
// Fill : The trailing color that you see when you drag the slider.
// background : Default Range Slider Background
const sliderProps = {
fill: "#0B1EDF",
background: "rgba(255, 255, 255, 0.214)",
};
// Selecting the Range Slider container which will effect the LENGTH property of the password.
const slider = document.querySelector(".range__slider");
// Text which will show the value of the range slider.
const sliderValue = document.querySelector(".length__title");
// Using Event Listener to apply the fill and also change the value of the text.
slider.querySelector("input").addEventListener("input", event => {
sliderValue.setAttribute("data-length", event.target.value);
applyFill(event.target);
});
// Selecting the range input and passing it in the applyFill func.
applyFill(slider.querySelector("input"));
// This function is responsible to create the trailing color and setting the fill.
function applyFill(slider) {
const percentage = (100 * (slider.value - slider.min)) / (slider.max - slider.min);
const bg = `linear-gradient(90deg, ${sliderProps.fill} ${percentage}%, ${sliderProps.background} ${percentage +
0.1}%)`;
slider.style.background = bg;
sliderValue.setAttribute("data-length", slider.value);
}
// Object of all the function names that we will use to create random letters of password
const randomFunc = {
lower: getRandomLower,
upper: getRandomUpper,
number: getRandomNumber,
symbol: getRandomSymbol,
};
// Generator Functions
// All the functions that are responsible to return a random value taht we will use to create password.
function getRandomLower() {
return String.fromCharCode(Math.floor(Math.random() * 26) + 97);
}
function getRandomUpper() {
return String.fromCharCode(Math.floor(Math.random() * 26) + 65);
}
function getRandomNumber() {
return String.fromCharCode(Math.floor(Math.random() * 10) + 48);
}
function getRandomSymbol() {
const symbols = '~!@#$%^&*()_+{}":?><;.,';
return symbols[Math.floor(Math.random() * symbols.length)];
}
// Selecting all the DOM Elements that are necessary -->
// The Viewbox where the result will be shown
const resultEl = document.getElementById("result");
// The input slider, will use to change the length of the password
const lengthEl = document.getElementById("slider");
// Checkboxes representing the options that is responsible to create differnt type of password based on user
const uppercaseEl = document.getElementById("uppercase");
const lowercaseEl = document.getElementById("lowercase");
const numberEl = document.getElementById("number");
const symbolEl = document.getElementById("symbol");
// Button to generate the password
const generateBtn = document.getElementById("generate");
// Button to copy the text
const copyBtn = document.getElementById("copy-btn");
// Result viewbox container
const resultContainer = document.querySelector(".result");
// Text info showed after generate button is clicked
const copyInfo = document.querySelector(".result__info.right");
// Text appear after copy button is clicked
const copiedInfo = document.querySelector(".result__info.left");
// Update Css Props of the COPY button
// Getting the bounds of the result viewbox container
let resultContainerBound = {
left: resultContainer.getBoundingClientRect().left,
top: resultContainer.getBoundingClientRect().top,
};
// This will update the position of the copy button based on mouse Position
resultContainer.addEventListener("mousemove", e => {
copyBtn.style.setProperty("--x", `${e.x - resultContainerBound.left}px`);
copyBtn.style.setProperty("--y", `${e.y - resultContainerBound.top}px`);
});
window.addEventListener("resize", e => {
resultContainerBound = {
left: resultContainer.getBoundingClientRect().left,
top: resultContainer.getBoundingClientRect().top,
};
});
// Copy Password in clipboard
copyBtn.addEventListener("click", () => {
const textarea = document.createElement("textarea");
const password = resultEl.innerText;
if (!password || password == "CLICK GENERATE") {
return;
}
textarea.value = password;
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
textarea.remove();
copyInfo.style.transform = "translateY(200%)";
copyInfo.style.opacity = "0";
copiedInfo.style.transform = "translateY(0%)";
copiedInfo.style.opacity = "0.75";
});
// When Generate is clicked Password id generated.
generateBtn.addEventListener("click", () => {
const length = +lengthEl.value;
const hasLower = lowercaseEl.checked;
const hasUpper = uppercaseEl.checked;
const hasNumber = numberEl.checked;
const hasSymbol = symbolEl.checked;
resultEl.innerText = generatePassword(length, hasLower, hasUpper, hasNumber, hasSymbol);
copyInfo.style.transform = "translateY(0%)";
copyInfo.style.opacity = "0.75";
copiedInfo.style.transform = "translateY(200%)";
copiedInfo.style.opacity = "0";
});
// Function responsible to generate password and then returning it.
function generatePassword(length, lower, upper, number, symbol) {
let generatedPassword = "";
const typesCount = lower + upper + number + symbol;
const typesArr = [{ lower }, { upper }, { number }, { symbol }].filter(item => Object.values(item)[0]);
if (typesCount === 0) {
return "";
}
for (let i = 0; i < length; i++) {
typesArr.forEach(type => {
const funcName = Object.keys(type)[0];
generatedPassword += randomFunc[funcName]();
});
}
return generatedPassword.slice(0, length);
}

View File

@ -12,7 +12,7 @@
<div class="layui-layout layui-layout-admin"> <div class="layui-layout layui-layout-admin">
<div id="header"></div> <div id="header"></div>
<div class="layui-body" style="left: 0px;"> <div class="layui-body" style="left: 0px;">
主页暂时还没想好~~~~咕!
</div> </div>
<div id="footer"></div> <div id="footer"></div>
</div> </div>