Pārlūkot izejas kodu

校验用户密保答案

tags/正式3.2.0
雍文秀 pirms 2 gadiem
vecāks
revīzija
f5cee991f8

+ 16
- 0
suser/src/main/java/com/xhkjedu/suser/controller/system/UserController.java Parādīt failu

@@ -499,4 +499,20 @@ public class UserController {
499 499
         N_Utils.validation(new Object[]{userphone, "手机号", 2});
500 500
         return userService.bindCode(userphone);
501 501
     }
502
+
503
+    /**
504
+     * 校验用户密保答案
505
+     * @param [user]
506
+     * @return com.xhkjedu.vo.ResultVo
507
+     * @author ywx
508
+     * @date 2022/4/7 16:16
509
+     */
510
+    @PostMapping("/check_usecret")
511
+    public ResultVo checkUsecret(@RequestBody TUserUsecret user) {
512
+        Integer userid = user.getUserid();
513
+        Integer usid = user.getUsid();
514
+        String usanswer = user.getUsanswer();
515
+        N_Utils.validation(new Object[]{userid, "用户id", 1, usid, "密保id", 1, usanswer, "密保答案", 2});
516
+        return userService.checkUsecret(userid, usid, usanswer);
517
+    }
502 518
 }

+ 3
- 0
suser/src/main/java/com/xhkjedu/suser/mapper/system/UserUsecretMapper.java Parādīt failu

@@ -17,4 +17,7 @@ public interface UserUsecretMapper extends TkMapper<TUserUsecret> {
17 17
 
18 18
     //根据用户id获取关联密保
19 19
     List<Map> listUsecret(Integer userid);
20
+
21
+    //获取用户密保答案
22
+    String getAnswerById(Integer userid, Integer usid);
20 23
 }

+ 15
- 0
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java Parādīt failu

@@ -929,4 +929,19 @@ public class UserService extends JedisUtil {
929 929
         if (generateCode(userphone, templateCode)) return new ResultVo(1, "请输入验证码或者在5分钟之后重新点击");
930 930
         return new ResultVo(0, "生成绑定手机码成功");
931 931
     }
932
+
933
+    /**
934
+     * 校验用户密保答案
935
+     *
936
+     * @param [userid, usid, usanswer]
937
+     * @return com.xhkjedu.vo.ResultVo
938
+     * @author ywx
939
+     * @date 2022/4/7 16:15
940
+     */
941
+    public ResultVo checkUsecret(Integer userid, Integer usid, String usanswer) {
942
+        //获取用户密保答案
943
+        String answer = userUsecretMapper.getAnswerById(userid, usid);
944
+        if (!usanswer.equals(answer)) return new ResultVo(1, "输入答案有误");
945
+        return new ResultVo(0, "校验密保答案成功");
946
+    }
932 947
 }

+ 5
- 1
suser/src/main/resources/mapper/system/UserUsecertMapper.xml Parādīt failu

@@ -11,8 +11,12 @@
11 11
     </delete>
12 12
     <!--根据用户id获取关联密保-->
13 13
     <select id="listUsecret" resultType="java.util.Map">
14
-        select uu.usid,uu.usanswer
14
+        select uu.usid
15 15
         ,(select u.sname from t_usecret u where u.usid=uu.usid)sname
16 16
         from t_user_usecret uu where uu.userid=#{userid}
17 17
     </select>
18
+    <!--获取用户密保答案-->
19
+    <select id="getAnswerById" resultType="java.lang.String">
20
+        select uu.usanswer from t_user_usecret uu where uu.userid=#{userid} and uu.usid=#{usid} limit 1
21
+    </select>
18 22
 </mapper>

Notiek ielāde…
Atcelt
Saglabāt