提交 f735339a authored 作者: hzh's avatar hzh

登录修改

上级 9f521600
...@@ -21,10 +21,11 @@ public interface RemoteServerService { ...@@ -21,10 +21,11 @@ public interface RemoteServerService {
* 根据手机号查询用户 * 根据手机号查询用户
* *
* @param tenantId 租户id * @param tenantId 租户id
* @param userType 用户类型
* @param phone 用户手机号 * @param phone 用户手机号
* @return 用户信息 * @return 用户信息
*/ */
RemoteUser getUserByPhone(String tenantId, String phone); RemoteUser getUserByPhone(String tenantId, String userType, String phone);
/** /**
......
package org.dromara.system.api;
import org.dromara.system.api.domain.vo.RemoteProjectVo;
import java.util.List;
/**
* 项目服务
*
* @author wenhe
*/
public interface RemoteProjectService {
/**
* 获取项目列表
*
* @param tenantId 租户id
* @param phone 手机号
* @return 结果
*/
List<RemoteProjectVo> queryList(String tenantId, String phone);
}
...@@ -59,10 +59,12 @@ public interface RemoteUserService { ...@@ -59,10 +59,12 @@ public interface RemoteUserService {
* 通过openid查询用户信息 * 通过openid查询用户信息
* *
* @param openid openid * @param openid openid
* @param phone 手机号
* @param userType 用户类型
* @param tenantId 租户id * @param tenantId 租户id
* @return 结果 * @return 结果
*/ */
XcxLoginUser getUserInfoByOpenid(String openid, String phone, String tenantId) throws UserException; XcxLoginUser getUserInfoByOpenid(String openid, String phone, String userType, String tenantId) throws UserException;
/** /**
* 注册用户信息 * 注册用户信息
......
...@@ -36,6 +36,11 @@ public class RemoteWxUserBo implements Serializable { ...@@ -36,6 +36,11 @@ public class RemoteWxUserBo implements Serializable {
*/ */
private String openId; private String openId;
/**
* 用户类型
*/
private String userType;
/** /**
* 手机号码 * 手机号码
*/ */
......
package org.dromara.system.api.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* 系统项目对象
*
* @author hzh
* @date 2025-06-11
*/
@Data
public class RemoteProjectVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 租户id
*/
private String tenantId;
/**
* id
*/
private Long projectId;
/**
* 项目名称
*/
private String projectName;
}
package org.dromara.auth.controller; package org.dromara.auth.controller;
import cn.dev33.satoken.exception.NotLoginException; import cn.dev33.satoken.exception.NotLoginException;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
...@@ -12,6 +13,7 @@ import me.zhyd.oauth.model.AuthUser; ...@@ -12,6 +13,7 @@ import me.zhyd.oauth.model.AuthUser;
import me.zhyd.oauth.request.AuthRequest; import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils; import me.zhyd.oauth.utils.AuthStateUtils;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.auth.domain.vo.LoginProjectVo;
import org.dromara.auth.domain.vo.LoginTenantVo; import org.dromara.auth.domain.vo.LoginTenantVo;
import org.dromara.auth.domain.vo.LoginVo; import org.dromara.auth.domain.vo.LoginVo;
import org.dromara.auth.domain.vo.TenantListVo; import org.dromara.auth.domain.vo.TenantListVo;
...@@ -34,6 +36,7 @@ import org.dromara.common.tenant.helper.TenantHelper; ...@@ -34,6 +36,7 @@ import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.resource.api.RemoteMessageService; import org.dromara.resource.api.RemoteMessageService;
import org.dromara.system.api.*; import org.dromara.system.api.*;
import org.dromara.system.api.domain.vo.RemoteClientVo; import org.dromara.system.api.domain.vo.RemoteClientVo;
import org.dromara.system.api.domain.vo.RemoteProjectVo;
import org.dromara.system.api.domain.vo.RemoteTenantVo; import org.dromara.system.api.domain.vo.RemoteTenantVo;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -64,6 +67,8 @@ public class TokenController { ...@@ -64,6 +67,8 @@ public class TokenController {
@DubboReference @DubboReference
private final RemoteTenantService remoteTenantService; private final RemoteTenantService remoteTenantService;
@DubboReference @DubboReference
private final RemoteProjectService remoteProjectService;
@DubboReference
private final RemoteClientService remoteClientService; private final RemoteClientService remoteClientService;
@DubboReference @DubboReference
private final RemoteSocialService remoteSocialService; private final RemoteSocialService remoteSocialService;
...@@ -239,10 +244,24 @@ public class TokenController { ...@@ -239,10 +244,24 @@ public class TokenController {
} }
// 根据域名进行筛选 // 根据域名进行筛选
List<TenantListVo> list = StreamUtils.filter(voList, vo -> List<TenantListVo> list = StreamUtils.filter(voList, vo ->
StringUtils.equals(vo.getDomain(), host)&& StringUtils.equals(vo.getDomain(), host) &&
virtual.equals(vo.getVirtual())); virtual.equals(vo.getVirtual()));
result.setVoList(CollUtil.isNotEmpty(list) ? list : voList); result.setVoList(CollUtil.isNotEmpty(list) ? list : voList);
return R.ok(result); return R.ok(result);
} }
/**
* 登录页面项目下拉框
*
* @param tenantId 租户id
* @param phone 手机号
* @return 项目列表
*/
@GetMapping("/project/list")
public R<List<LoginProjectVo>> projectList(@RequestParam(value = "tenantId", required = false) String tenantId,
@RequestParam(value = "phone", required = false) String phone) {
List<RemoteProjectVo> list = remoteProjectService.queryList(tenantId, phone);
return R.ok(BeanUtil.copyToList(list, LoginProjectVo.class));
}
} }
package org.dromara.auth.domain.vo;
import lombok.Data;
/**
* 登录项目对象
*
* @author wenhe
*/
@Data
public class LoginProjectVo {
/**
* 租户id
*/
private String tenantId;
/**
* 项目id
*/
private Long projectId;
/**
* 项目名称
*/
private String projectName;
}
...@@ -14,7 +14,6 @@ import org.dromara.auth.service.SysLoginService; ...@@ -14,7 +14,6 @@ import org.dromara.auth.service.SysLoginService;
import org.dromara.common.core.constant.Constants; import org.dromara.common.core.constant.Constants;
import org.dromara.common.core.constant.GlobalConstants; import org.dromara.common.core.constant.GlobalConstants;
import org.dromara.common.core.enums.LoginType; import org.dromara.common.core.enums.LoginType;
import org.dromara.common.core.enums.UserType;
import org.dromara.common.core.exception.user.CaptchaException; import org.dromara.common.core.exception.user.CaptchaException;
import org.dromara.common.core.exception.user.CaptchaExpireException; import org.dromara.common.core.exception.user.CaptchaExpireException;
import org.dromara.common.core.utils.MessageUtils; import org.dromara.common.core.utils.MessageUtils;
...@@ -68,7 +67,7 @@ public class PasswordAuthStrategy implements IAuthStrategy { ...@@ -68,7 +67,7 @@ public class PasswordAuthStrategy implements IAuthStrategy {
validateCaptcha(tenantId, username, code, uuid); validateCaptcha(tenantId, username, code, uuid);
} }
LoginUser loginUser = TenantHelper.dynamic(tenantId, () -> { LoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
LoginUser user = remoteUserService.getUserInfo(username, null, tenantId, UserType.SYS_USER.getUserType()); LoginUser user = remoteUserService.getUserInfo(username, null, tenantId, loginBody.getUserType());
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword())); loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword()));
return user; return user;
}); });
...@@ -80,7 +79,7 @@ public class PasswordAuthStrategy implements IAuthStrategy { ...@@ -80,7 +79,7 @@ public class PasswordAuthStrategy implements IAuthStrategy {
// 例如: 后台用户30分钟过期 app用户1天过期 // 例如: 后台用户30分钟过期 app用户1天过期
model.setTimeout(client.getTimeout()); model.setTimeout(client.getTimeout());
model.setActiveTimeout(client.getActiveTimeout()); model.setActiveTimeout(client.getActiveTimeout());
RemoteUser ru = remoteServerService.getUserByPhone(loginUser.getTenantId(), loginUser.getPhonenumber()); RemoteUser ru = remoteServerService.getUserByPhone(loginUser.getTenantId(), loginBody.getUserType(), loginUser.getPhonenumber());
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId()); model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
model.setExtra(LoginHelper.YS_USER_ID, Optional.ofNullable(ru).map(RemoteUser::getUserNo).orElse(null)); model.setExtra(LoginHelper.YS_USER_ID, Optional.ofNullable(ru).map(RemoteUser::getUserNo).orElse(null));
// 生成token // 生成token
......
...@@ -70,13 +70,14 @@ public class XcxAuthStrategy extends AbstractMallStrategy implements IAuthStrate ...@@ -70,13 +70,14 @@ public class XcxAuthStrategy extends AbstractMallStrategy implements IAuthStrate
remoteUserService.registerWxUserInfo(new RemoteWxUserBo() remoteUserService.registerWxUserInfo(new RemoteWxUserBo()
.setTenantId(loginBody.getTenantId()) .setTenantId(loginBody.getTenantId())
.setOpenId(openid) .setOpenId(openid)
.setUserType(loginBody.getUserType())
.setPhonenumber(phone)); .setPhonenumber(phone));
} }
//校验手机号 //校验手机号
validatePhone(loginBody.getPhone(), phone); validatePhone(loginBody.getPhone(), phone);
XcxLoginUser loginUser = remoteUserService.getUserInfoByOpenid(openid, phone, loginBody.getTenantId()); XcxLoginUser loginUser = remoteUserService.getUserInfoByOpenid(openid, phone, loginBody.getUserType(), loginBody.getTenantId());
// 用户不存在 返回 openid // 用户不存在 返回 openid
if (loginUser == null) { if (loginUser == null) {
...@@ -103,7 +104,7 @@ public class XcxAuthStrategy extends AbstractMallStrategy implements IAuthStrate ...@@ -103,7 +104,7 @@ public class XcxAuthStrategy extends AbstractMallStrategy implements IAuthStrate
model.setTimeout(client.getTimeout()); model.setTimeout(client.getTimeout());
model.setActiveTimeout(client.getActiveTimeout()); model.setActiveTimeout(client.getActiveTimeout());
RemoteUser ru = remoteServerService.getUserByPhone(loginUser.getTenantId(), loginUser.getPhone()); RemoteUser ru = remoteServerService.getUserByPhone(loginUser.getTenantId(), loginUser.getUserType(), loginUser.getPhone());
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId()); model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
model.setExtra(LoginHelper.YS_USER_ID, Optional.ofNullable(ru).map(RemoteUser::getUserNo).orElse(null)); model.setExtra(LoginHelper.YS_USER_ID, Optional.ofNullable(ru).map(RemoteUser::getUserNo).orElse(null));
model.setExtra(LoginHelper.OPEN_ID, openid); model.setExtra(LoginHelper.OPEN_ID, openid);
......
...@@ -55,12 +55,13 @@ public class XcxPhoneAuthStrategy extends AbstractMallStrategy implements IAuthS ...@@ -55,12 +55,13 @@ public class XcxPhoneAuthStrategy extends AbstractMallStrategy implements IAuthS
remoteUserService.registerWxUserInfo(new RemoteWxUserBo() remoteUserService.registerWxUserInfo(new RemoteWxUserBo()
.setTenantId(loginBody.getTenantId()) .setTenantId(loginBody.getTenantId())
.setOpenId(loginBody.getOpenId()) .setOpenId(loginBody.getOpenId())
.setUserType(loginBody.getUserType())
.setPhonenumber(phone)); .setPhonenumber(phone));
//校验手机号 //校验手机号
validatePhone(loginBody.getPhone(), phone); validatePhone(loginBody.getPhone(), phone);
XcxLoginUser loginUser = remoteUserService.getUserInfoByOpenid(loginBody.getOpenId(), phone, loginBody.getTenantId()); XcxLoginUser loginUser = remoteUserService.getUserInfoByOpenid(loginBody.getOpenId(), phone, loginBody.getUserType(), loginBody.getTenantId());
if (loginUser == null) { if (loginUser == null) {
throw new RuntimeException("用户不存在"); throw new RuntimeException("用户不存在");
...@@ -78,7 +79,7 @@ public class XcxPhoneAuthStrategy extends AbstractMallStrategy implements IAuthS ...@@ -78,7 +79,7 @@ public class XcxPhoneAuthStrategy extends AbstractMallStrategy implements IAuthS
// 例如: 后台用户30分钟过期 app用户1天过期 // 例如: 后台用户30分钟过期 app用户1天过期
model.setTimeout(client.getTimeout()); model.setTimeout(client.getTimeout());
model.setActiveTimeout(client.getActiveTimeout()); model.setActiveTimeout(client.getActiveTimeout());
RemoteUser ru = remoteServerService.getUserByPhone(loginUser.getTenantId(), loginUser.getPhone()); RemoteUser ru = remoteServerService.getUserByPhone(loginUser.getTenantId(), loginUser.getUserType(), loginUser.getPhone());
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId()); model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
model.setExtra(LoginHelper.YS_USER_ID, Optional.ofNullable(ru).map(RemoteUser::getUserNo).orElse(null)); model.setExtra(LoginHelper.YS_USER_ID, Optional.ofNullable(ru).map(RemoteUser::getUserNo).orElse(null));
model.setExtra(LoginHelper.OPEN_ID, loginBody.getOpenId()); model.setExtra(LoginHelper.OPEN_ID, loginBody.getOpenId());
......
...@@ -3,6 +3,7 @@ package org.dromara.common.core.domain.model; ...@@ -3,6 +3,7 @@ package org.dromara.common.core.domain.model;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.dromara.common.core.enums.UserType;
/** /**
* 用户登录对象 * 用户登录对象
...@@ -40,4 +41,9 @@ public class LoginBody { ...@@ -40,4 +41,9 @@ public class LoginBody {
*/ */
private String uuid; private String uuid;
/**
* 用户类型
*/
private String userType = UserType.SYS_USER.getUserType();
} }
...@@ -18,6 +18,7 @@ import org.dromara.server.api.domain.RemoteUser; ...@@ -18,6 +18,7 @@ import org.dromara.server.api.domain.RemoteUser;
import org.dromara.server.domain.BizUser; import org.dromara.server.domain.BizUser;
import org.dromara.server.mapper.BizUserMapper; import org.dromara.server.mapper.BizUserMapper;
import org.dromara.system.api.RemoteUserService; import org.dromara.system.api.RemoteUserService;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -41,10 +42,7 @@ public class RemoteServerServiceImpl implements RemoteServerService { ...@@ -41,10 +42,7 @@ public class RemoteServerServiceImpl implements RemoteServerService {
@GlobalTransactional(timeoutMills = 60000, rollbackFor = Exception.class) @GlobalTransactional(timeoutMills = 60000, rollbackFor = Exception.class)
@Override @Override
public boolean saveOrUpdateUser(RemoteUser user) { public boolean saveOrUpdateUser(RemoteUser user) {
String userNo = user.getTenantId() + "-" + user.getPhoneNumber(); String userNo = getUserNo(user.getTenantId(), user.getUserType(), user.getPhoneNumber());
if (!StringUtils.equals(user.getUserType(), UserType.SYS_USER.getUserType())) {
userNo = user.getTenantId() + "-" + user.getUserType() + "-" + user.getPhoneNumber();
}
BizUser bz = userMapper.selectOne(new LambdaQueryWrapper<>(BizUser.class).eq(BizUser::getUserNo, userNo)); BizUser bz = userMapper.selectOne(new LambdaQueryWrapper<>(BizUser.class).eq(BizUser::getUserNo, userNo));
if (Objects.isNull(bz)) { if (Objects.isNull(bz)) {
//新增 //新增
...@@ -73,9 +71,18 @@ public class RemoteServerServiceImpl implements RemoteServerService { ...@@ -73,9 +71,18 @@ public class RemoteServerServiceImpl implements RemoteServerService {
return false; return false;
} }
@Override @NotNull
public RemoteUser getUserByPhone(String tenantId, String phone) { private String getUserNo(String tenantId, String userType, String phone) {
String userNo = tenantId + "-" + phone; String userNo = tenantId + "-" + phone;
if (!StringUtils.equals(userType, UserType.SYS_USER.getUserType())) {
userNo = tenantId + "-" + userType + "-" + phone;
}
return userNo;
}
@Override
public RemoteUser getUserByPhone(String tenantId, String userType, String phone) {
String userNo = getUserNo(tenantId, userType, phone);
return BeanUtil.copyProperties(userMapper.selectOne(new LambdaQueryWrapper<>(BizUser.class).eq(BizUser::getUserNo, userNo)), RemoteUser.class); return BeanUtil.copyProperties(userMapper.selectOne(new LambdaQueryWrapper<>(BizUser.class).eq(BizUser::getUserNo, userNo)), RemoteUser.class);
} }
......
...@@ -24,6 +24,7 @@ import org.dromara.common.satoken.utils.LoginHelper; ...@@ -24,6 +24,7 @@ import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.common.web.core.BaseController; import org.dromara.common.web.core.BaseController;
import org.dromara.system.api.model.LoginUser; import org.dromara.system.api.model.LoginUser;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.bo.SysDeptBo; import org.dromara.system.domain.bo.SysDeptBo;
import org.dromara.system.domain.bo.SysPostBo; import org.dromara.system.domain.bo.SysPostBo;
import org.dromara.system.domain.bo.SysRoleBo; import org.dromara.system.domain.bo.SysRoleBo;
...@@ -75,7 +76,7 @@ public class SysUserController extends BaseController { ...@@ -75,7 +76,7 @@ public class SysUserController extends BaseController {
@SaCheckPermission("system:project:user:list") @SaCheckPermission("system:project:user:list")
@GetMapping("/project/list") @GetMapping("/project/list")
public TableDataInfo<SysUserVo> projectUserList(SysUserBo user, PageQuery pageQuery) { public TableDataInfo<SysUserVo> projectUserList(SysUserBo user, PageQuery pageQuery) {
user.setUserType(StringUtils.isEmpty(user.getUserType()) ? UserType.PROJECT_USER.getUserType() : user.getUserType()); user.setUserType(StringUtils.isEmpty(user.getUserType()) ? SysUser.PROJECT_USER_TYPE : user.getUserType());
return userService.selectPageUserList(user, pageQuery); return userService.selectPageUserList(user, pageQuery);
} }
......
...@@ -5,6 +5,7 @@ import lombok.Data; ...@@ -5,6 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.dromara.common.core.constant.UserConstants; import org.dromara.common.core.constant.UserConstants;
import org.dromara.common.core.enums.UserType;
import org.dromara.common.tenant.core.TenantEntity; import org.dromara.common.tenant.core.TenantEntity;
import java.util.Date; import java.util.Date;
...@@ -21,6 +22,9 @@ import java.util.Date; ...@@ -21,6 +22,9 @@ import java.util.Date;
@TableName("sys_user") @TableName("sys_user")
public class SysUser extends TenantEntity { public class SysUser extends TenantEntity {
public static String PROJECT_USER_TYPE = UserType.PROJECT_USER.getUserType();
public static String PROJECT_USER_TYPE_SPLIT = ":";
/** /**
* 用户ID * 用户ID
*/ */
......
...@@ -33,6 +33,11 @@ public class WxUser extends TenantEntity { ...@@ -33,6 +33,11 @@ public class WxUser extends TenantEntity {
*/ */
private String openId; private String openId;
/**
* 用户类型
*/
private String userType;
/** /**
* 手机号码 * 手机号码
*/ */
......
...@@ -25,6 +25,11 @@ public class WxUserBo extends BaseEntity { ...@@ -25,6 +25,11 @@ public class WxUserBo extends BaseEntity {
*/ */
private Long userId; private Long userId;
/**
* 用户类型
*/
private String userType;
/** /**
* openId * openId
*/ */
......
...@@ -31,6 +31,11 @@ public class WxUserVo implements Serializable { ...@@ -31,6 +31,11 @@ public class WxUserVo implements Serializable {
*/ */
private String tenantId; private String tenantId;
/**
* 用户类型
*/
private String userType;
/** /**
* 用户账号 * 用户账号
*/ */
......
package org.dromara.system.dubbo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.system.api.RemoteProjectService;
import org.dromara.system.api.domain.vo.RemoteProjectVo;
import org.dromara.system.domain.SysUser;
import org.dromara.system.mapper.SysProjectMapper;
import org.dromara.system.mapper.SysUserMapper;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import static org.dromara.system.domain.SysUser.PROJECT_USER_TYPE_SPLIT;
/**
* @author hzh
* @date 2025-06-11
**/
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteProjectServiceImpl implements RemoteProjectService {
private final SysProjectMapper sysProjectMapper;
private final SysUserMapper sysUserMapper;
@Override
public List<RemoteProjectVo> queryList(String tenantId, String phone) {
List<SysUser> userList = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>()
.eq(StringUtils.isNotEmpty(tenantId), SysUser::getTenantId, tenantId)
.eq(StringUtils.isNotEmpty(phone), SysUser::getPhonenumber, phone)
.likeRight(SysUser::getUserType, SysUser.PROJECT_USER_TYPE)
.select(SysUser::getUserType)
);
Set<Long> projectIds = StreamUtils.toSet(userList, u -> {
String[] split = u.getUserType().split(PROJECT_USER_TYPE_SPLIT);
return Long.parseLong(split[1]);
});
return CollectionUtil.isEmpty(projectIds) ? List.of() : BeanUtil.copyToList(sysProjectMapper.selectByIds(projectIds), RemoteProjectVo.class);
}
}
...@@ -162,12 +162,15 @@ public class RemoteUserServiceImpl implements RemoteUserService { ...@@ -162,12 +162,15 @@ public class RemoteUserServiceImpl implements RemoteUserService {
/** /**
* 通过openid查询用户信息 * 通过openid查询用户信息
* *
* @param openid openid * @param openid openid
* @param phone 手机号
* @param userType 用户类型
* @param tenantId 租户id
* @return 结果 * @return 结果
*/ */
@Override @Override
public XcxLoginUser getUserInfoByOpenid(String openid, String phone, String tenantId) throws UserException { public XcxLoginUser getUserInfoByOpenid(String openid, String phone, String userType, String tenantId) throws UserException {
List<WxUserVo> wxUserList = wxUserService.selectUserByOpenId(openid, phone, tenantId); List<WxUserVo> wxUserList = wxUserService.selectUserByOpenId(openid, phone, userType, tenantId);
WxUserVo wxUser = CollectionUtils.isEmpty(wxUserList) ? null : wxUserList.get(0); WxUserVo wxUser = CollectionUtils.isEmpty(wxUserList) ? null : wxUserList.get(0);
if (!ObjectUtil.isNotNull(wxUser)) { if (!ObjectUtil.isNotNull(wxUser)) {
return null; return null;
...@@ -178,7 +181,7 @@ public class RemoteUserServiceImpl implements RemoteUserService { ...@@ -178,7 +181,7 @@ public class RemoteUserServiceImpl implements RemoteUserService {
} }
//根据手机号查询用户信息 //根据手机号查询用户信息
SysUserVo user = userService.selectUserByPhonenumber(wxUser.getPhonenumber(), wxUser.getTenantId()); SysUserVo user = userService.selectUserByPhonenumber(wxUser.getPhonenumber(), wxUser.getUserType(), wxUser.getTenantId());
if (!ObjectUtil.isNotNull(user)) { if (!ObjectUtil.isNotNull(user)) {
throw new UserException("user.not.exists", wxUser.getPhonenumber()); throw new UserException("user.not.exists", wxUser.getPhonenumber());
} }
...@@ -231,7 +234,7 @@ public class RemoteUserServiceImpl implements RemoteUserService { ...@@ -231,7 +234,7 @@ public class RemoteUserServiceImpl implements RemoteUserService {
public Boolean registerWxUserInfo(RemoteWxUserBo remoteWxUserBo) { public Boolean registerWxUserInfo(RemoteWxUserBo remoteWxUserBo) {
WxUserBo user = BeanUtil.copyProperties(remoteWxUserBo, WxUserBo.class); WxUserBo user = BeanUtil.copyProperties(remoteWxUserBo, WxUserBo.class);
List<WxUserVo> wxUserVoList = wxUserService.selectUserByOpenId(remoteWxUserBo.getOpenId(), remoteWxUserBo.getPhonenumber(), remoteWxUserBo.getTenantId()); List<WxUserVo> wxUserVoList = wxUserService.selectUserByOpenId(remoteWxUserBo.getOpenId(), remoteWxUserBo.getPhonenumber(), remoteWxUserBo.getUserType(), remoteWxUserBo.getTenantId());
if (CollectionUtils.isNotEmpty(wxUserVoList)) { if (CollectionUtils.isNotEmpty(wxUserVoList)) {
return true; return true;
} }
......
...@@ -60,10 +60,11 @@ public interface ISysUserService { ...@@ -60,10 +60,11 @@ public interface ISysUserService {
* 通过手机号查询用户 * 通过手机号查询用户
* *
* @param phonenumber 手机号 * @param phonenumber 手机号
* @param tenantId tenantId * @param userType 用户类型
* @param tenantId tenantId
* @return 用户对象信息 * @return 用户对象信息
*/ */
SysUserVo selectUserByPhonenumber(String phonenumber,String tenantId); SysUserVo selectUserByPhonenumber(String phonenumber, String userType, String tenantId);
/** /**
* 通过用户ID查询用户 * 通过用户ID查询用户
......
...@@ -17,10 +17,11 @@ public interface IWxUserService { ...@@ -17,10 +17,11 @@ public interface IWxUserService {
* *
* @param openId openId * @param openId openId
* @param phone phone * @param phone phone
* @param userType userType
* @param tenantId 租户ID * @param tenantId 租户ID
* @return 用户对象信息 * @return 用户对象信息
*/ */
List<WxUserVo> selectUserByOpenId(String openId, String phone, String tenantId); List<WxUserVo> selectUserByOpenId(String openId, String phone, String userType, String tenantId);
/** /**
* 注册用户 * 注册用户
......
...@@ -242,11 +242,12 @@ public class SysUserServiceImpl implements ISysUserService { ...@@ -242,11 +242,12 @@ public class SysUserServiceImpl implements ISysUserService {
* 通过手机号查询用户 * 通过手机号查询用户
* *
* @param phonenumber 手机号 * @param phonenumber 手机号
* @param userType 用户类型
* @param tenantId tenantId * @param tenantId tenantId
* @return 用户对象信息 * @return 用户对象信息
*/ */
@Override @Override
public SysUserVo selectUserByPhonenumber(String phonenumber, String tenantId) { public SysUserVo selectUserByPhonenumber(String phonenumber, String userType, String tenantId) {
SysTenant sysTenant = TenantHelper.dynamic(tenantId, () -> sysTenantMapper.selectOne(SysTenant::getTenantId, tenantId)); SysTenant sysTenant = TenantHelper.dynamic(tenantId, () -> sysTenantMapper.selectOne(SysTenant::getTenantId, tenantId));
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhonenumber, phonenumber) return baseMapper.selectVoOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhonenumber, phonenumber)
.eq(SysUser::getTenantId, tenantId) .eq(SysUser::getTenantId, tenantId)
......
...@@ -35,10 +35,11 @@ public class WxUserServiceImpl implements IWxUserService { ...@@ -35,10 +35,11 @@ public class WxUserServiceImpl implements IWxUserService {
* @return 用户对象信息 * @return 用户对象信息
*/ */
@Override @Override
public List<WxUserVo> selectUserByOpenId(String openId, String phone, String tenantId) { public List<WxUserVo> selectUserByOpenId(String openId, String phone, String userType, String tenantId) {
return baseMapper.selectVoList( return baseMapper.selectVoList(
new LambdaQueryWrapper<WxUser>() new LambdaQueryWrapper<WxUser>()
.eq(WxUser::getOpenId, openId) .eq(WxUser::getOpenId, openId)
.eq(WxUser::getUserType, userType)
.eq(StringUtils.isNotBlank(phone), WxUser::getPhonenumber, phone) .eq(StringUtils.isNotBlank(phone), WxUser::getPhonenumber, phone)
.eq(WxUser::getTenantId, tenantId)); .eq(WxUser::getTenantId, tenantId));
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论