Browse Source

Merge remote-tracking branch 'cloud-schoolapi/ywx'

tags/正式3.2.0
王宁 2 years ago
parent
commit
e9e62b33af

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

499
         N_Utils.validation(new Object[]{userphone, "手机号", 2});
499
         N_Utils.validation(new Object[]{userphone, "手机号", 2});
500
         return userService.bindCode(userphone);
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
- 2
suser/src/main/java/com/xhkjedu/suser/mapper/system/MsgMapper.java View File

5
 
5
 
6
 public interface MsgMapper extends TkMapper<TMsg> {
6
 public interface MsgMapper extends TkMapper<TMsg> {
7
     /**
7
     /**
8
-     * 5分钟内发送短信次数
8
+     * 1分钟内发送短信次数
9
+     *
10
+     * @return java.lang.Integer
9
      * @Param [userphone]
11
      * @Param [userphone]
10
      * @Author ywx
12
      * @Author ywx
11
      * @Date 2020/10/15 16:55
13
      * @Date 2020/10/15 16:55
12
-     * @return java.lang.Integer
13
      **/
14
      **/
14
     Integer getMsgNumByUserPhone(String userphone);
15
     Integer getMsgNumByUserPhone(String userphone);
15
 
16
 

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

17
 
17
 
18
     //根据用户id获取关联密保
18
     //根据用户id获取关联密保
19
     List<Map> listUsecret(Integer userid);
19
     List<Map> listUsecret(Integer userid);
20
+
21
+    //获取用户密保答案
22
+    String getAnswerById(Integer userid, Integer usid);
20
 }
23
 }

+ 19
- 4
suser/src/main/java/com/xhkjedu/suser/service/system/UserService.java View File

628
      **/
628
      **/
629
     public ResultVo updateCode(String userphone) {
629
     public ResultVo updateCode(String userphone) {
630
         String templateCode = "xgmm";
630
         String templateCode = "xgmm";
631
-        if (generateCode(userphone, templateCode)) return new ResultVo(1, "请输入验证码或者在5分钟之后重新点击");
631
+        if (generateCode(userphone, templateCode)) return new ResultVo(1, "请输入验证码或者在1分钟之后重新点击");
632
         return new ResultVo(0, "生成修改码成功");
632
         return new ResultVo(0, "生成修改码成功");
633
     }
633
     }
634
 
634
 
641
      * @Date 2020/5/8 10:04
641
      * @Date 2020/5/8 10:04
642
      **/
642
      **/
643
     private boolean generateCode(String userphone, String templateCode) {
643
     private boolean generateCode(String userphone, String templateCode) {
644
-        Integer msgNum = msgMapper.getMsgNumByUserPhone(userphone);//5分钟内发送短信次数
644
+        Integer msgNum = msgMapper.getMsgNumByUserPhone(userphone);//1分钟内发送短信次数
645
         if (msgNum != 0) return true;
645
         if (msgNum != 0) return true;
646
 
646
 
647
         Integer messageCode = N_Utils.messageCode();
647
         Integer messageCode = N_Utils.messageCode();
718
     public ResultVo loginCode(String userphone) {
718
     public ResultVo loginCode(String userphone) {
719
         N_Utils.validation(new Object[]{userphone, "手机号", 2});
719
         N_Utils.validation(new Object[]{userphone, "手机号", 2});
720
         String templateCode = "dlqr";
720
         String templateCode = "dlqr";
721
-        if (generateCode(userphone, templateCode)) return new ResultVo(1, "请输入验证码或者在5分钟之后重新点击");
721
+        if (generateCode(userphone, templateCode)) return new ResultVo(1, "请输入验证码或者在1分钟之后重新点击");
722
         return new ResultVo(0, "生成登录确认码成功");
722
         return new ResultVo(0, "生成登录确认码成功");
723
     }
723
     }
724
 
724
 
926
      */
926
      */
927
     public ResultVo bindCode(String userphone) {
927
     public ResultVo bindCode(String userphone) {
928
         String templateCode = "bdsj";
928
         String templateCode = "bdsj";
929
-        if (generateCode(userphone, templateCode)) return new ResultVo(1, "请输入验证码或者在5分钟之后重新点击");
929
+        if (generateCode(userphone, templateCode)) return new ResultVo(1, "请输入验证码或者在1分钟之后重新点击");
930
         return new ResultVo(0, "生成绑定手机码成功");
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
 }

+ 2
- 2
suser/src/main/resources/mapper/system/MsgMapper.xml View File

1
 <?xml version="1.0" encoding="UTF-8" ?>
1
 <?xml version="1.0" encoding="UTF-8" ?>
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
 <mapper namespace="com.xhkjedu.suser.mapper.system.MsgMapper">
3
 <mapper namespace="com.xhkjedu.suser.mapper.system.MsgMapper">
4
-    <!-- 5分钟内发送短信次数 -->
4
+    <!-- 1分钟内发送短信次数 -->
5
     <select id="getMsgNumByUserPhone" resultType="java.lang.Integer">
5
     <select id="getMsgNumByUserPhone" resultType="java.lang.Integer">
6
-        select count(*) from t_msg where userphone=#{userphone} and createtime>=UNIX_TIMESTAMP(now())-300
6
+        select count(*) from t_msg where userphone=#{userphone} and createtime>=UNIX_TIMESTAMP(now())-60
7
     </select>
7
     </select>
8
     <!--根据手机号和验证码获取短信信息-->
8
     <!--根据手机号和验证码获取短信信息-->
9
     <select id="findByUserPhoneAndCode" resultType="com.xhkjedu.suser.model.system.TMsg">
9
     <select id="findByUserPhoneAndCode" resultType="com.xhkjedu.suser.model.system.TMsg">

+ 5
- 1
suser/src/main/resources/mapper/system/UserUsecertMapper.xml View File

11
     </delete>
11
     </delete>
12
     <!--根据用户id获取关联密保-->
12
     <!--根据用户id获取关联密保-->
13
     <select id="listUsecret" resultType="java.util.Map">
13
     <select id="listUsecret" resultType="java.util.Map">
14
-        select uu.usid,uu.usanswer
14
+        select uu.usid
15
         ,(select u.sname from t_usecret u where u.usid=uu.usid)sname
15
         ,(select u.sname from t_usecret u where u.usid=uu.usid)sname
16
         from t_user_usecret uu where uu.userid=#{userid}
16
         from t_user_usecret uu where uu.userid=#{userid}
17
     </select>
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
 </mapper>
22
 </mapper>

Loading…
Cancel
Save