Browse Source

修改根据用户名查询用户信息接口

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
a1ecd4602a
5 changed files with 20 additions and 20 deletions
  1. +4
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/UserController.java
  2. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/QueryUserInfoByIdCodeEnum.java
  3. +2
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/IUserService.java
  4. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/UserServiceImpl.java
  5. +10
    -10
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserInfoByIdService.java

+ 4
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/UserController.java View File

@@ -40,12 +40,12 @@ public class UserController {
/**
* 获取用户详情
*
* @param id 用户ID
* @param username
* @return
*/
@GetMapping("/info/{id}")
public JsonResult getUserInfo(@PathVariable("id") String id) {
return userService.getUserInfo(id);
@GetMapping("/info/{username}")
public JsonResult getUserInfo(@PathVariable("username") String username) {
return userService.getUserInfo(username);
}

/**

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/enums/code/user/QueryUserInfoByIdCodeEnum.java View File

@@ -12,7 +12,7 @@ package com.tuoheng.admin.enums.code.user;
public enum QueryUserInfoByIdCodeEnum {

QUERY_ID_IS_NULL(1100600, "查询失败"),
USER_ID_IS_NULL(1100601, "用户ID为空"),
USERNAME_ID_IS_NULL(1100601, "用户名为空"),
USER_IS_NOT_EXIST(1100602, "用户不存在"),
NON_TENANT_USER(1100603, "当前用户非本租户用户");


+ 2
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/IUserService.java View File

@@ -30,10 +30,10 @@ public interface IUserService {
/**
* 获取用户详情
*
* @param id 用户ID
* @param username
* @return
*/
JsonResult getUserInfo(@PathVariable("id") String id);
JsonResult getUserInfo(String username);

/**
* 添加用户

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/UserServiceImpl.java View File

@@ -75,12 +75,12 @@ public class UserServiceImpl implements IUserService {
/**
* 获取用户详情
*
* @param id 用户ID
* @param username
* @return
*/
@Override
public JsonResult getUserInfo(String id) {
return queryUserInfoByIdService.getUserInfo(id);
public JsonResult getUserInfo(String username) {
return queryUserInfoByIdService.getUserInfo(username);
}

/**

+ 10
- 10
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserInfoByIdService.java View File

@@ -19,7 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 根据用户Id查询用户信息业务层处理
* 根据用户查询用户信息业务层处理
*
* @author wanjing
* @team tuoheng
@@ -43,11 +43,11 @@ public class QueryUserInfoByIdService {
*
* @return
*/
public JsonResult getUserInfo(String id) {
log.info("进入根据用户Id查询用户信息业务");
JsonResult result = this.check(id);
public JsonResult getUserInfo(String username) {
log.info("进入根据用户查询用户信息业务");
JsonResult result = this.check(username);
if (0 != result.getCode()) {
log.info("根据用户Id查询用户信息业务:校验失败:{}", result.getMsg());
log.info("根据用户查询用户信息业务:校验失败:{}", result.getMsg());
return result;
}

@@ -73,15 +73,15 @@ public class QueryUserInfoByIdService {
/**
* 检查参数
*
* @param id
* @param username
* @return
*/
private JsonResult check(String id) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(QueryUserInfoByIdCodeEnum.USER_ID_IS_NULL.getCode(), QueryUserInfoByIdCodeEnum.USER_ID_IS_NULL.getMsg());
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::getId, id)
.eq(User::getUsername, username)
.eq(User::getMark, 1));

if (ObjectUtil.isNull(user)) {

Loading…
Cancel
Save