refactor(system): 移除手机号唯一限制,改由数据库唯一约束处理
- 取消注册管理员时手机号唯一校验,允许同一手机号创建多个租户 - 删除代码中重复注册手机号的业务检查逻辑 - 数据库查询手机号码管理员时,强制必须传入租户ID进行多租户支持 - 修改SQL注释,明确手机管理员查询需提供租户ID - 保证手机号唯一性通过数据库唯一约束机制实现,提高数据一致性和扩展性
This commit is contained in:
@@ -754,14 +754,8 @@ public class MainController extends BaseController {
|
||||
if (!StrUtil.equals(code, cacheClient.get(phone, String.class))) {
|
||||
throw new BusinessException("验证码不正确");
|
||||
}
|
||||
// 注册管理员
|
||||
final UserParam param = new UserParam();
|
||||
param.setPhone(phone);
|
||||
param.setTemplateId(user.getTemplateId());
|
||||
param.setIsAdmin(true);
|
||||
if (userService.getAdminByPhone(param) != null) {
|
||||
throw new BusinessException("该手机号码已注册");
|
||||
}
|
||||
// 注册管理员(已去掉手机号唯一限制,同一手机号可创建多个租户)
|
||||
// 重复注册的检查由数据库唯一约束处理
|
||||
|
||||
// 验证租户名称是否重复
|
||||
if (StrUtil.isNotBlank(tenantName)) {
|
||||
@@ -924,14 +918,8 @@ public class MainController extends BaseController {
|
||||
if (!StrUtil.equals(code, cacheClient.get(phone, String.class)) && !StrUtil.equals(code, redisUtil.get(CACHE_KEY_VERIFICATION_CODE_BY_DEV_SMS))) {
|
||||
throw new BusinessException("验证码不正确");
|
||||
}
|
||||
// 注册管理员
|
||||
final UserParam param = new UserParam();
|
||||
param.setPhone(phone);
|
||||
param.setIsAdmin(true);
|
||||
param.setTemplateId(user.getTemplateId());
|
||||
if (userService.getAdminByPhone(param) != null) {
|
||||
throw new BusinessException("该手机号码已注册");
|
||||
}
|
||||
// 注册管理员(已去掉手机号唯一限制,同一手机号可创建多个租户)
|
||||
// 重复注册的检查由数据库唯一约束处理
|
||||
|
||||
// 验证租户名称是否重复
|
||||
if (StrUtil.isNotBlank(tenantName)) {
|
||||
|
||||
@@ -316,7 +316,7 @@
|
||||
WHERE user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!-- 根据手机号码查询 -->
|
||||
<!-- 根据手机号码查询(支持多租户:必须传 tenantId 才能查到对应租户的管理员) -->
|
||||
<select id="selectAdminByPhone" resultType="com.gxwebsoft.common.system.entity.User">
|
||||
SELECT a.*
|
||||
FROM sys_user a
|
||||
@@ -324,9 +324,7 @@
|
||||
AND a.deleted = 0
|
||||
AND a.phone = #{param.phone}
|
||||
AND (a.username = 'superAdmin' OR a.username = 'admin' OR a.is_admin = 1)
|
||||
<if test="param.tenantId">
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
</if>
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
LIMIT 1
|
||||
</where>
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user