Browse Source

校验用户密码

tags/正式3.2.0
雍文秀 2 years ago
parent
commit
405361358c

+ 16
- 0
suser/src/main/java/com/xhkjedu/suser/controller/system/UserController.java View File

515
         N_Utils.validation(new Object[]{userid, "用户id", 1, usid, "密保id", 1, usanswer, "密保答案", 2});
515
         N_Utils.validation(new Object[]{userid, "用户id", 1, usid, "密保id", 1, usanswer, "密保答案", 2});
516
         return userService.checkUsecret(userid, usid, usanswer);
516
         return userService.checkUsecret(userid, usid, usanswer);
517
     }
517
     }
518
+
519
+    /**
520
+     * 校验用户密码
521
+     *
522
+     * @param [user]
523
+     * @return com.xhkjedu.vo.ResultVo
524
+     * @author ywx
525
+     * @date 2022/4/8 15:05
526
+     */
527
+    @PostMapping("/check_pwd")
528
+    public ResultVo checkPwd(@RequestBody TUser user) {
529
+        Integer userid = user.getUserid();
530
+        String loginpwd = user.getLoginpwd();
531
+        N_Utils.validation(new Object[]{userid, "用户id", 1, loginpwd, "密码", 2});
532
+        return userService.checkPwd(user);
533
+    }
518
 }
534
 }

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/system/UserMapper.java View File

207
 
207
 
208
     //获取手机号绑定的其他用户数量
208
     //获取手机号绑定的其他用户数量
209
     Integer getNumByUserPhone(Integer userid, String userphone);
209
     Integer getNumByUserPhone(Integer userid, String userphone);
210
+
211
+    //根据用户id获取密码
212
+    String getPwdByUserId(Integer userid);
210
 }
213
 }

+ 16
- 0
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java View File

944
         if (!usanswer.equals(answer)) return new ResultVo(1, "输入答案有误");
944
         if (!usanswer.equals(answer)) return new ResultVo(1, "输入答案有误");
945
         return new ResultVo(0, "校验密保答案成功");
945
         return new ResultVo(0, "校验密保答案成功");
946
     }
946
     }
947
+
948
+    /**
949
+     * 校验用户密码
950
+     *
951
+     * @param [user]
952
+     * @return com.xhkjedu.vo.ResultVo
953
+     * @author ywx
954
+     * @date 2022/4/8 15:05
955
+     */
956
+    public ResultVo checkPwd(TUser user) {
957
+        String pwd = userMapper.getPwdByUserId(user.getUserid());
958
+        setLoginPwd(user);
959
+        String loginpwd = user.getLoginpwd();
960
+        if (!loginpwd.equals(pwd)) return new ResultVo(1, "密码不正确");
961
+        return new ResultVo(0, "密码正确");
962
+    }
947
 }
963
 }

+ 4
- 0
suser/src/main/resources/mapper/system/UserMapper.xml View File

199
     <select id="getNumByUserPhone" resultType="java.lang.Integer">
199
     <select id="getNumByUserPhone" resultType="java.lang.Integer">
200
         select count(*) from t_user where userid!=#{userid} and userphone=#{userphone}
200
         select count(*) from t_user where userid!=#{userid} and userphone=#{userphone}
201
     </select>
201
     </select>
202
+    <!--根据用户id获取密码-->
203
+    <select id="getPwdByUserId" resultType="java.lang.String">
204
+        select loginpwd from t_user where userid=#{userid}
205
+    </select>
202
 
206
 
203
 
207
 
204
 </mapper>
208
 </mapper>

Loading…
Cancel
Save