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,4 +515,20 @@ public class UserController {
515 515
         N_Utils.validation(new Object[]{userid, "用户id", 1, usid, "密保id", 1, usanswer, "密保答案", 2});
516 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,4 +207,7 @@ public interface UserMapper extends TkMapper<TUser> {
207 207
 
208 208
     //获取手机号绑定的其他用户数量
209 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,4 +944,20 @@ public class UserService extends JedisUtil {
944 944
         if (!usanswer.equals(answer)) return new ResultVo(1, "输入答案有误");
945 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,6 +199,10 @@
199 199
     <select id="getNumByUserPhone" resultType="java.lang.Integer">
200 200
         select count(*) from t_user where userid!=#{userid} and userphone=#{userphone}
201 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 208
 </mapper>

Loading…
Cancel
Save