[feat]:用户微信登录模块,登录注册微信用户数据

This commit is contained in:
李世琳
2024-12-17 11:31:32 +08:00
parent 7f0b291311
commit 62a9f8e6ff
3 changed files with 35 additions and 29 deletions
@@ -110,6 +110,17 @@ public class SysUserController {
return appUserService.findByOpenId(openId);
}
/**
* 根据WxOpenId查询用户信息
*
* @param openId openId
*/
@GetMapping(value = "/users-anon/wxOpenId", params = "openId")
@Operation(summary = "根据WxOpenId查询用户")
public SysUser findByWxOpenId(String openId) throws Exception {
return appUserService.findByWxOpenid(openId);
}
@GetMapping("/users/{id}")
public SysUser findUserById(@PathVariable Long id) {
return appUserService.getById(id);
@@ -76,7 +76,8 @@ public class SysUserServiceImpl extends SuperServiceImpl<SysUserMapper, SysUser>
@Override
public SysUser findByWxOpenid(String wxOpenid) throws Exception {
SysUser sysUser = this.selectByOpenId(wxOpenid);
if (sysUser.getId() == null) {
if (ObjectUtils.isEmpty(sysUser)) {
sysUser = new SysUser();
sysUser.setOpenId(wxOpenid);
sysUser.setUsername(wxOpenid);
sysUser.setType(UserType.APP.name());