|
|
@@ -6,14 +6,11 @@ import com.tuoheng.admin.conver.UserConverMapper; |
|
|
|
import com.tuoheng.admin.entity.Dept; |
|
|
|
import com.tuoheng.admin.entity.Role; |
|
|
|
import com.tuoheng.admin.entity.User; |
|
|
|
import com.tuoheng.admin.enums.code.user.QueryUserInfoByIdCodeEnum; |
|
|
|
import com.tuoheng.admin.mapper.DeptMapper; |
|
|
|
import com.tuoheng.admin.mapper.RoleMapper; |
|
|
|
import com.tuoheng.admin.mapper.UserMapper; |
|
|
|
import com.tuoheng.admin.utils.CurrentUserUtil; |
|
|
|
import com.tuoheng.admin.vo.user.UserInfoVo; |
|
|
|
import com.tuoheng.common.core.utils.JsonResult; |
|
|
|
import com.tuoheng.common.core.utils.StringUtils; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@@ -29,9 +26,6 @@ import org.springframework.stereotype.Service; |
|
|
|
@Service |
|
|
|
public class QueryUserInfoByIdService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DeptMapper deptMapper; |
|
|
|
|
|
|
@@ -43,16 +37,9 @@ public class QueryUserInfoByIdService { |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public JsonResult getUserInfo(String username) { |
|
|
|
public JsonResult getUserInfo() { |
|
|
|
log.info("进入根据用户名查询用户信息业务"); |
|
|
|
JsonResult result = this.check(username); |
|
|
|
if (0 != result.getCode()) { |
|
|
|
log.info("根据用户名查询用户信息业务:校验失败:{}", result.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
User user = (User) result.getData(); |
|
|
|
|
|
|
|
User user = CurrentUserUtil.getUserInfo(); |
|
|
|
UserInfoVo userInfoVo = UserConverMapper.INSTANCE.fromUserToUserInfoVo(user); |
|
|
|
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>() |
|
|
|
.eq(Dept::getId, userInfoVo.getDeptId()) |
|
|
@@ -60,7 +47,6 @@ public class QueryUserInfoByIdService { |
|
|
|
if (ObjectUtil.isNotNull(dept)) { |
|
|
|
userInfoVo.setDeptName(dept.getName()); |
|
|
|
} |
|
|
|
|
|
|
|
Role role = roleMapper.selectOne(new LambdaQueryWrapper<Role>() |
|
|
|
.eq(Role::getId, userInfoVo.getRoleId()) |
|
|
|
.eq(Role::getMark, 1)); |
|
|
@@ -69,29 +55,4 @@ public class QueryUserInfoByIdService { |
|
|
|
} |
|
|
|
return JsonResult.success(userInfoVo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查参数 |
|
|
|
* |
|
|
|
* @param username |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult check(String username) { |
|
|
|
if (StringUtils.isEmpty(username)) { |
|
|
|
return JsonResult.error(QueryUserInfoByIdCodeEnum.USERNAME_ID_IS_NULL.getCode(), QueryUserInfoByIdCodeEnum.USERNAME_ID_IS_NULL.getMsg()); |
|
|
|
} |
|
|
|
User user = userMapper.selectOne(new LambdaQueryWrapper<User>() |
|
|
|
.eq(User::getUsername, username) |
|
|
|
.eq(User::getMark, 1)); |
|
|
|
|
|
|
|
if (ObjectUtil.isNull(user)) { |
|
|
|
return JsonResult.error(QueryUserInfoByIdCodeEnum.USER_IS_NOT_EXIST.getCode(), QueryUserInfoByIdCodeEnum.USER_IS_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
if (!user.getTenantId().equals(CurrentUserUtil.getTenantId())) { |
|
|
|
return JsonResult.error(QueryUserInfoByIdCodeEnum.NON_TENANT_USER.getCode(), QueryUserInfoByIdCodeEnum.NON_TENANT_USER.getMsg()); |
|
|
|
} |
|
|
|
return JsonResult.success(user); |
|
|
|
} |
|
|
|
|
|
|
|
} |