feat: bug修复
This commit is contained in:
@@ -31,15 +31,16 @@ public class UserController {
|
||||
|
||||
@Resource
|
||||
private AuthUserDomainService authUserDomainService;
|
||||
/**
|
||||
* @description: 用户注册
|
||||
|
||||
/**
|
||||
* @description: 用户注册
|
||||
* @param: []
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 13:57
|
||||
*/
|
||||
*/
|
||||
@PostMapping("register")
|
||||
public Result<Boolean> register(@RequestBody AuthUserDTO authUserDTO){
|
||||
public Result<Boolean> register(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.register.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
@@ -52,15 +53,16 @@ public class UserController {
|
||||
return Result.fail("注册用户失败");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 修改用户信息
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
|
||||
/**
|
||||
* @description: 修改用户信息
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:38
|
||||
*/
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public Result<Boolean> update(@RequestBody AuthUserDTO authUserDTO){
|
||||
public Result<Boolean> update(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.update.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
@@ -73,20 +75,21 @@ public class UserController {
|
||||
return Result.fail("更新用户信息失败");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @description: 用户启用/禁用
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
|
||||
/**
|
||||
* @description: 用户启用/禁用
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:56
|
||||
*/
|
||||
*/
|
||||
@PostMapping("changeStatus")
|
||||
public Result<Boolean> changeStatus(@RequestBody AuthUserDTO authUserDTO){
|
||||
public Result<Boolean> changeStatus(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.changeStatus.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(authUserDTO.getStatus(),"用户名状态不能为空");
|
||||
Preconditions.checkNotNull(authUserDTO.getStatus(), "用户名状态不能为空");
|
||||
AuthUserBO authUserBO = AuthUserDTOConverter.INSTANCE.convertDTOToBO(authUserDTO);
|
||||
return Result.ok(authUserDomainService.update(authUserBO));
|
||||
} catch (Exception e) {
|
||||
@@ -96,15 +99,15 @@ public class UserController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @description: 删除用户
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<java.lang.Boolean>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/19 14:50
|
||||
*/
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
public Result<Boolean> delete(@RequestBody AuthUserDTO authUserDTO){
|
||||
public Result<Boolean> delete(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.update.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
@@ -134,10 +137,54 @@ public class UserController {
|
||||
return "当前会话是否登录:" + StpUtil.isLogin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取用户信息
|
||||
* @param: [authUserDTO]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<com.landaiqing.auth.application.dto.AuthUserDTO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/26 18:54
|
||||
*/
|
||||
@RequestMapping("getUserInfo")
|
||||
public Result<AuthUserDTO> getUserInfo(@RequestBody AuthUserDTO authUserDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("UserController.getUserInfo.dto:{}", JSON.toJSONString(authUserDTO));
|
||||
}
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getUserName()), "用户名不能为空");
|
||||
AuthUserBO authUserBO = AuthUserDTOConverter.INSTANCE.convertDTOToBO(authUserDTO);
|
||||
AuthUserBO userInfo = authUserDomainService.getUserInfo(authUserBO);
|
||||
AuthUserDTO authUserDTO1 = AuthUserDTOConverter.INSTANCE.convertBOToDTO(userInfo);
|
||||
return Result.ok(authUserDTO1);
|
||||
} catch (Exception e) {
|
||||
log.error("UserController.getUserInfo.error:{}", e.getMessage(), e);
|
||||
return Result.fail("获取用户信息失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 用户退出
|
||||
* @param: [userName]
|
||||
* @return: com.landaiqing.auth.common.entity.Result<com.landaiqing.auth.application.dto.AuthUserDTO>
|
||||
* @author landaiqing
|
||||
* @date: 2024/2/26 19:08
|
||||
*/
|
||||
@RequestMapping("logout")
|
||||
public Result logout(@RequestParam String userName) {
|
||||
try {
|
||||
|
||||
log.info("UserController.logout.dto:{}", userName);
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(userName), "用户名不能为空");
|
||||
StpUtil.logout(userName);
|
||||
return Result.ok();
|
||||
} catch (Exception e) {
|
||||
log.error("UserController.logout.error:{}", e.getMessage(), e);
|
||||
return Result.fail("用户登出失败");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUserInfo(@RequestBody AuthUserDTO authUserDTO) {
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getUserName()),"用户名不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getEmail()),"邮箱不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getPassword()),"密码不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getUserName()), "用户名不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getEmail()), "邮箱不能为空");
|
||||
Preconditions.checkArgument(!StringUtils.isBlank(authUserDTO.getPassword()), "密码不能为空");
|
||||
}
|
||||
}
|
||||
|
@@ -24,5 +24,7 @@ public interface AuthUserDomainService {
|
||||
Object delete(AuthUserBO authUserBO);
|
||||
|
||||
Object doLogin(String validCode);
|
||||
|
||||
AuthUserBO getUserInfo(AuthUserBO authUserBO);
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
@@ -135,4 +136,17 @@ public class AuthUserDomainServiceImpl implements AuthUserDomainService {
|
||||
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
|
||||
return tokenInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthUserBO getUserInfo(AuthUserBO authUserBO) {
|
||||
AuthUser authUser = new AuthUser();
|
||||
authUser.setUserName(authUserBO.getUserName());
|
||||
List<AuthUser> userList = authUserService.queryByCondition(authUser);
|
||||
if (CollectionUtils.isEmpty(userList)) {
|
||||
return new AuthUserBO();
|
||||
}
|
||||
AuthUser user = userList.get(0);
|
||||
AuthUserBO authUserBO1 = AuthUserBOConverter.INSTANCE.convertEntityToBO(user);
|
||||
return authUserBO1;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user