密码新增拼音字段,可通过拼音查找
This commit is contained in:
parent
c2098ec827
commit
bbaecbf976
12
pom.xml
12
pom.xml
@ -54,7 +54,7 @@
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
@ -69,20 +69,20 @@
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<version>1.18.22</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.67</version>
|
||||
<version>1.2.78</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
|
||||
<dependency>
|
||||
@ -93,13 +93,13 @@
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>3.13.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.28.0</version>
|
||||
<version>3.36.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -13,6 +13,8 @@ public class ToolsPassword implements Serializable {
|
||||
|
||||
private String title;
|
||||
|
||||
private String titlePinyin;
|
||||
|
||||
private String username;
|
||||
|
||||
private String password;
|
||||
|
@ -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<String> values) {
|
||||
addCriterion("title_pinyin in", values, "titlePinyin");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTitlePinyinNotIn(List<String> 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;
|
||||
|
@ -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,7 +104,7 @@ 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));
|
||||
("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("<br/>", "\n");
|
||||
@ -268,7 +269,8 @@ public class Tools {
|
||||
downloadInterface.onError(e);
|
||||
}
|
||||
}
|
||||
public static ResponseEntity<FileSystemResource> getFile(File file,MediaType mediaType){
|
||||
|
||||
public static ResponseEntity<FileSystemResource> getFile(File file, MediaType mediaType) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
//headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
try {
|
||||
@ -285,6 +287,7 @@ public class Tools {
|
||||
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<FileSystemResource> 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,6 +372,7 @@ public class Tools {
|
||||
|
||||
/**
|
||||
* 扫描使用注解的类
|
||||
*
|
||||
* @param packageName 扫描包名
|
||||
* @param annotation 注解类
|
||||
* @return 扫描到的集合
|
||||
@ -407,40 +411,43 @@ public class Tools {
|
||||
|
||||
/**
|
||||
* 获取Url
|
||||
*
|
||||
* @param packageName 扫描包名
|
||||
* @param className 指定类,如无指定类,为null即可
|
||||
* @return url集合
|
||||
*/
|
||||
public static List<String> getUrls(String packageName,String className){
|
||||
List<Class> list= scanClass(packageName, Controller.class);
|
||||
List<String> urls=new ArrayList<>();
|
||||
public static List<String> getUrls(String packageName, String className) {
|
||||
List<Class> list = scanClass(packageName, Controller.class);
|
||||
List<String> 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 "";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
<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="title_pinyin" jdbcType="VARCHAR" property="titlePinyin" />
|
||||
<result column="username" jdbcType="VARCHAR" property="username" />
|
||||
<result column="password" jdbcType="VARCHAR" property="password" />
|
||||
<result column="url" jdbcType="VARCHAR" property="url" />
|
||||
@ -70,7 +71,7 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, title, username, `password`, url, info, `type`, `uid`
|
||||
id, title, title_pinyin, username, `password`, url, info, `type`, `uid`
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="com.yutou.tools.mybatis.model.ToolsPasswordExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -103,12 +104,12 @@
|
||||
</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`, `uid`
|
||||
)
|
||||
values (#{title,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
|
||||
#{url,jdbcType=VARCHAR}, #{info,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}
|
||||
)
|
||||
insert into tools_password (title, title_pinyin, username,
|
||||
`password`, url, info,
|
||||
`type`, `uid`)
|
||||
values (#{title,jdbcType=VARCHAR}, #{titlePinyin,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR},
|
||||
#{password,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{info,jdbcType=VARCHAR},
|
||||
#{type,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER})
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.ToolsPassword" useGeneratedKeys="true">
|
||||
insert into tools_password
|
||||
@ -116,6 +117,9 @@
|
||||
<if test="title != null">
|
||||
title,
|
||||
</if>
|
||||
<if test="titlePinyin != null">
|
||||
title_pinyin,
|
||||
</if>
|
||||
<if test="username != null">
|
||||
username,
|
||||
</if>
|
||||
@ -139,6 +143,9 @@
|
||||
<if test="title != null">
|
||||
#{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="titlePinyin != null">
|
||||
#{titlePinyin,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="username != null">
|
||||
#{username,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -174,6 +181,9 @@
|
||||
<if test="record.title != null">
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.titlePinyin != null">
|
||||
title_pinyin = #{record.titlePinyin,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.username != null">
|
||||
username = #{record.username,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -201,6 +211,7 @@
|
||||
update tools_password
|
||||
set id = #{record.id,jdbcType=INTEGER},
|
||||
title = #{record.title,jdbcType=VARCHAR},
|
||||
title_pinyin = #{record.titlePinyin,jdbcType=VARCHAR},
|
||||
username = #{record.username,jdbcType=VARCHAR},
|
||||
`password` = #{record.password,jdbcType=VARCHAR},
|
||||
url = #{record.url,jdbcType=VARCHAR},
|
||||
@ -217,6 +228,9 @@
|
||||
<if test="title != null">
|
||||
title = #{title,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="titlePinyin != null">
|
||||
title_pinyin = #{titlePinyin,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="username != null">
|
||||
username = #{username,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -241,6 +255,7 @@
|
||||
<update id="updateByPrimaryKey" parameterType="com.yutou.tools.mybatis.model.ToolsPassword">
|
||||
update tools_password
|
||||
set title = #{title,jdbcType=VARCHAR},
|
||||
title_pinyin = #{titlePinyin,jdbcType=VARCHAR},
|
||||
username = #{username,jdbcType=VARCHAR},
|
||||
`password` = #{password,jdbcType=VARCHAR},
|
||||
url = #{url,jdbcType=VARCHAR},
|
||||
|
Loading…
Reference in New Issue
Block a user