新增uid:第三方系统的用户ID

This commit is contained in:
2024-08-14 03:52:27 +08:00
parent 575d0f688e
commit e9658c69a5
6 changed files with 30 additions and 11 deletions

View File

@@ -148,6 +148,12 @@ public class WxLoginController extends BaseController {
if(userParam.getPhone() != null){
addUser.setPhone(userParam.getPhone());
}
if(StrUtil.isNotBlank(userParam.getOpenid())){
addUser.setOpenid(userParam.getOpenid());
}
if(StrUtil.isNotBlank(userParam.getUnionid())){
addUser.setUnionid(userParam.getUnionid());
}
addUser.setPassword(userService.encodePassword(CommonUtil.randomUUID16()));
addUser.setTenantId(getTenantId());
addUser.setRecommend(1);
@@ -380,18 +386,16 @@ public class WxLoginController extends BaseController {
String sessionKey = jsonObject.getString("session_key");
String unionid = jsonObject.getString("unionid");
System.out.println("openid = " + openid);
System.out.println("unionid = " + unionid);
if (StrUtil.isNotBlank(openid)) {
User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getOpenid, openid).last("limit 1"));
if (ObjectUtil.isEmpty(user)) {
// 注册新用户
final UserParam param = new UserParam();
addUser(param);
user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getOpenid, openid));
if(ObjectUtil.isNotEmpty(user)){
return success("登录成功", user);
}
return success("登录成功", user);
return fail("用户未注册",openid);
}
return fail("登录失败",openid);
return fail("openId获取失败");
}
/**

View File

@@ -210,7 +210,7 @@ public class WxOfficialController extends BaseController {
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/bizsend?access_token=" + getAccessToken();
final UserOauth userOauth = userOauthService.getOne(new LambdaQueryWrapper<UserOauth>().eq(UserOauth::getUserId, param.getUserId()).eq(UserOauth::getOauthType,"MP-OFFICIAL").eq(UserOauth::getDeleted, 0));
if(userOauth != null){
param.setOpenId(userOauth.getOauthId());
param.setOpenid(userOauth.getOauthId());
final String oauthId = userOauth.getOauthId();
// 跳转小程序链接
HashMap<String, String> miniprogram = new HashMap<>();

View File

@@ -34,6 +34,9 @@ public class User implements UserDetails {
@ApiModelProperty("用户编码")
private String userCode;
@ApiModelProperty("第三方系统的用户ID")
private Integer uid;
@ApiModelProperty("账号")
private String username;

View File

@@ -46,6 +46,12 @@
<if test="param.username != null">
AND a.username LIKE CONCAT('%', #{param.username}, '%')
</if>
<if test="param.uid != null">
AND a.uid = #{param.uid}
</if>
<if test="param.userCode != null">
AND a.user_code = #{param.userCode}
</if>
<if test="param.nickname != null">
AND a.nickname LIKE CONCAT('%', #{param.nickname}, '%')
</if>

View File

@@ -44,6 +44,9 @@ public class UserParam extends BaseParam {
@ApiModelProperty("用户编码")
private String userCode;
@ApiModelProperty("第三方系统用户ID")
private Integer uid;
@ApiModelProperty("性别(字典)")
@QueryField(type = QueryType.EQ)
private String sex;
@@ -222,9 +225,12 @@ public class UserParam extends BaseParam {
@TableField(exist = false)
private Boolean showProfile;
@ApiModelProperty("openId")
@ApiModelProperty("微信openid")
@TableField(exist = false)
private String openId;
private String openid;
@ApiModelProperty("unionid")
private String unionid;
@ApiModelProperty(value = "可管理的商户")
@QueryField(type = QueryType.LIKE)

View File

@@ -1,6 +1,6 @@
# 端口
server:
port: 9091
port: 9090
# socketIo
socketio:
port: 9191