This commit is contained in:
tangzh 2025-07-11 17:53:27 +08:00
parent 5f54043ab3
commit 9e709f0a10
2 changed files with 8 additions and 8 deletions

View File

@ -1,6 +1,6 @@
package me.zhengjie.modules.front.domain.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.alibaba.fastjson2.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -8,23 +8,23 @@ import lombok.Data;
public class WeChatMiniAuthorizeVo {
@ApiModelProperty(value = "会话密钥")
@TableField(value = "session_key")
@JSONField(name = "session_key")
private String sessionKey;
@ApiModelProperty(value = "用户唯一标识")
@TableField(value = "openid")
@JSONField(name = "openid")
private String openId;
@ApiModelProperty(value = "用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台帐号下会返回")
@TableField(value = "unionid")
@JSONField(name = "unionid")
private String unionId;
@ApiModelProperty(value = "错误码")
@TableField(value = "errcode")
@JSONField(name = "errcode")
private String errCode;
@ApiModelProperty(value = "错误信息")
@TableField(value = "errmsg")
@JSONField(name = "errmsg")
private String errMsg;
}

View File

@ -68,6 +68,7 @@ public class WeChatServiceImpl implements WeChatService {
WeChatMiniAuthorizeVo response = miniAuthCode(code);
// WeChatMiniAuthorizeVo response = new WeChatMiniAuthorizeVo();
// response.setOpenId("123456");
log.info("<<< response{}", JSON.toJSONString(response));
String openId = response.getOpenId();
String type = "login";
BusUser BusUser = BusUserMapper.getUserByOpenId(openId);
@ -77,7 +78,7 @@ public class WeChatServiceImpl implements WeChatService {
BusUser add = new BusUser();
add.setSex(0);
add.setRealName(DateUtil.localDateTimeFormat(LocalDateTime.now(), DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")));
add.setNickname("用户_" + new Random().nextInt(900000) + 100000);
add.setNickname("用户_" + (new Random().nextInt(900000) + 100000));
add.setToken(openId);
add.setAvatar(DEFAULT_AVATAR);
BusUserMapper.insert(add);
@ -112,5 +113,4 @@ public class WeChatServiceImpl implements WeChatService {
}
return JSONObject.parseObject(data.toJSONString(), WeChatMiniAuthorizeVo.class);
}
}