密码管理器新增搜索功能,all.do添加更多信息

This commit is contained in:
Yutousama 2021-06-19 02:37:14 +08:00
parent d6734600fe
commit 2fb30737af
3 changed files with 14 additions and 3 deletions

View File

@ -61,7 +61,7 @@ public class PasswordManager {
} }
@ResponseBody @ResponseBody
@RequestMapping(value = "get/all.do",method = RequestMethod.GET) @RequestMapping(value = "get/all.do",method = RequestMethod.GET)
public String getAllPassword(HttpServletRequest request){ public String getAllPassword(HttpServletRequest request,String search){
JSONObject json=new JSONObject(); JSONObject json=new JSONObject();
JSONArray array=new JSONArray(); JSONArray array=new JSONArray();
int uid=tls.getUid(request); int uid=tls.getUid(request);
@ -69,13 +69,19 @@ public class PasswordManager {
return ""; return "";
} }
ToolsPasswordExample example=new ToolsPasswordExample(); ToolsPasswordExample example=new ToolsPasswordExample();
example.createCriteria().andUidEqualTo(uid); ToolsPasswordExample.Criteria criteria=example.createCriteria();
criteria.andUidEqualTo(uid);
if(!StringUtils.isEmpty(search)){
criteria.search(search);
}
List<ToolsPassword> list=passwordDao.selectByExample(example); List<ToolsPassword> list=passwordDao.selectByExample(example);
for (ToolsPassword password : list) { for (ToolsPassword password : list) {
JSONObject item=new JSONObject(); JSONObject item=new JSONObject();
item.put("id",password.getId()); item.put("id",password.getId());
item.put("account",password.getUsername()); item.put("account",password.getUsername());
item.put("title",password.getTitle()); item.put("title",password.getTitle());
item.put("desc",password.getInfo());
item.put("url",password.getUrl());
item.put("password",AESTools.decrypt(password.getPassword())); item.put("password",AESTools.decrypt(password.getPassword()));
array.add(item); array.add(item);
} }

View File

@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class ToolsApplication { public class ToolsApplication {
public static final String version="1.1.3"; public static final String version="1.1.4";
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("当前版本号:" + version); System.out.println("当前版本号:" + version);

View File

@ -104,6 +104,11 @@ public class ToolsPasswordExample {
criteria.add(new Criterion(condition, value1, value2)); criteria.add(new Criterion(condition, value1, value2));
} }
public Criteria search(String value){
addCriterion("title like '%"+value+"%' or `info` like '%"+value+"%' or `url` like '%"+value+"%'");
return (Criteria) this;
}
public Criteria andIdIsNull() { public Criteria andIdIsNull() {
addCriterion("id is null"); addCriterion("id is null");
return (Criteria) this; return (Criteria) this;