瀏覽代碼

小程序认证登录

18792927508 2 年之前
父節點
當前提交
2e91e53da7

+ 60
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/WeChatUserController.java 查看文件

@@ -0,0 +1,60 @@
1
+package com.ruoyi.web.controller.wisdomarbitrate;
2
+
3
+import cn.hutool.core.util.StrUtil;
4
+import com.ruoyi.common.annotation.Anonymous;
5
+import com.ruoyi.common.core.controller.BaseController;
6
+import com.ruoyi.common.core.domain.AjaxResult;
7
+import com.ruoyi.common.exception.ServiceException;
8
+import com.ruoyi.common.utils.http.HttpUtils;
9
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
10
+import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
11
+import com.ruoyi.wisdomarbitrate.domain.vo.WeChatUserVO;
12
+import com.ruoyi.wisdomarbitrate.service.WeChatUserService;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.validation.annotation.Validated;
15
+import org.springframework.web.bind.annotation.*;
16
+
17
+/**
18
+ * @author wangqiong
19
+ * @description 微信小程序用户注册登录
20
+ * @date 2023-10-16 11:25
21
+ */
22
+@RestController
23
+@RequestMapping("/weChatUser")
24
+public class WeChatUserController extends BaseController {
25
+    @Autowired
26
+    private WeChatUserService weChatUserService;
27
+
28
+    /**
29
+     * 小程序端获取手机验证码
30
+     * @param userVO
31
+     * @return
32
+     */
33
+    @Anonymous
34
+    @GetMapping("/sendCode")
35
+    public AjaxResult sendCode(  WeChatUserVO userVO)
36
+    {
37
+        if(StrUtil.isEmpty(userVO.getPhone())){
38
+            return warn("手机号不能为空");
39
+        }
40
+        return success(weChatUserService.sendCode(userVO));
41
+    }
42
+    /**
43
+     * 小程序注册
44
+     */
45
+    @Anonymous
46
+    @PostMapping("/registerUser")
47
+    public AjaxResult registerUser( @RequestBody IdentityAuthentication ientityAuthentication) {
48
+        if(ientityAuthentication.getId()==null
49
+                || StrUtil.isEmpty(ientityAuthentication.getName())
50
+                || StrUtil.isEmpty(ientityAuthentication.getIdentityNo())
51
+                || StrUtil.isEmpty(ientityAuthentication.getPhone())
52
+                || StrUtil.isEmpty(ientityAuthentication.getEmail())
53
+                || StrUtil.isEmpty(ientityAuthentication.getVerifyCode())
54
+        ){
55
+            return warn("参数校验失败");
56
+        }
57
+        return weChatUserService.registerUser(ientityAuthentication);
58
+    }
59
+
60
+}

+ 1
- 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java 查看文件

@@ -41,4 +41,5 @@ public class CacheConstants
41 41
      * 登录账户密码错误次数 redis key
42 42
      */
43 43
     public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
44
+    public static final String  WE_CHAT_SMS_VERIFY_CODE_KEY="we_chat_sms_verify_code:";
44 45
 }

+ 7
- 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java 查看文件

@@ -134,4 +134,11 @@ public interface SysUserMapper
134 134
     public SysUser checkEmailUnique(String email);
135 135
 
136 136
     List<SysUser> selectUserListByIds(@Param("idList") List<Long> idList);
137
+
138
+    /**
139
+     * 根据身份证号查询用户信息
140
+     * @param identityNo
141
+     * @return
142
+     */
143
+    SysUser selectUserByIdCard(@Param("idCard")String identityNo);
137 144
 }

+ 20
- 1
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/IdentityAuthentication.java 查看文件

@@ -3,9 +3,10 @@ package com.ruoyi.wisdomarbitrate.domain;
3 3
 import com.fasterxml.jackson.annotation.JsonFormat;
4 4
 import com.ruoyi.common.annotation.Excel;
5 5
 import com.ruoyi.common.core.domain.BaseEntity;
6
+import lombok.Data;
6 7
 
7 8
 import java.util.Date;
8
-
9
+@Data
9 10
 public class IdentityAuthentication   extends BaseEntity {
10 11
     private static final long serialVersionUID = 1L;
11 12
 
@@ -15,6 +16,20 @@ public class IdentityAuthentication   extends BaseEntity {
15 16
     private String name;
16 17
     /** 身份证号 */
17 18
     private String identityNo;
19
+    /**
20
+     * 短信验证码
21
+     */
22
+    private String VerifyCode;
23
+    private String passWord;
24
+    private String phone;
25
+    /**
26
+     * 邮箱
27
+     */
28
+    private String email;
29
+    /**
30
+     * 身份证地址
31
+     */
32
+    private String idAddress;
18 33
     /** 认证时间 */
19 34
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
20 35
     private Date certificationTime;
@@ -44,6 +59,10 @@ public class IdentityAuthentication   extends BaseEntity {
44 59
     private Long userId;
45 60
     /** 用户账号 */
46 61
     private String userName;
62
+    /**
63
+     * 用户昵称
64
+     */
65
+    private String nickName;
47 66
 
48 67
     /** EID商户id */
49 68
     private String merchantId;

+ 63
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/WeChatUserVO.java 查看文件

@@ -0,0 +1,63 @@
1
+package com.ruoyi.wisdomarbitrate.domain.vo;
2
+
3
+import com.fasterxml.jackson.annotation.JsonFormat;
4
+import com.ruoyi.wisdomarbitrate.domain.Arbitrator;
5
+import lombok.Data;
6
+
7
+import javax.validation.constraints.NotEmpty;
8
+import javax.validation.constraints.NotNull;
9
+import java.util.Date;
10
+import java.util.List;
11
+
12
+/**
13
+ * 微信小程序用户注册登录
14
+ */
15
+@Data
16
+public class WeChatUserVO {
17
+    /**
18
+     * id
19
+     */
20
+    private Long id;
21
+    /**
22
+     * 微信用户唯一标识
23
+     */
24
+    private String openId;
25
+    /**
26
+     * 微信授权的code,用户登录凭证
27
+     */
28
+    private String wxCode;
29
+
30
+    /**
31
+     * 姓名
32
+     */
33
+    @NotEmpty(message = "姓名不能为空")
34
+    private String name;
35
+    /** 身份证号 */
36
+    @NotEmpty(message = "身份证号不能为空")
37
+    private String identityNo;
38
+    /** 认证时间 */
39
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
40
+    private Date certificationTime;
41
+    /** 认证状态 */
42
+    private Integer certificationStatus;
43
+    private String password;
44
+    /**
45
+     * 电话
46
+     */
47
+    @NotEmpty(message = "电话不能为空")
48
+    private String phone;
49
+    /**
50
+     * 验证码
51
+     */
52
+    private String verifyCode;
53
+    /**
54
+     * 邮箱
55
+     */
56
+    @NotEmpty(message = "邮箱不能为空")
57
+    private String email;
58
+    /**
59
+     * 创建人
60
+     */
61
+    private String createBy;
62
+    private String updateBy;
63
+}

+ 1
- 2
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/IdentityAuthenticationMapper.java 查看文件

@@ -8,6 +8,5 @@ public interface IdentityAuthenticationMapper {
8 8
     IdentityAuthentication  selectIdentityAuthentication(IdentityAuthentication identityAuthentication);
9 9
 
10 10
 
11
-
12
-
11
+    void updateIdentityAuthentication(IdentityAuthentication ientityAuthentication);
13 12
 }

+ 21
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/WeChatUserMapper.java 查看文件

@@ -0,0 +1,21 @@
1
+package com.ruoyi.wisdomarbitrate.mapper;
2
+
3
+import com.ruoyi.wisdomarbitrate.domain.vo.WeChatUserVO;
4
+import org.apache.ibatis.annotations.Param;
5
+import org.springframework.stereotype.Repository;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * @author wangqiong
11
+ * @description 微信小程序用户注册登录
12
+ * @date 2023-10-16 11:45
13
+ */
14
+@Repository
15
+public interface WeChatUserMapper {
16
+    int insertUser(WeChatUserVO userVO);
17
+    int updateUser(WeChatUserVO userVO);
18
+    List<WeChatUserVO> selectIdentityAuthentication(WeChatUserVO userVO);
19
+
20
+    WeChatUserVO selectUserByOppenId(@Param("oppenId") String openId);
21
+}

+ 18
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/WeChatUserService.java 查看文件

@@ -0,0 +1,18 @@
1
+package com.ruoyi.wisdomarbitrate.service;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.ruoyi.common.core.domain.AjaxResult;
5
+import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
6
+import com.ruoyi.wisdomarbitrate.domain.vo.WeChatUserVO;
7
+
8
+/**
9
+ * 微信小程序用户注册登录
10
+ */
11
+public interface WeChatUserService {
12
+
13
+
14
+    String sendCode(WeChatUserVO userVO);
15
+
16
+
17
+    AjaxResult registerUser(IdentityAuthentication ientityAuthentication);
18
+}

+ 15
- 8
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/IdentityAuthenticationServiceImpl.java 查看文件

@@ -8,8 +8,10 @@ import cn.hutool.crypto.symmetric.SymmetricCrypto;
8 8
 import com.alibaba.fastjson.JSON;
9 9
 import com.alibaba.fastjson.JSONObject;
10 10
 import com.ruoyi.common.core.domain.AjaxResult;
11
+import com.ruoyi.common.core.domain.entity.SysUser;
11 12
 import com.ruoyi.common.core.domain.model.LoginUser;
12 13
 import com.ruoyi.common.utils.SecurityUtils;
14
+import com.ruoyi.system.mapper.SysUserMapper;
13 15
 import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
14 16
 import com.ruoyi.wisdomarbitrate.mapper.IdentityAuthenticationMapper;
15 17
 import com.ruoyi.wisdomarbitrate.service.IdentityAuthenticationService;
@@ -46,6 +48,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
46 48
 
47 49
     @Autowired
48 50
     private IdentityAuthenticationMapper identityAuthenticationMapper;
51
+    private SysUserMapper sysUserMapper;
49 52
 
50 53
     private static final Logger log = LoggerFactory.getLogger(IdentityAuthenticationServiceImpl.class);
51 54
 
@@ -147,7 +150,7 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
147 150
     @Transactional
148 151
     public AjaxResult selectIdentityAuthenticaRespon(IdentityAuthentication ientityAuthentication) {
149 152
         String eidToken = ientityAuthentication.getEidToken();
150
-
153
+        IdentityAuthentication authentication = new IdentityAuthentication();
151 154
         try {
152 155
             Credential cred = new Credential(credentialSecretId, credentialSecretKey);
153 156
             // 实例化一个http选项,可选的,没有特殊需求可以跳过
@@ -181,8 +184,8 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
181 184
                             String idcardno = info.getString("idnum");
182 185
                             String name = info.getString("name");
183 186
                             //2.在用户认证表中插入用户认证记录
184
-                            LoginUser loginUser = SecurityUtils.getLoginUser();
185
-                            IdentityAuthentication authentication = new IdentityAuthentication();
187
+                          //  LoginUser loginUser = SecurityUtils.getLoginUser();
188
+
186 189
                             /**
187 190
                              * 用户名
188 191
                              * 用户名id
@@ -192,15 +195,17 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
192 195
                              * 认证状态0表示成功
193 196
                              * 请求id
194 197
                              */
195
-                            authentication.setUserName(loginUser.getUsername());
196
-                            authentication.setUserId(loginUser.getUserId());
198
+                           // authentication.setUserName(loginUser.getUsername());
199
+                          //  authentication.setUserId(loginUser.getUserId());
197 200
                             authentication.setName(name);
198 201
                             authentication.setIdentityNo(idcardno);
199 202
                             authentication.setCertificationTime(new Date());
200 203
                             authentication.setCertificationStatus(0);
201
-                            authentication.setCreateBy(loginUser.getUsername());
204
+                            authentication.setCreateBy(name);
205
+                          //  authentication.setCreateBy(loginUser.getUsername());
202 206
                             try {
203 207
                                 identityAuthenticationMapper.insertIdentityAuthentication(authentication);
208
+                                authentication.setId(authentication.getId());
204 209
                             } catch (Exception e) {
205 210
                                 System.out.println("认证记录新增失败");
206 211
                             }
@@ -210,12 +215,14 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
210 215
                     }
211 216
                 }
212 217
             }
213
-            return AjaxResult.success();
218
+            return AjaxResult.success(authentication);
214 219
         } catch (TencentCloudSDKException e) {
215 220
             System.out.println(e.toString());
216 221
         }
217
-        return null;
222
+        return AjaxResult.success();
218 223
     }
219 224
 
220 225
 
226
+
227
+
221 228
 }

+ 148
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/WeChatUserServiceImpl.java 查看文件

@@ -0,0 +1,148 @@
1
+package com.ruoyi.wisdomarbitrate.service.impl;
2
+
3
+import cn.hutool.core.util.StrUtil;
4
+import cn.hutool.http.HttpUtil;
5
+import cn.hutool.json.JSONUtil;
6
+import com.alibaba.fastjson2.JSONArray;
7
+import com.alibaba.fastjson2.JSONObject;
8
+import com.ruoyi.common.constant.CacheConstants;
9
+import com.ruoyi.common.core.domain.AjaxResult;
10
+import com.ruoyi.common.core.domain.entity.SysDictData;
11
+import com.ruoyi.common.core.domain.entity.SysUser;
12
+import com.ruoyi.common.core.domain.model.LoginUser;
13
+import com.ruoyi.common.core.redis.RedisCache;
14
+import com.ruoyi.common.utils.SecurityUtils;
15
+import com.ruoyi.common.utils.SmsUtils;
16
+import com.ruoyi.common.utils.StringUtils;
17
+import com.ruoyi.common.utils.http.HttpUtils;
18
+import com.ruoyi.common.utils.spring.SpringUtils;
19
+import com.ruoyi.system.mapper.SysUserMapper;
20
+import com.ruoyi.wisdomarbitrate.domain.IdentityAuthentication;
21
+import com.ruoyi.wisdomarbitrate.domain.vo.WeChatUserVO;
22
+import com.ruoyi.wisdomarbitrate.mapper.IdentityAuthenticationMapper;
23
+import com.ruoyi.wisdomarbitrate.mapper.WeChatUserMapper;
24
+import com.ruoyi.wisdomarbitrate.service.WeChatUserService;
25
+import lombok.extern.slf4j.Slf4j;
26
+import org.springframework.beans.factory.annotation.Autowired;
27
+import org.springframework.stereotype.Service;
28
+import org.springframework.transaction.annotation.Transactional;
29
+
30
+import java.util.HashMap;
31
+import java.util.List;
32
+import java.util.Random;
33
+import java.util.concurrent.TimeUnit;
34
+
35
+/**
36
+ * @author wangqiong
37
+ * @description 微信小程序用户注册登录
38
+ * @date 2023-10-16 11:45
39
+ */
40
+@Service
41
+@Slf4j
42
+public class WeChatUserServiceImpl implements WeChatUserService {
43
+    String appid="wx91cb8459dca561b4";//自行获取
44
+    //小程序secret
45
+    String secret="190aaa3bda96a65d25318fbb0e133fc6";//自己去公众号后台获取
46
+    // 获取openId
47
+    String openIdUrl = "https://api.weixin.qq.com/sns/jscode2session";
48
+    @Autowired
49
+    private WeChatUserMapper weChatUserMapper;
50
+    @Autowired
51
+    private SysUserMapper sysUserMapper;
52
+    @Autowired
53
+    private IdentityAuthenticationMapper identityAuthenticationMapper;
54
+
55
+    @Override
56
+    public String sendCode(WeChatUserVO userVO) {
57
+        Random random = new Random();
58
+        String code = "";
59
+        for (int i = 0; i < 6; i++) {
60
+
61
+            code += random.nextInt(10);
62
+        }
63
+        SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest();
64
+        request.setTemplateId("1952136");
65
+        // 1948332 普通短信 开庭审理房间号通知 尊敬的{1}用户,您的{2}仲裁案件,开庭审理房间号为{3},请知晓,如非本人操作,请忽略本短信。
66
+        request.setPhone(userVO.getPhone());
67
+        request.setTemplateParamSet(new String[]{"王琼", "验证码", code});
68
+        Boolean flag = SmsUtils.sendSms(request);
69
+        if(flag){
70
+            setCodeCache(userVO.getPhone(),code);
71
+        }
72
+        return "短信发送成功";
73
+    }
74
+    /**
75
+     * 设置字典缓存
76
+     *
77
+     * @param key 参数键
78
+     * @param code 字典数据列表
79
+     */
80
+    public static void setCodeCache(String key, String code)
81
+    {
82
+        SpringUtils.getBean(RedisCache.class).setCacheObject(getVerifyCodeCacheKey(key), code, 5,TimeUnit.MILLISECONDS);
83
+    }
84
+
85
+
86
+    /**
87
+     * 获取字典缓存
88
+     *
89
+     * @param key 参数键
90
+     * @return dictDatas 字典数据列表
91
+     */
92
+    public static String getCodeCache(String key)
93
+    {
94
+        String codeCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getVerifyCodeCacheKey(key));
95
+        if (StringUtils.isNotNull(codeCache))
96
+        {
97
+            return codeCache;
98
+        }
99
+        return null;
100
+    }
101
+
102
+    private static String getVerifyCodeCacheKey(String key) {
103
+        return CacheConstants.WE_CHAT_SMS_VERIFY_CODE_KEY + key;
104
+    }
105
+    @Transactional
106
+    @Override
107
+    public AjaxResult registerUser(IdentityAuthentication ientityAuthentication) {
108
+        // 校验短信验证码
109
+//        if(StrUtil.isEmpty(getCodeCache(ientityAuthentication.getPhone()))){
110
+//            return AjaxResult.success("验证码校验失败");
111
+//        }
112
+        // 根据身份证查询系统用户表中是否存在该用户,存在则同步已认证的信息,不存在则新增
113
+        SysUser sysUser=sysUserMapper.selectUserByIdCard(ientityAuthentication.getIdentityNo());
114
+
115
+        if(sysUser!=null){
116
+            sysUser.setIdCard(ientityAuthentication.getIdentityNo());
117
+            sysUser.setNickName(ientityAuthentication.getName());
118
+            sysUser.setUserName(ientityAuthentication.getUserName());
119
+            sysUser.setPhonenumber(ientityAuthentication.getPhone());
120
+            sysUser.setEmail(ientityAuthentication.getEmail());
121
+            sysUser.setPassword(SecurityUtils.encryptPassword(ientityAuthentication.getPassWord()));
122
+            sysUserMapper.updateUser(sysUser);
123
+            ientityAuthentication.setUserId(sysUser.getUserId());
124
+        }else {
125
+            sysUser=new SysUser();
126
+            // 用户名设为电话号
127
+            sysUser.setUserName(ientityAuthentication.getPhone());
128
+            sysUser.setIdCard(ientityAuthentication.getIdentityNo());
129
+            sysUser.setNickName(ientityAuthentication.getName());
130
+            sysUser.setUserName(ientityAuthentication.getUserName());
131
+            sysUser.setPhonenumber(ientityAuthentication.getPhone());
132
+            sysUser.setEmail(ientityAuthentication.getEmail());
133
+            sysUser.setCreateBy(ientityAuthentication.getPhone());
134
+            sysUser.setPassword(SecurityUtils.encryptPassword(ientityAuthentication.getPassWord()));
135
+            int row = sysUserMapper.insertUser(sysUser);
136
+            if(row<1) {
137
+                return AjaxResult.success("注册失败");
138
+            }
139
+        }
140
+
141
+        ientityAuthentication.setUserId(sysUser.getUserId());
142
+        ientityAuthentication.setUserName(sysUser.getUserName());
143
+        // 已经认证过的用户才能注册,认证表中已经有该数据
144
+        identityAuthenticationMapper.updateIdentityAuthentication(ientityAuthentication);
145
+        return AjaxResult.success("注册成功");
146
+    }
147
+
148
+}

+ 7
- 1
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml 查看文件

@@ -177,7 +177,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
177 177
 
178 178
 	</select>
179 179
 
180
-	<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
180
+	<select id="selectUserByIdCard" parameterType="String" resultMap="SysUserResult">
181
+		select u.* from sys_user u
182
+		where u.id_card = #{idCard} and u.del_flag = '0' and u.status='0' order by u.create_time limit 1
183
+	</select>
184
+
185
+
186
+    <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
181 187
  		insert into sys_user(
182 188
  			<if test="userId != null and userId != 0">user_id,</if>
183 189
  			<if test="deptId != null and deptId != 0">dept_id,</if>

+ 14
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/IdentityAuthenticationMapper.xml 查看文件

@@ -11,12 +11,14 @@
11 11
         <result property="certificationStatus"        column="certification_status"        />
12 12
         <result property="userId"  column="user_id"  />
13 13
         <result property="userName"          column="user_name"          />
14
+        <result property="idAddress"          column="id_address"          />
14 15
 
15 16
     </resultMap>
16 17
 
17 18
     <insert id="insertIdentityAuthentication" parameterType="IdentityAuthentication" useGeneratedKeys="true" keyProperty="id">
18 19
         insert into identi_authenti(
19 20
         <if test="userId != null">user_id,</if>
21
+        <if test="idAddress != null and idAddress != ''">id_address,</if>
20 22
         <if test="name != null and name != ''">name,</if>
21 23
         <if test="identityNo != null and identityNo != ''">identity_no,</if>
22 24
         certification_time,
@@ -26,6 +28,7 @@
26 28
         create_time
27 29
         )values(
28 30
         <if test="userId != null ">#{userId},</if>
31
+        <if test="idAddress != null and idAddress != ''">#{idAddress},</if>
29 32
         <if test="name != null and name != ''">#{name},</if>
30 33
         <if test="identityNo != null and identityNo != ''">#{identityNo},</if>
31 34
         sysdate(),
@@ -35,6 +38,17 @@
35 38
         sysdate()
36 39
         )
37 40
     </insert>
41
+    <update id="updateIdentityAuthentication">
42
+        update identi_authenti
43
+        <set>
44
+            <if test="userId != null ">user_id = #{userId},</if>
45
+            <if test="userName != null and userName != ''">user_name = #{userName},</if>
46
+            <if test="identityNo != null and identityNo != ''">identity_no = #{identityNo},</if>
47
+            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
48
+            update_time = sysdate()
49
+        </set>
50
+        where id = #{id}
51
+    </update>
38 52
 
39 53
     <select id="selectIdentityAuthentication" parameterType="IdentityAuthentication" resultMap="IdentityAuthenticationResult">
40 54
         SELECT  i.id ,i.name ,i.identity_no ,i.certification_time ,i.certification_status ,i.user_id ,i.user_name

+ 61
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/WeChatUserMapper.xml 查看文件

@@ -0,0 +1,61 @@
1
+<?xml version="1.0" encoding="UTF-8" ?>
2
+<!DOCTYPE mapper
3
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
+<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.WeChatUserMapper">
6
+    <resultMap type="com.ruoyi.wisdomarbitrate.domain.vo.WeChatUserVO" id="BaseResult">
7
+        <id     property="id"       column="id"      />
8
+        <result property="name"       column="name"      />
9
+        <result property="identityNo"     column="identity_no"    />
10
+        <result property="certificationTime"     column="certification_time"    />
11
+        <result property="certificationStatus"        column="certification_status"        />
12
+        <result property="openId"  column="open_id"  />
13
+        <result property="phone"          column="phone"          />
14
+        <result property="email"          column="email"          />
15
+
16
+    </resultMap>
17
+    <insert id="insertUser">
18
+        insert into identi_authenti(
19
+        <if test="name != null and name != ''">name,</if>
20
+        <if test="identityNo != null and identityNo != ''">identity_no,</if>
21
+        certification_time,
22
+        <if test="certificationStatus != null ">certification_status,</if>
23
+        <if test="openId != null ">open_id,</if>
24
+        <if test="createBy != null  and createBy != ''">create_by,</if>
25
+        <if test="phone != null  and phone != ''">phone,</if>
26
+        <if test="email != null  and email != ''">email,</if>
27
+        create_time
28
+
29
+        )values(
30
+        <if test="name != null and name != ''">#{name},</if>
31
+        <if test="identityNo != null and identityNo != ''">#{identityNo},</if>
32
+        sysdate(),
33
+        <if test="certificationStatus != null ">#{certificationStatus},</if>
34
+        <if test="openId != null ">#{openId},</if>
35
+        <if test="createBy != null  and createBy != ''">#{createBy},</if>
36
+        <if test="phone != null  and phone != ''">#{phone},</if>
37
+        <if test="email != null  and email != ''">#{email},</if>
38
+        sysdate()
39
+        )
40
+    </insert>
41
+    <update id="updateUser">
42
+        update identi_authenti
43
+        <set>
44
+            <if test="phone != null and phone != ''">phone = #{phone},</if>
45
+            <if test="email != null and email != ''">email = #{email},</if>
46
+            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
47
+            update_time = sysdate()
48
+        </set>
49
+        where id = #{id}
50
+    </update>
51
+    <select id="selectIdentityAuthentication"  resultMap="BaseResult">
52
+        SELECT  i.id ,i.name ,i.identity_no ,i.certification_time ,i.certification_status ,i.user_id ,i.user_name,open_id,phone,email
53
+        from identi_authenti i
54
+    </select>
55
+    <select id="selectUserByOppenId" resultMap="BaseResult">
56
+        SELECT  i.id ,i.name ,i.identity_no ,i.certification_time ,i.certification_status ,i.user_id ,i.user_name,open_id,phone,email
57
+        from identi_authenti i where open_id=#{oppenId}
58
+    </select>
59
+
60
+
61
+</mapper>