mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 04:29:21 +08:00
sql: sys_user.phone 非空并清理无手机号测试账号
This commit is contained in:
+2
-1
@@ -20,8 +20,9 @@ public class CreateAccountDTO {
|
||||
@Size(min = 6, max = 20, message = "密码长度为6-20个字符")
|
||||
private String password;
|
||||
|
||||
/** 手机号;新建用户时仅写 phone,username 留空 */
|
||||
/** 手机号(必填);新建用户时仅写 phone,username 留空 */
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确")
|
||||
private String phone;
|
||||
|
||||
@NotBlank(message = "用户姓名不能为空")
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.org.company.model.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -34,9 +35,10 @@ public class CreateCompanyDTO {
|
||||
private String ownerName;
|
||||
|
||||
/**
|
||||
* 公司拥有者电话(作为登录账号)
|
||||
* 公司拥有者电话(必填,用于创建/匹配用户)
|
||||
*/
|
||||
@NotBlank(message = "公司拥有者电话不能为空")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "公司拥有者电话格式不正确")
|
||||
private String ownerPhone;
|
||||
|
||||
/**
|
||||
|
||||
+4
-13
@@ -5,7 +5,7 @@ import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户注册DTO
|
||||
* 用户注册 DTO(手机号必填;登录用户名可选)
|
||||
*/
|
||||
@Data
|
||||
public class RegisterDTO {
|
||||
@@ -16,24 +16,15 @@ public class RegisterDTO {
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
* 手机号码(必填)
|
||||
*/
|
||||
@Pattern(regexp = "^(|1[3-9]\\d{9})$", message = "手机号码格式不正确")
|
||||
@NotBlank(message = "手机号码不能为空")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 登录密码
|
||||
*/
|
||||
@NotBlank(message = "密码不能为空")
|
||||
// @Pattern(regexp = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d@$!%*?&]{8,}$",
|
||||
// message = "密码必须包含大小写字母和数字,长度至少8位")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 验证登录账号和手机号码至少填写一个
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return (username != null && !username.trim().isEmpty()) ||
|
||||
(phone != null && !phone.trim().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,9 +25,9 @@ public class UpdateUserInfoDTO {
|
||||
private Long avatarImageId;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
* 手机号码(必填;更新时不可清空)
|
||||
*/
|
||||
@Pattern(regexp = "^(|1[3-9]\\d{9})$", message = "手机号码格式不正确")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
|
||||
+5
-12
@@ -70,11 +70,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
||||
*/
|
||||
@Override
|
||||
public LoginVO register(RegisterDTO registerDTO) {
|
||||
// 验证登录账号和手机号码至少填写一个
|
||||
if (!registerDTO.isValid()) {
|
||||
throw new BusinessException("登录账号和手机号码至少填写一个");
|
||||
}
|
||||
|
||||
// 检查登录用户名是否已存在
|
||||
if (StringUtils.hasText(registerDTO.getUsername())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
@@ -84,13 +79,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserPO> implements
|
||||
}
|
||||
}
|
||||
|
||||
// 检查手机号码是否已存在
|
||||
if (StringUtils.hasText(registerDTO.getPhone())) {
|
||||
LambdaQueryWrapper<UserPO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(UserPO::getPhone, registerDTO.getPhone());
|
||||
if (this.count(wrapper) > 0) {
|
||||
throw new BusinessException("手机号码已存在");
|
||||
}
|
||||
// 手机号必填且唯一
|
||||
LambdaQueryWrapper<UserPO> phoneWrapper = new LambdaQueryWrapper<>();
|
||||
phoneWrapper.eq(UserPO::getPhone, registerDTO.getPhone());
|
||||
if (this.count(phoneWrapper) > 0) {
|
||||
throw new BusinessException("手机号码已存在");
|
||||
}
|
||||
|
||||
// 创建用户
|
||||
|
||||
Reference in New Issue
Block a user