From bbaecbf976781dcd187f9f179cc41ed136ca434d Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Sat, 6 Nov 2021 16:07:02 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=96=B0=E5=A2=9E=E6=8B=BC?=
=?UTF-8?q?=E9=9F=B3=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=8F=AF=E9=80=9A=E8=BF=87?=
=?UTF-8?q?=E6=8B=BC=E9=9F=B3=E6=9F=A5=E6=89=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 12 ++--
.../yutou/tools/Tools/PasswordManager.java | 3 +
.../com/yutou/tools/ToolsApplication.java | 2 +-
.../tools/mybatis/model/ToolsPassword.java | 2 +
.../mybatis/model/ToolsPasswordExample.java | 72 ++++++++++++++++++-
.../java/com/yutou/tools/utils/Tools.java | 66 +++++++++++------
.../resources/mapper/ToolsPasswordDao.xml | 29 ++++++--
7 files changed, 148 insertions(+), 38 deletions(-)
diff --git a/pom.xml b/pom.xml
index 34cec30..7d903fd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
redis.clients
jedis
- 3.2.0
+ 3.6.3
org.springframework.data
@@ -69,20 +69,20 @@
org.mybatis.spring.boot
mybatis-spring-boot-starter
- 2.1.1
+ 2.2.0
org.projectlombok
lombok
- 1.18.12
+ 1.18.22
provided
com.alibaba
fastjson
- 1.2.67
+ 1.2.78
@@ -93,13 +93,13 @@
com.aliyun.oss
aliyun-sdk-oss
- 3.8.0
+ 3.13.2
org.xerial
sqlite-jdbc
- 3.28.0
+ 3.36.0.2
diff --git a/src/main/java/com/yutou/tools/Tools/PasswordManager.java b/src/main/java/com/yutou/tools/Tools/PasswordManager.java
index 4cd9d8a..e7f2526 100644
--- a/src/main/java/com/yutou/tools/Tools/PasswordManager.java
+++ b/src/main/java/com/yutou/tools/Tools/PasswordManager.java
@@ -10,6 +10,8 @@ import com.yutou.tools.mybatis.model.ToolsPasswordType;
import com.yutou.tools.mybatis.model.ToolsPasswordTypeExample;
import com.yutou.tools.other.tools;
import com.yutou.tools.utils.AESTools;
+import com.yutou.tools.utils.HttpTools;
+import com.yutou.tools.utils.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -156,6 +158,7 @@ public class PasswordManager {
}
ToolsPassword toolsPassword=new ToolsPassword();
toolsPassword.setTitle(title);
+ toolsPassword.setTitlePinyin(Tools.getPinYin(title));
toolsPassword.setUsername(username);
toolsPassword.setPassword(AESTools.encrypt(password));
toolsPassword.setType(Integer.parseInt(type));
diff --git a/src/main/java/com/yutou/tools/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java
index 38e257f..c97ad19 100644
--- a/src/main/java/com/yutou/tools/ToolsApplication.java
+++ b/src/main/java/com/yutou/tools/ToolsApplication.java
@@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ToolsApplication {
- public static final String version="1.3";
+ public static final String version="1.4";
public static void main(String[] args) {
System.out.println("当前版本号:" + version);
diff --git a/src/main/java/com/yutou/tools/mybatis/model/ToolsPassword.java b/src/main/java/com/yutou/tools/mybatis/model/ToolsPassword.java
index 5fcbfc8..85cb495 100644
--- a/src/main/java/com/yutou/tools/mybatis/model/ToolsPassword.java
+++ b/src/main/java/com/yutou/tools/mybatis/model/ToolsPassword.java
@@ -13,6 +13,8 @@ public class ToolsPassword implements Serializable {
private String title;
+ private String titlePinyin;
+
private String username;
private String password;
diff --git a/src/main/java/com/yutou/tools/mybatis/model/ToolsPasswordExample.java b/src/main/java/com/yutou/tools/mybatis/model/ToolsPasswordExample.java
index c4cd053..f15f6d3 100644
--- a/src/main/java/com/yutou/tools/mybatis/model/ToolsPasswordExample.java
+++ b/src/main/java/com/yutou/tools/mybatis/model/ToolsPasswordExample.java
@@ -105,7 +105,7 @@ public class ToolsPasswordExample {
}
public Criteria search(String value){
- addCriterion("title like '%"+value+"%' or `info` like '%"+value+"%' or `url` like '%"+value+"%'");
+ addCriterion("title like '%"+value+"%' or `info` like '%"+value+"%' or `url` like '%"+value+"%' or `title_pinyin` like '%"+value+"%'");
return (Criteria) this;
}
@@ -239,6 +239,76 @@ public class ToolsPasswordExample {
return (Criteria) this;
}
+ public Criteria andTitlePinyinIsNull() {
+ addCriterion("title_pinyin is null");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinIsNotNull() {
+ addCriterion("title_pinyin is not null");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinEqualTo(String value) {
+ addCriterion("title_pinyin =", value, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinNotEqualTo(String value) {
+ addCriterion("title_pinyin <>", value, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinGreaterThan(String value) {
+ addCriterion("title_pinyin >", value, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinGreaterThanOrEqualTo(String value) {
+ addCriterion("title_pinyin >=", value, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinLessThan(String value) {
+ addCriterion("title_pinyin <", value, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinLessThanOrEqualTo(String value) {
+ addCriterion("title_pinyin <=", value, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinLike(String value) {
+ addCriterion("title_pinyin like", value, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinNotLike(String value) {
+ addCriterion("title_pinyin not like", value, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinIn(List values) {
+ addCriterion("title_pinyin in", values, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinNotIn(List values) {
+ addCriterion("title_pinyin not in", values, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinBetween(String value1, String value2) {
+ addCriterion("title_pinyin between", value1, value2, "titlePinyin");
+ return (Criteria) this;
+ }
+
+ public Criteria andTitlePinyinNotBetween(String value1, String value2) {
+ addCriterion("title_pinyin not between", value1, value2, "titlePinyin");
+ return (Criteria) this;
+ }
+
public Criteria andUsernameIsNull() {
addCriterion("username is null");
return (Criteria) this;
diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java
index 2d46409..9acd070 100644
--- a/src/main/java/com/yutou/tools/utils/Tools.java
+++ b/src/main/java/com/yutou/tools/utils/Tools.java
@@ -1,6 +1,7 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.interfaces.DownloadInterface;
import com.yutou.tools.nas.UpdateIp;
import org.apache.commons.codec.digest.DigestUtils;
@@ -103,8 +104,8 @@ public class Tools {
try {
System.out.println("title=" + title + " msg=" + msg);
HttpTools.post("https://sctapi.ftqq.com/SCT2619Tpqu93OYtQCrK4LOZYEfr2irm.send",
- ("title="+URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8));
- if (!StringUtils.isEmpty(UpdateIp.nas_ip)) {
+ ("title=" + URLEncoder.encode(title, "UTF-8") + "&desp=" + URLEncoder.encode(msg, "UTF-8")).getBytes(StandardCharsets.UTF_8));
+ if (!StringUtils.isEmpty(UpdateIp.nas_ip)) {
String img = null;
msg = msg.replace("
", "\n");
if (msg.contains("![logo]")) {
@@ -268,7 +269,8 @@ public class Tools {
downloadInterface.onError(e);
}
}
- public static ResponseEntity getFile(File file,MediaType mediaType){
+
+ public static ResponseEntity getFile(File file, MediaType mediaType) {
HttpHeaders headers = new HttpHeaders();
//headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
try {
@@ -277,14 +279,15 @@ public class Tools {
headers.add("Content-Disposition", "attachment; filename=" + file.getName());
}
//headers.add("Pragma", "no-cache");
- // headers.add("Expires", "0");
- // headers.add("Last-Modified", new Date().toString());
- // headers.add("ETag", String.valueOf(System.currentTimeMillis()));
+ // headers.add("Expires", "0");
+ // headers.add("Last-Modified", new Date().toString());
+ // headers.add("ETag", String.valueOf(System.currentTimeMillis()));
headers.remove("Vary");
headers.remove("Connection");
headers.remove("Content-Disposition");
return ResponseEntity.ok().headers(headers).contentLength(file.length()).contentType(mediaType).body(new FileSystemResource(file));
}
+
/**
* 构造给前端的文件
*
@@ -292,7 +295,7 @@ public class Tools {
* @return 前端获取的文件
*/
public static ResponseEntity getFile(File file) {
- return getFile(file,MediaType.parseMediaType("application/octet-stream"));
+ return getFile(file, MediaType.parseMediaType("application/octet-stream"));
}
public static String getFileMD5(File file) {
@@ -369,8 +372,9 @@ public class Tools {
/**
* 扫描使用注解的类
+ *
* @param packageName 扫描包名
- * @param annotation 注解类
+ * @param annotation 注解类
* @return 扫描到的集合
*/
public static List scanClass(String packageName, Class extends Annotation> annotation) {
@@ -407,40 +411,43 @@ public class Tools {
/**
* 获取Url
+ *
* @param packageName 扫描包名
- * @param className 指定类,如无指定类,为null即可
+ * @param className 指定类,如无指定类,为null即可
* @return url集合
*/
- public static List getUrls(String packageName,String className){
- List list= scanClass(packageName, Controller.class);
- List urls=new ArrayList<>();
+ public static List getUrls(String packageName, String className) {
+ List list = scanClass(packageName, Controller.class);
+ List urls = new ArrayList<>();
for (Class aClass : list) {
- if(className!=null&&!aClass.getSimpleName().equals(className)){
+ if (className != null && !aClass.getSimpleName().equals(className)) {
continue;
}
- Method[] methods= aClass.getDeclaredMethods();
+ Method[] methods = aClass.getDeclaredMethods();
for (Method method : methods) {
- RequestMapping ls=method.getAnnotation(RequestMapping.class);
- if(ls!=null) {
+ RequestMapping ls = method.getAnnotation(RequestMapping.class);
+ if (ls != null) {
urls.add(ls.value()[0]);
}
}
}
return urls;
}
- public static String getLoginUser(){
- Object user= SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- if(user instanceof String){
+
+ public static String getLoginUser() {
+ Object user = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
+ if (user instanceof String) {
return (String) user;
- }else {
- return ((User)user).getUsername();
+ } else {
+ return ((User) user).getUsername();
}
}
- public static boolean isAdminLogin(){
+
+ public static boolean isAdminLogin() {
return "admin".equals(getLoginUser());
}
- public static String getMD5(String str){
+ public static String getMD5(String str) {
return DigestUtils.md5Hex(str);
}
@@ -448,4 +455,17 @@ public class Tools {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
}
+ public static String getPinYin(String text) {
+ try {
+ String pinyin = HttpTools.get("https://hn216.api.yesapi.cn/?s=Ext.Pinyin.Convert&return_data=0&text=" + URLEncoder.encode(text, "UTF-8") + "&app_key=C0A906F8C2E21E8B31103458D7B38F93&sign=1B49164601BB2F2C9E189353598A56B5");
+ JSONObject json = JSONObject.parseObject(pinyin);
+ if (json.getInteger("ret") == 200) {
+ return json.getJSONObject("data").getString("pinyin").trim().replace(" ", "");
+ }
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
}
diff --git a/src/main/resources/mapper/ToolsPasswordDao.xml b/src/main/resources/mapper/ToolsPasswordDao.xml
index fe62d79..06cddfb 100644
--- a/src/main/resources/mapper/ToolsPasswordDao.xml
+++ b/src/main/resources/mapper/ToolsPasswordDao.xml
@@ -4,6 +4,7 @@
+
@@ -70,7 +71,7 @@
- id, title, username, `password`, url, info, `type`, `uid`
+ id, title, title_pinyin, username, `password`, url, info, `type`, `uid`