This commit is contained in:
yutou 2021-02-22 18:35:18 +08:00
parent dde0f58cca
commit 52e5072f9e

View File

@ -73,6 +73,7 @@ public class PasswordManager {
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("account",password.getUsername()); item.put("account",password.getUsername());
item.put("title",password.getTitle()); item.put("title",password.getTitle());
item.put("password",AESTools.decrypt(password.getPassword())); item.put("password",AESTools.decrypt(password.getPassword()));
@ -120,11 +121,34 @@ public class PasswordManager {
JSONObject json=new JSONObject(); JSONObject json=new JSONObject();
try{ try{
if(StringUtils.isEmpty(title)||StringUtils.isEmpty(username)||StringUtils.isEmpty(password)||StringUtils.isEmpty(type)){ if(StringUtils.isEmpty(title)||StringUtils.isEmpty(username)||StringUtils.isEmpty(password)||StringUtils.isEmpty(type)){
System.out.println("tt "+request.getParameter("title"));
System.out.println("title = " + title + ", username = " + username + ", password = " + password + ", url = " + url + ", info = " + info + ", type = " + type);
json.put("code",-1); json.put("code",-1);
json.put("msg","有参数为空"); json.put("msg","有参数为空");
return json.toJSONString(); return json.toJSONString();
} }
int uid=tls.getUid(request); int uid=tls.getUid(request);
if(uid==-1){
json.put("code",-1);
json.put("msg","有参数为空");
return json.toJSONString();
}
if("-1".equals(type)){
int _type=-1;
ToolsPasswordTypeExample typeExample=new ToolsPasswordTypeExample();
typeExample.createCriteria().andTitleEqualTo("默认");
if(passwordTypeDao.selectByExample(typeExample).isEmpty()){
ToolsPasswordType passwordType=new ToolsPasswordType();
passwordType.setTitle("默认");
passwordType.setUid(uid);
passwordTypeDao.insert(passwordType);
_type=passwordTypeDao.selectByExample(typeExample).get(0).getId();
}else{
List<ToolsPasswordType> _type_list= passwordTypeDao.selectByExample(typeExample);
_type=_type_list.get(_type_list.size()-1).getId();
}
type=_type+"";
}
ToolsPassword toolsPassword=new ToolsPassword(); ToolsPassword toolsPassword=new ToolsPassword();
toolsPassword.setTitle(title); toolsPassword.setTitle(title);
toolsPassword.setUsername(username); toolsPassword.setUsername(username);