Parcourir la source

提交根据id查看用户信息接口代码

tags/v1.0.0^2
wanjing il y a 1 an
Parent
révision
1cc32a0941
6 fichiers modifiés avec 242 ajouts et 7 suppressions
  1. +3
    -3
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/UserController.java
  2. +3
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/UserConverMapper.java
  3. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/IUserService.java
  4. +1
    -1
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/UserServiceImpl.java
  5. +27
    -2
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserInfoByIdService.java
  6. +207
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/UserInfoVo.java

+ 3
- 3
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/UserController.java Voir le fichier

@@ -43,9 +43,9 @@ public class UserController {
* @param id 用户ID
* @return
*/
@GetMapping("/detail/{id}")
public JsonResult detail(@PathVariable("id") String id) {
return userService.detail(id);
@GetMapping("/info/{id}")
public JsonResult getUserInfo(@PathVariable("id") String id) {
return userService.getUserInfo(id);
}

/**

+ 3
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/conver/UserConverMapper.java Voir le fichier

@@ -1,6 +1,7 @@
package com.tuoheng.admin.conver;

import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.vo.UserInfoVo;
import com.tuoheng.admin.vo.UserPageListVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@@ -12,6 +13,8 @@ public interface UserConverMapper {

UserConverMapper INSTANCE = Mappers.getMapper(UserConverMapper.class);

UserInfoVo fromUserToUserInfoVo(User user);

List<UserPageListVo> fromUserListToUserPageVoList(List<User> userList);

}

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/IUserService.java Voir le fichier

@@ -33,7 +33,7 @@ public interface IUserService {
* @param id 用户ID
* @return
*/
JsonResult detail(@PathVariable("id") String id);
JsonResult getUserInfo(@PathVariable("id") String id);

/**
* 添加用户

+ 1
- 1
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/UserServiceImpl.java Voir le fichier

@@ -75,7 +75,7 @@ public class UserServiceImpl implements IUserService {
* @return
*/
@Override
public JsonResult detail(String id) {
public JsonResult getUserInfo(String id) {
return queryUserInfoByIdService.getUserInfo(id);
}


+ 27
- 2
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/user/query/QueryUserInfoByIdService.java Voir le fichier

@@ -2,10 +2,16 @@ package com.tuoheng.admin.service.user.query;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.UserInfoVo;
import com.tuoheng.common.core.utils.JsonResult;
import com.tuoheng.common.core.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
@@ -26,6 +32,12 @@ public class QueryUserInfoByIdService {
@Autowired
private UserMapper userMapper;

@Autowired
private DeptMapper deptMapper;

@Autowired
private RoleMapper roleMapper;

/**
* 获取部门树形列表
*
@@ -41,7 +53,21 @@ public class QueryUserInfoByIdService {

User user = (User) result.getData();

return JsonResult.success(user);
UserInfoVo userInfoVo = UserConverMapper.INSTANCE.fromUserToUserInfoVo(user);
Dept dept = deptMapper.selectOne(new LambdaQueryWrapper<Dept>()
.eq(Dept::getId, userInfoVo.getDeptId())
.eq(Dept::getMark, 1));
if (ObjectUtil.isNotNull(dept)) {
userInfoVo.setDeptName(dept.getName());
}

Role role = roleMapper.selectOne(new LambdaQueryWrapper<Role>()
.eq(Role::getId, userInfoVo.getRoleId())
.eq(Role::getMark, 1));
if (ObjectUtil.isNotNull(role)) {
userInfoVo.setRoleName(role.getRoleName());
}
return JsonResult.success(userInfoVo);
}

/**
@@ -65,7 +91,6 @@ public class QueryUserInfoByIdService {
if (!user.getTenantId().equals(CurrentUserUtil.getTenantId())) {
return JsonResult.error(QueryUserInfoByIdCodeEnum.NON_TENANT_USER.getCode(), QueryUserInfoByIdCodeEnum.NON_TENANT_USER.getMsg());
}

return JsonResult.success(user);
}


+ 207
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/vo/UserInfoVo.java Voir le fichier

@@ -0,0 +1,207 @@
package com.tuoheng.admin.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
* 返回用户分页列表视图Vo
*
* @author wanjing
* @team tuoheng
* @date 2022-12-20
*/
@Data
public class UserInfoVo {

/**
* 用户ID
*/
private String id;

/**
* 用户编号
*/
private String code;

/**
* 真实姓名
*/
private String realname;

/**
* 昵称
*/
private String nickname;

/**
* 性别:1男 2女 3保密
*/
private Integer gender;

/**
* 头像
*/
private String avatar;

/**
* 手机号码
*/
private String mobile;

/**
* 邮箱地址
*/
private String email;

/**
* 出生日期
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date birthday;

/**
* 部门ID
*/
private String deptId;

/**
* 部门名称
*/
private String deptName;

/**
* 省份编码
*/
private String provinceCode;

/**
* 城市编码
*/
private String cityCode;

/**
* 区县编码
*/
private String districtCode;

/**
* 街道编码
*/
private String streetCode;

/**
* 详细地址
*/
private String address;

/**
* 所属城市
*/
private String cityName;

/**
* 登录用户名
*/
private String username;

/**
* 用户类型:1管理员
*/
private Integer type;

/**
* 驾照类型:1飞行执照 2飞行许可证
*/
private Integer driverType;

/**
* 驾照编号
*/
private String driverCode;

/**
* 个人简介
*/
private String intro;

/**
* 状态:1正常 2禁用
*/
private Integer status;

/**
* 备注
*/
private String note;

/**
* 显示顺序
*/
private Integer sort;

/**
* 登录次数
*/
private Integer loginNum;

/**
* 最近登录IP
*/
private String loginIp;

/**
* 最近登录时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date loginTime;

/**
* 添加人
*/
private String createUser;

/**
* 创建时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;

/**
* 更新人
*/
private String updateUser;

/**
* 更新时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;

/**
* 有效标识
*/
private Integer mark;

/**
* 角色id
*/
private Integer roleId;

/**
* 角色名称
*/
private String roleName;

/**
* 标识id 小程序,pc
*/
private String clientId;

}

Chargement…
Annuler
Enregistrer