新增页面

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

View File

@@ -7,6 +7,7 @@ import com.yutou.tools.mybatis.model.BilibiliLive;
import com.yutou.tools.mybatis.model.BilibiliLiveExample;
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.ResponseBody;
@@ -56,4 +57,45 @@ public class Live {
json.put("data",JSONArray.toJSON(list));
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();
File file = new File("/etc/nginx/nginx.conf");
file = new File("D:\\nginx.conf");
//file = new File("D:\\nginx.conf");
if (file.exists()) {
String testIp = "0.0.0.0";
try {

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;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.UKeyExample;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -18,19 +21,39 @@ public class APIFilter implements Filter {
UKeyDao keyDao;
@Resource
RedisTools redisTools;
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request= (HttpServletRequest) servletRequest;
String token=request.getParameter("token");
System.out.println("接收到请求:"+request.getRequestURI()+" "+token);
if(token==null&&redisTools.get(request.getSession().getId())==null&&!request.getRequestURI().equals("/")){
System.out.println("请求无令牌,拦截");
//((HttpServletResponse)servletResponse).sendRedirect("/");
//return;
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response= (HttpServletResponse) servletResponse;
String token = request.getParameter("token");
Cookie cookie = Tools.getCookie(request, "user");
System.out.println("接收到请求:" + request.getRequestURI() + " " + token);
boolean isToken = false;
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);
//return;
} else if (!isCookie) {
System.out.println("请求无令牌,拦截");
}
if (!isCookie && !isToken) {
//response.sendRedirect("/");
if(!request.getRequestURI().contains("/login/")){
response.sendRedirect("/");
return;
}
}
filterChain.doFilter(servletRequest, servletResponse);
}

View File

@@ -6,18 +6,28 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;
@Component
public class RedisTools {
@Resource
RedisTemplate<String,String> redisTemplate;
public void set(String key,String value){
redisTemplate.opsForValue().set(key,value);
RedisTemplate<String, String> redisTemplate;
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) {
cookie.setMaxAge(time);
}
cookie.setPath("/");
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
@@ -54,11 +37,16 @@ public class Tools {
*/
public static Cookie getCookie(HttpServletRequest request,String key) {
Cookie[] cookies = request.getCookies();
for (Cookie cookie : cookies) {
if (key!=null&&cookie.getName().equals(key)) {
return cookie;
try {
for (Cookie cookie : cookies) {
if (key!=null&&cookie.getName().equals(key)) {
return cookie;
}
}
}catch (Exception ignored){
}
return null;
}
/**
@@ -69,18 +57,27 @@ public class Tools {
* @return
*/
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){
try{
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();
connection.connect();
InputStream inputStream=connection.getInputStream();
int i=inputStream.read();
inputStream.close();
connection.disconnect();*/
connection.disconnect();
}catch (Exception e){
e.printStackTrace();
}

View File

@@ -7,6 +7,7 @@ import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import org.springframework.stereotype.Controller;
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;
@@ -27,11 +28,13 @@ public class userController {
JSONObject json = new JSONObject();
json.put("code", -1);
json.put("msg", "未登录");
JSONArray array=new JSONArray();
if(redisTools.get("bean")!=null){
array=JSONArray.parseArray(redisTools.get("bean"));
JSONArray array = new JSONArray();
if (redisTools.get("ban") != null) {
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已被封禁");
return json.toJSONString();
}
@@ -39,7 +42,7 @@ public class userController {
if (cookie == null) {
return json.toJSONString();
}
if (redisTools.get(cookie.getValue()).equals("ok")) {
if ("ok".equals(redisTools.get(cookie.getValue()))) {
json.put("code", 0);
json.put("msg", "登录成功");
return json.toJSONString();
@@ -52,31 +55,78 @@ public class userController {
@RequestMapping("/login/sendCaptcha.do")
@ResponseBody
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 = "";
for (int value : captcha) {
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
+ ",登录IP:" + Tools.getRemoteAddress(request)
+ ",非正常登录封禁IP:http://www.baidu.com");
+ ",非正常登录封禁IP:"+url);
return "ok";
}
@RequestMapping("/login/login.do")
@RequestMapping("/login/ban.do")
@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*1000);
redisTools.set(uuid.replace("-",""),"ok",30*24*60*60*1000);
json.put("code",0);
json.put("msg","登录成功");
public String banIp(String token){
String ip=redisTools.get(token);
if(ip!=null){
JSONArray array = new JSONArray();
if (redisTools.get("ban") != null) {
array = JSONArray.parseArray(redisTools.get("bean"));
}
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();
}
json.put("code",-2);
json.put("msg","登录安全码错误");
return json.toJSONString();
json.put("code", -2);
json.put("msg", "登录安全码错误");
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>