新增用户可以手动填写用户id

This commit is contained in:
2023-07-27 14:08:11 +08:00
parent 77cda9ae6e
commit ecb099f12a
2 changed files with 12 additions and 1 deletions

View File

@@ -98,6 +98,11 @@ public class UserParam {
@NotBlank(message = UserValidMessage.LOGIN_NAME_NOT_BLANK) @NotBlank(message = UserValidMessage.LOGIN_NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.LOGIN_NAME_REGEX, message = UserValidMessage.LOGIN_NAME_FORMAT_ERROR) @Pattern(regexp = PatternRegex.LOGIN_NAME_REGEX, message = UserValidMessage.LOGIN_NAME_FORMAT_ERROR)
private String loginName; private String loginName;
@ApiModelProperty("用户表Id")
@NotBlank(message = UserValidMessage.ID_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
private String id;
} }

View File

@@ -21,6 +21,7 @@ import com.njcn.user.pojo.po.UserSet;
import com.njcn.user.service.IUserSetService; import com.njcn.user.service.IUserSetService;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Objects; import java.util.Objects;
@@ -45,8 +46,13 @@ public class UserSetServiceImpl extends ServiceImpl<UserSetMapper, UserSet> impl
@Override @Override
public UserSet addUserSet(UserParam.UserAddParam addUserParam) { public UserSet addUserSet(UserParam.UserAddParam addUserParam) {
String userId;
UserSet userSet = new UserSet(); UserSet userSet = new UserSet();
String userId = IdUtil.simpleUUID(); if (StringUtils.isBlank(addUserParam.getId()) || Objects.isNull(addUserParam.getId())){
userId = IdUtil.simpleUUID();
} else {
userId = addUserParam.getId();
}
userSet.setUserId(userId); userSet.setUserId(userId);
String secretKey = PubUtils.randomCode(16); String secretKey = PubUtils.randomCode(16);
userSet.setSecretKey(secretKey); userSet.setSecretKey(secretKey);