feat: 添加代码格式化
This commit is contained in:
@@ -7,7 +7,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
@MapperScan("cn.meowrain.aioj.backend.userservice.dao.mapper")
|
||||
public class UserServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UserServiceApplication.class, args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UserServiceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,20 +5,22 @@ import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public enum ChainMarkEnums {
|
||||
/**
|
||||
* 用户注册请求验证
|
||||
*/
|
||||
USER_REGISTER_REQ_PARAM_VERIFY("USER_REGISTER_REQ_PARAM_VERIFY"),
|
||||
/**
|
||||
* 用户登录请求验证
|
||||
*/
|
||||
USER_LOGIN_REQ_PARAM_VERIFY("USER_LOGIN_REQ_PARAM_VERIFY");
|
||||
|
||||
@Getter
|
||||
private final String markName;
|
||||
/**
|
||||
* 用户注册请求验证
|
||||
*/
|
||||
USER_REGISTER_REQ_PARAM_VERIFY("USER_REGISTER_REQ_PARAM_VERIFY"),
|
||||
/**
|
||||
* 用户登录请求验证
|
||||
*/
|
||||
USER_LOGIN_REQ_PARAM_VERIFY("USER_LOGIN_REQ_PARAM_VERIFY");
|
||||
|
||||
@Getter
|
||||
private final String markName;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return markName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return markName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@ import org.springframework.context.annotation.ComponentScans;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScans({
|
||||
@ComponentScan("cn.meowrain.aioj.backend.framework.core.banner")
|
||||
})
|
||||
@ComponentScans({ @ComponentScan("cn.meowrain.aioj.backend.framework.core.banner") })
|
||||
public class FrameworkConfiguration {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,23 +16,25 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
@EnableKnife4j
|
||||
public class SwaggerConfiguration implements ApplicationRunner {
|
||||
@Value("${server.port:8080}")
|
||||
private String serverPort;
|
||||
@Value("${server.servlet.context-path:}")
|
||||
private String contextPath;
|
||||
|
||||
@Bean
|
||||
public OpenAPI customerOpenAPI() {
|
||||
return new OpenAPI()
|
||||
.info(new Info()
|
||||
.title("AIOJ-用户微服务✨")
|
||||
.description("用户注册,用户登录等功能")
|
||||
.version("v1.0.0")
|
||||
.contact(new Contact().name("meowrain").email("meowrain@126.com"))
|
||||
.license(new License().name("MeowRain").url("https://meowrain.cn")));
|
||||
}
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
log.info("✨API Document: http://127.0.0.1:{}{}/doc.html", serverPort, contextPath);
|
||||
}
|
||||
@Value("${server.port:8080}")
|
||||
private String serverPort;
|
||||
|
||||
@Value("${server.servlet.context-path:}")
|
||||
private String contextPath;
|
||||
|
||||
@Bean
|
||||
public OpenAPI customerOpenAPI() {
|
||||
return new OpenAPI().info(new Info().title("AIOJ-用户微服务✨")
|
||||
.description("用户注册,用户登录等功能")
|
||||
.version("v1.0.0")
|
||||
.contact(new Contact().name("meowrain").email("meowrain@126.com"))
|
||||
.license(new License().name("MeowRain").url("https://meowrain.cn")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
log.info("✨API Document: http://127.0.0.1:{}{}/doc.html", serverPort, contextPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,25 +13,24 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequestMapping("/v1/user")
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
private final UserService userService;
|
||||
|
||||
@PostMapping("/register")
|
||||
public Result<Long> register(@RequestBody UserRegisterRequestDTO userRegisterRequest) {
|
||||
Long l = userService.userRegister(userRegisterRequest);
|
||||
return Results.success(l);
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public Result<Long> register(@RequestBody UserRegisterRequestDTO userRegisterRequest) {
|
||||
Long l = userService.userRegister(userRegisterRequest);
|
||||
return Results.success(l);
|
||||
}
|
||||
@GetMapping("/inner/get-by-username")
|
||||
public Result<UserAuthRespDTO> getUserByUserName(@RequestParam("userAccount") String userAccount) {
|
||||
UserAuthRespDTO userAuthDTO = userService.findAuthInfoByUserAccount(userAccount);
|
||||
return Results.success(userAuthDTO);
|
||||
}
|
||||
|
||||
@GetMapping("/inner/get-by-username")
|
||||
public Result<UserAuthRespDTO> getUserByUserName(@RequestParam("userAccount") String userAccount) {
|
||||
UserAuthRespDTO userAuthDTO = userService.findAuthInfoByUserAccount(userAccount);
|
||||
return Results.success(userAuthDTO);
|
||||
}
|
||||
|
||||
@GetMapping("/inner/get-by-userid")
|
||||
public Result<UserAuthRespDTO> getUserById(@RequestParam("userId") String userid) {
|
||||
UserAuthRespDTO userAuthRespDTO = userService.findAuthInfoByUserId(userid);
|
||||
return Results.success(userAuthRespDTO);
|
||||
}
|
||||
@GetMapping("/inner/get-by-userid")
|
||||
public Result<UserAuthRespDTO> getUserById(@RequestParam("userId") String userid) {
|
||||
UserAuthRespDTO userAuthRespDTO = userService.findAuthInfoByUserId(userid);
|
||||
return Results.success(userAuthRespDTO);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,69 +12,70 @@ import java.util.Date;
|
||||
@Accessors(chain = true)
|
||||
public class User implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userAccount;
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userAccount;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String userPassword;
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String userPassword;
|
||||
|
||||
/**
|
||||
* 开放平台id
|
||||
*/
|
||||
private String unionId;
|
||||
/**
|
||||
* 开放平台id
|
||||
*/
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 公众号openId
|
||||
*/
|
||||
private String mpOpenId;
|
||||
/**
|
||||
* 公众号openId
|
||||
*/
|
||||
private String mpOpenId;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String userAvatar;
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 用户简介
|
||||
*/
|
||||
private String userProfile;
|
||||
/**
|
||||
* 用户简介
|
||||
*/
|
||||
private String userProfile;
|
||||
|
||||
/**
|
||||
* 用户角色:user/admin/ban
|
||||
*/
|
||||
private String userRole;
|
||||
/**
|
||||
* 用户角色:user/admin/ban
|
||||
*/
|
||||
private String userRole;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@TableLogic
|
||||
private Integer isDelete;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
@@ -4,4 +4,5 @@ import cn.meowrain.aioj.backend.userservice.dao.entity.User;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
}
|
||||
|
||||
@@ -12,32 +12,34 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
@Slf4j
|
||||
public class UserRegisterRequestParamVerifyChain implements AbstractChianHandler<UserRegisterRequestDTO> {
|
||||
@Override
|
||||
public void handle(UserRegisterRequestDTO requestParam) {
|
||||
// 校验参数里面用户名和密码是不是空的
|
||||
if (StringUtils.isAnyBlank(requestParam.getUserAccount(), requestParam.getUserPassword())) {
|
||||
throw new ClientException("参数为空", ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
if (requestParam.getUserAccount().length() < 4) {
|
||||
throw new ClientException("账号长度不小于4位", ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
if (requestParam.getUserPassword().length() < 8) {
|
||||
throw new ClientException("密码长度不小于8位", ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
// 密码和校验密码相同
|
||||
if (!requestParam.getUserPassword().equals(requestParam.getCheckPassword())) {
|
||||
throw new ClientException("两次输入的密码不一致", ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void handle(UserRegisterRequestDTO requestParam) {
|
||||
// 校验参数里面用户名和密码是不是空的
|
||||
if (StringUtils.isAnyBlank(requestParam.getUserAccount(), requestParam.getUserPassword())) {
|
||||
throw new ClientException("参数为空", ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
if (requestParam.getUserAccount().length() < 4) {
|
||||
throw new ClientException("账号长度不小于4位", ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
if (requestParam.getUserPassword().length() < 8) {
|
||||
throw new ClientException("密码长度不小于8位", ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
// 密码和校验密码相同
|
||||
if (!requestParam.getUserPassword().equals(requestParam.getCheckPassword())) {
|
||||
throw new ClientException("两次输入的密码不一致", ErrorCode.PARAMS_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mark() {
|
||||
return ChainMarkEnums.USER_REGISTER_REQ_PARAM_VERIFY.getMarkName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mark() {
|
||||
return ChainMarkEnums.USER_REGISTER_REQ_PARAM_VERIFY.getMarkName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class UserRegisterRequestParamVerifyContext extends CommonChainContext<UserRegisterRequestDTO> {
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserLoginRequestDTO {
|
||||
private String userAccount;
|
||||
private String userPassword;
|
||||
|
||||
private String userAccount;
|
||||
|
||||
private String userPassword;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,11 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
public class UserRegisterRequestDTO {
|
||||
private String userAccount;
|
||||
private String userPassword;
|
||||
private String checkPassword;
|
||||
|
||||
private String userAccount;
|
||||
|
||||
private String userPassword;
|
||||
|
||||
private String checkPassword;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,60 +10,59 @@ import java.util.Date;
|
||||
@Data
|
||||
public class UserAuthRespDTO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userAccount;
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String userPassword;
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userAccount;
|
||||
|
||||
/**
|
||||
* 开放平台id
|
||||
*/
|
||||
private String unionId;
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String userPassword;
|
||||
|
||||
/**
|
||||
* 公众号openId
|
||||
*/
|
||||
private String mpOpenId;
|
||||
/**
|
||||
* 开放平台id
|
||||
*/
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 公众号openId
|
||||
*/
|
||||
private String mpOpenId;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String userAvatar;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户简介
|
||||
*/
|
||||
private String userProfile;
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 用户角色:user/admin/ban
|
||||
*/
|
||||
private String userRole;
|
||||
/**
|
||||
* 用户简介
|
||||
*/
|
||||
private String userProfile;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 用户角色:user/admin/ban
|
||||
*/
|
||||
private String userRole;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -8,68 +8,69 @@ import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class UserLoginResponseDTO implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userAccount;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 开放平台id
|
||||
*/
|
||||
private String unionId;
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String userAccount;
|
||||
|
||||
/**
|
||||
* 公众号openId
|
||||
*/
|
||||
private String mpOpenId;
|
||||
/**
|
||||
* 开放平台id
|
||||
*/
|
||||
private String unionId;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 公众号openId
|
||||
*/
|
||||
private String mpOpenId;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String userAvatar;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户简介
|
||||
*/
|
||||
private String userProfile;
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 用户角色:user/admin/ban
|
||||
*/
|
||||
private String userRole;
|
||||
/**
|
||||
* 用户简介
|
||||
*/
|
||||
private String userProfile;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 用户角色:user/admin/ban
|
||||
*/
|
||||
private String userRole;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
private Integer isDelete;
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
|
||||
private Integer isDelete;
|
||||
|
||||
/**
|
||||
* JWT令牌(登录成功返回)
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* JWT令牌(登录成功返回)
|
||||
*/
|
||||
private String token;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
@@ -9,5 +9,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
@Data
|
||||
public class UserRegisterResponseDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,24 +7,25 @@ import cn.meowrain.aioj.backend.userservice.dto.resp.UserAuthRespDTO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface UserService extends IService<User> {
|
||||
/**
|
||||
* 用户注册
|
||||
* @param request {@link cn.meowrain.aioj.backend.userservice.dto.req.UserRegisterRequestDTO}
|
||||
* @return {@link Long}
|
||||
*/
|
||||
Long userRegister(UserRegisterRequestDTO request);
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
* @param request
|
||||
* {@link cn.meowrain.aioj.backend.userservice.dto.req.UserRegisterRequestDTO}
|
||||
* @return {@link Long}
|
||||
*/
|
||||
Long userRegister(UserRegisterRequestDTO request);
|
||||
|
||||
/**
|
||||
* 根据用户账号查找用户认证信息
|
||||
* @param userAccount
|
||||
* @return
|
||||
*/
|
||||
UserAuthRespDTO findAuthInfoByUserAccount(String userAccount);
|
||||
|
||||
/**
|
||||
* 根据用户账号查找用户认证信息
|
||||
* @param userAccount
|
||||
* @return
|
||||
*/
|
||||
UserAuthRespDTO findAuthInfoByUserAccount(String userAccount);
|
||||
/**
|
||||
* 根据用户id查找用户认证信息
|
||||
*/
|
||||
UserAuthRespDTO findAuthInfoByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据用户id查找用户认证信息
|
||||
*/
|
||||
UserAuthRespDTO findAuthInfoByUserId(String userId);
|
||||
}
|
||||
|
||||
@@ -25,56 +25,61 @@ import java.util.Date;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
private final UserRegisterRequestParamVerifyContext userRegisterRequestParamVerifyContext;
|
||||
|
||||
@Override
|
||||
public Long userRegister(UserRegisterRequestDTO request) {
|
||||
UserAuthRespDTO authInfoByUserAccount = findAuthInfoByUserAccount(request.getUserAccount());
|
||||
if (authInfoByUserAccount != null) {
|
||||
throw new ClientException("重复创建用户");
|
||||
}
|
||||
private final UserRegisterRequestParamVerifyContext userRegisterRequestParamVerifyContext;
|
||||
|
||||
log.info("进行用户注册");
|
||||
userRegisterRequestParamVerifyContext.handler(ChainMarkEnums.USER_REGISTER_REQ_PARAM_VERIFY.getMarkName(),
|
||||
request);
|
||||
// 使用 BCrypt 加密密码
|
||||
Date now = new Date();
|
||||
String salt = BCrypt.gensalt();
|
||||
String encryptPassword = BCrypt.hashpw(request.getUserPassword(), salt);
|
||||
User user = new User().setUserAccount(request.getUserAccount()).setUserPassword(encryptPassword)
|
||||
.setUserRole("user").setCreateTime(now).setUpdateTime(now);
|
||||
try {
|
||||
// 需要修改表,使得用户名是唯一的
|
||||
this.save(user);
|
||||
} catch (DuplicateKeyException e) {
|
||||
log.error("重复创建用户");
|
||||
throw new ServiceException("用户名已存在", ErrorCode.SYSTEM_ERROR);
|
||||
}
|
||||
@Override
|
||||
public Long userRegister(UserRegisterRequestDTO request) {
|
||||
UserAuthRespDTO authInfoByUserAccount = findAuthInfoByUserAccount(request.getUserAccount());
|
||||
if (authInfoByUserAccount != null) {
|
||||
throw new ClientException("重复创建用户");
|
||||
}
|
||||
|
||||
return user.getId();
|
||||
}
|
||||
log.info("进行用户注册");
|
||||
userRegisterRequestParamVerifyContext.handler(ChainMarkEnums.USER_REGISTER_REQ_PARAM_VERIFY.getMarkName(),
|
||||
request);
|
||||
// 使用 BCrypt 加密密码
|
||||
Date now = new Date();
|
||||
String salt = BCrypt.gensalt();
|
||||
String encryptPassword = BCrypt.hashpw(request.getUserPassword(), salt);
|
||||
User user = new User().setUserAccount(request.getUserAccount())
|
||||
.setUserPassword(encryptPassword)
|
||||
.setUserRole("user")
|
||||
.setCreateTime(now)
|
||||
.setUpdateTime(now);
|
||||
try {
|
||||
// 需要修改表,使得用户名是唯一的
|
||||
this.save(user);
|
||||
}
|
||||
catch (DuplicateKeyException e) {
|
||||
log.error("重复创建用户");
|
||||
throw new ServiceException("用户名已存在", ErrorCode.SYSTEM_ERROR);
|
||||
}
|
||||
|
||||
return user.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAuthRespDTO findAuthInfoByUserAccount(String userAccount) {
|
||||
User one = this.lambdaQuery().eq(User::getUserAccount, userAccount).one();
|
||||
UserAuthRespDTO userAuthDTO = new UserAuthRespDTO();
|
||||
if (one != null) {
|
||||
BeanUtils.copyProperties(one, userAuthDTO);
|
||||
return userAuthDTO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public UserAuthRespDTO findAuthInfoByUserAccount(String userAccount) {
|
||||
User one = this.lambdaQuery().eq(User::getUserAccount, userAccount).one();
|
||||
UserAuthRespDTO userAuthDTO = new UserAuthRespDTO();
|
||||
if (one != null) {
|
||||
BeanUtils.copyProperties(one, userAuthDTO);
|
||||
return userAuthDTO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserAuthRespDTO findAuthInfoByUserId(String userId) {
|
||||
User one = this.lambdaQuery().eq(User::getId, userId).one();
|
||||
UserAuthRespDTO userAuthDTO = new UserAuthRespDTO();
|
||||
if (one != null) {
|
||||
BeanUtils.copyProperties(one, userAuthDTO);
|
||||
return userAuthDTO;
|
||||
}
|
||||
return null;
|
||||
@Override
|
||||
public UserAuthRespDTO findAuthInfoByUserId(String userId) {
|
||||
User one = this.lambdaQuery().eq(User::getId, userId).one();
|
||||
UserAuthRespDTO userAuthDTO = new UserAuthRespDTO();
|
||||
if (one != null) {
|
||||
BeanUtils.copyProperties(one, userAuthDTO);
|
||||
return userAuthDTO;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user