Compare commits
2 Commits
df7a41f3c4
...
607589d2c5
| Author | SHA1 | Date | |
|---|---|---|---|
| 607589d2c5 | |||
| 424929222f |
@@ -67,13 +67,24 @@ public class AppUserController extends BaseController {
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@Operation(summary = "邀请用户成为应用成员")
|
||||
@Operation(summary = "邀请用户成为应用成员(支持用户ID或手机号)")
|
||||
@PostMapping("/invite")
|
||||
public ApiResult<?> invite(@RequestBody AppUser appUser) {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
// 支持手机号邀请:若 userId 为空但传了 phone,则先按手机号查出用户
|
||||
if (appUser.getUserId() == null && appUser.getPhone() != null && !appUser.getPhone().isEmpty()) {
|
||||
User targetUser = appUserService.findUserByPhone(appUser.getPhone());
|
||||
if (targetUser == null) {
|
||||
return fail("手机号未注册,请确认后再试");
|
||||
}
|
||||
appUser.setUserId(targetUser.getUserId());
|
||||
}
|
||||
if (appUser.getUserId() == null) {
|
||||
return fail("请输入用户ID或手机号");
|
||||
}
|
||||
try {
|
||||
AppUser result = appUserService.inviteUser(
|
||||
appUser.getWebsiteId(),
|
||||
|
||||
@@ -57,4 +57,12 @@ public interface AppUserService extends IService<AppUser> {
|
||||
*/
|
||||
boolean isMember(Long websiteId, Integer userId);
|
||||
|
||||
/**
|
||||
* 根据手机号查找系统用户(用于手机号邀请)
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @return 系统用户,不存在返回 null
|
||||
*/
|
||||
com.gxwebsoft.common.system.entity.User findUserByPhone(String phone);
|
||||
|
||||
}
|
||||
|
||||
@@ -104,4 +104,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findUserByPhone(String phone) {
|
||||
return userService.getByPhone(phone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,6 +62,14 @@ public interface UserMapper extends BaseMapper<User> {
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
User selectByIdIgnoreTenant(@Param("userId") Integer userId);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户(忽略租户隔离,跨库查 gxwebsoft_core.sys_user)
|
||||
* @param phone 手机号
|
||||
* @return User
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
User selectByPhone(@Param("phone") String phone);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<User> pageAdminByPhone(@Param("param") UserParam param);
|
||||
|
||||
|
||||
@@ -182,20 +182,13 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 根据手机号码查询 -->
|
||||
<!-- 根据手机号码查询(跨租户,忽略租户隔离) -->
|
||||
<select id="selectByPhone" resultType="com.gxwebsoft.common.system.entity.User">
|
||||
SELECT a.*
|
||||
FROM gxwebsoft_core.sys_user a
|
||||
<where>
|
||||
AND a.deleted = 0
|
||||
WHERE a.deleted = 0
|
||||
AND a.phone = #{phone}
|
||||
<if test="tenantId != null">
|
||||
AND a.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="tenantId == null">
|
||||
AND a.tenant_id = 1
|
||||
</if>
|
||||
</where>
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 获取所有的邮政协会/管局工作人员 -->
|
||||
|
||||
@@ -180,7 +180,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
|
||||
@Override
|
||||
public User getByPhone(String phone) {
|
||||
return query().eq("phone", phone).one();
|
||||
// 使用自定义 SQL(@InterceptorIgnore),避免 TenantLineInterceptor 把表定位到当前库的 sys_user
|
||||
return baseMapper.selectByPhone(phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user