| | |
| | | } |
| | | //修改密码 |
| | | public Response changeSnId(String name,String oldSnId, String newSnId) { |
| | | if(name==null||name.equals("")){ |
| | | return new Response().set(1,false,"找不到用户"); |
| | | } |
| | | //验证老密码是否正确 |
| | | String snIdRsa=mapper.selectSnId(name); |
| | | //解密 |
| | | String snId=RSAUtil.decrypt(snIdRsa,RSAUtil.getPrivateKey()); |
| | | if(oldSnId.equals(snId)){ |
| | | String[] decOld=RSAUtil.decryptFrontP(oldSnId,RSAUtil.fontSeparator); |
| | | String oldId=decOld[0]; |
| | | String[] newOld=RSAUtil.decryptFrontP(newSnId,RSAUtil.fontSeparator); |
| | | String newId=newOld[0]; |
| | | if(oldId.equals(snId)){ |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.set("sn_id",RSAUtil.encrypt(newSnId,RSAUtil.getPublicKey())); |
| | | wrapper.set("sn_id",RSAUtil.encrypt(newId,RSAUtil.getPublicKey())); |
| | | wrapper.eq("name",name); |
| | | int bl=mapper.update(null,wrapper); |
| | | return new Response().set(1,bl>0?true:false,"修改成功"); |
| | | }else { |
| | | return new Response().set(1,false,"密码错误"); |
| | | return new Response().set(1,false,"旧密码不正确"); |
| | | } |
| | | } |
| | | } |