用户管理完善
This commit is contained in:
@@ -0,0 +1,43 @@
|
|||||||
|
package com.dc.dc_project.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.dc.dc_project.common.ResponseResult;
|
||||||
|
import com.dc.dc_project.model.dto.user.UpdateUserPasswordDto;
|
||||||
|
import com.dc.dc_project.model.dto.user.UserInfoUpdateDto;
|
||||||
|
import com.dc.dc_project.model.pojo.RecordResult;
|
||||||
|
import com.dc.dc_project.model.pojo.User;
|
||||||
|
import com.dc.dc_project.service.UserService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/user")
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
@PostMapping("/getUserInfo")
|
||||||
|
ResponseResult getUserInfo() {
|
||||||
|
return userService.getUserInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save")
|
||||||
|
ResponseResult save(@RequestBody User user) {
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/updateInfo")
|
||||||
|
ResponseResult updateInfo(@RequestBody UserInfoUpdateDto userInfoUpdateDto) {
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/updatePassword")
|
||||||
|
ResponseResult updatePassword(@RequestBody UpdateUserPasswordDto updateUserPasswordDto) {
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.dc.dc_project.model.dto.user;
|
||||||
|
|
||||||
|
public class UpdateUserPasswordDto {
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.dc.dc_project.model.dto.user;
|
||||||
|
|
||||||
|
public class UserInfoUpdateDto {
|
||||||
|
}
|
||||||
@@ -34,10 +34,10 @@ public class Personnel {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 职务/岗位(如 检测员、试验室主任)
|
* 头像
|
||||||
*/
|
*/
|
||||||
@TableField(value = "position")
|
@TableField(value = "avatar")
|
||||||
private String position;
|
private String avatar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系电话
|
* 联系电话
|
||||||
|
|||||||
@@ -33,17 +33,7 @@ public class User {
|
|||||||
@TableField(value = "password")
|
@TableField(value = "password")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
|
||||||
* 真实姓名
|
|
||||||
*/
|
|
||||||
@TableField(value = "real_name")
|
|
||||||
private String realName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 性别(0=未知,1=男,2=女)
|
|
||||||
*/
|
|
||||||
@TableField(value = "gender")
|
|
||||||
private Integer gender;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系电话
|
* 联系电话
|
||||||
@@ -51,17 +41,6 @@ public class User {
|
|||||||
@TableField(value = "phone")
|
@TableField(value = "phone")
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
/**
|
|
||||||
* 邮箱地址
|
|
||||||
*/
|
|
||||||
@TableField(value = "email")
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 所属组织ID
|
|
||||||
*/
|
|
||||||
@TableField(value = "org_id")
|
|
||||||
private Long orgId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账户状态(0=停用,1=启用)
|
* 账户状态(0=停用,1=启用)
|
||||||
@@ -99,76 +78,5 @@ public class User {
|
|||||||
@TableField(value = "is_deleted")
|
@TableField(value = "is_deleted")
|
||||||
private Integer isDeleted;
|
private Integer isDeleted;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object that) {
|
|
||||||
if (this == that) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (that == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != that.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
User other = (User) that;
|
|
||||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
|
||||||
&& (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
|
|
||||||
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
|
|
||||||
&& (this.getRealName() == null ? other.getRealName() == null : this.getRealName().equals(other.getRealName()))
|
|
||||||
&& (this.getGender() == null ? other.getGender() == null : this.getGender().equals(other.getGender()))
|
|
||||||
&& (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone()))
|
|
||||||
&& (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail()))
|
|
||||||
&& (this.getOrgId() == null ? other.getOrgId() == null : this.getOrgId().equals(other.getOrgId()))
|
|
||||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
|
|
||||||
&& (this.getLastLoginTime() == null ? other.getLastLoginTime() == null : this.getLastLoginTime().equals(other.getLastLoginTime()))
|
|
||||||
&& (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark()))
|
|
||||||
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
|
|
||||||
&& (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
|
|
||||||
&& (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
|
||||||
result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
|
|
||||||
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
|
|
||||||
result = prime * result + ((getRealName() == null) ? 0 : getRealName().hashCode());
|
|
||||||
result = prime * result + ((getGender() == null) ? 0 : getGender().hashCode());
|
|
||||||
result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode());
|
|
||||||
result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
|
|
||||||
result = prime * result + ((getOrgId() == null) ? 0 : getOrgId().hashCode());
|
|
||||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
|
||||||
result = prime * result + ((getLastLoginTime() == null) ? 0 : getLastLoginTime().hashCode());
|
|
||||||
result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode());
|
|
||||||
result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
|
||||||
result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
|
|
||||||
result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(getClass().getSimpleName());
|
|
||||||
sb.append(" [");
|
|
||||||
sb.append("Hash = ").append(hashCode());
|
|
||||||
sb.append(", id=").append(id);
|
|
||||||
sb.append(", username=").append(username);
|
|
||||||
sb.append(", password=").append(password);
|
|
||||||
sb.append(", realName=").append(realName);
|
|
||||||
sb.append(", gender=").append(gender);
|
|
||||||
sb.append(", phone=").append(phone);
|
|
||||||
sb.append(", email=").append(email);
|
|
||||||
sb.append(", orgId=").append(orgId);
|
|
||||||
sb.append(", status=").append(status);
|
|
||||||
sb.append(", lastLoginTime=").append(lastLoginTime);
|
|
||||||
sb.append(", remark=").append(remark);
|
|
||||||
sb.append(", createdAt=").append(createdAt);
|
|
||||||
sb.append(", updatedAt=").append(updatedAt);
|
|
||||||
sb.append(", isDeleted=").append(isDeleted);
|
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
4
src/main/java/com/dc/dc_project/model/vo/OrgVo.java
Normal file
4
src/main/java/com/dc/dc_project/model/vo/OrgVo.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package com.dc.dc_project.model.vo;
|
||||||
|
|
||||||
|
public class OrgVo {
|
||||||
|
}
|
||||||
@@ -40,11 +40,6 @@ public class PersonnelVo {
|
|||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
|
||||||
* 职务/岗位(如 检测员、试验室主任)
|
|
||||||
*/
|
|
||||||
private String position;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系电话
|
* 联系电话
|
||||||
*/
|
*/
|
||||||
@@ -99,7 +94,6 @@ public class PersonnelVo {
|
|||||||
personnelVo.setId(personnel.getId());
|
personnelVo.setId(personnel.getId());
|
||||||
personnelVo.setUserId(personnel.getUserId());
|
personnelVo.setUserId(personnel.getUserId());
|
||||||
personnelVo.setName(personnel.getName());
|
personnelVo.setName(personnel.getName());
|
||||||
personnelVo.setPosition(personnel.getPosition());
|
|
||||||
personnelVo.setContactPhone(personnel.getContactPhone());
|
personnelVo.setContactPhone(personnel.getContactPhone());
|
||||||
personnelVo.setEmail(personnel.getEmail());
|
personnelVo.setEmail(personnel.getEmail());
|
||||||
personnelVo.setMainResponsibility(personnel.getMainResponsibility());
|
personnelVo.setMainResponsibility(personnel.getMainResponsibility());
|
||||||
|
|||||||
34
src/main/java/com/dc/dc_project/model/vo/UserInfoVo.java
Normal file
34
src/main/java/com/dc/dc_project/model/vo/UserInfoVo.java
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package com.dc.dc_project.model.vo;
|
||||||
|
|
||||||
|
import com.dc.dc_project.model.pojo.Role;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class UserInfoVo {
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private Long personId;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
private String mainResponsibility;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private List<Role> roles;
|
||||||
|
|
||||||
|
private OrgVo orgVo;
|
||||||
|
}
|
||||||
@@ -63,22 +63,4 @@ public class UserVo {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色列表
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static UserVo fromUser(User user) {
|
|
||||||
UserVo userVo = new UserVo();
|
|
||||||
userVo.setId(user.getId());
|
|
||||||
userVo.setUsername(user.getUsername());
|
|
||||||
userVo.setRealName(user.getRealName());
|
|
||||||
userVo.setGender(user.getGender());
|
|
||||||
userVo.setPhone(user.getPhone());
|
|
||||||
userVo.setEmail(user.getEmail());
|
|
||||||
userVo.setOrgId(user.getOrgId());
|
|
||||||
userVo.setStatus(user.getStatus());
|
|
||||||
userVo.setLastLoginTime(user.getLastLoginTime());
|
|
||||||
userVo.setRemark(user.getRemark());
|
|
||||||
return userVo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.dc.dc_project.service;
|
|||||||
|
|
||||||
import com.dc.dc_project.common.ResponseResult;
|
import com.dc.dc_project.common.ResponseResult;
|
||||||
import com.dc.dc_project.model.dto.user.LoginDto;
|
import com.dc.dc_project.model.dto.user.LoginDto;
|
||||||
|
import com.dc.dc_project.model.pojo.RecordResult;
|
||||||
import com.dc.dc_project.model.pojo.User;
|
import com.dc.dc_project.model.pojo.User;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -21,4 +22,10 @@ public interface UserService extends IService<User> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ResponseResult login(LoginDto loginDto);
|
ResponseResult login(LoginDto loginDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ResponseResult getUserInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ import com.dc.dc_project.mapper.PersonnelMapper;
|
|||||||
import com.dc.dc_project.mapper.RoleMapper;
|
import com.dc.dc_project.mapper.RoleMapper;
|
||||||
import com.dc.dc_project.model.dto.user.LoginDto;
|
import com.dc.dc_project.model.dto.user.LoginDto;
|
||||||
import com.dc.dc_project.model.pojo.Personnel;
|
import com.dc.dc_project.model.pojo.Personnel;
|
||||||
|
import com.dc.dc_project.model.pojo.RecordResult;
|
||||||
|
import com.dc.dc_project.model.pojo.Role;
|
||||||
import com.dc.dc_project.model.pojo.User;
|
import com.dc.dc_project.model.pojo.User;
|
||||||
import com.dc.dc_project.model.vo.PersonnelVo;
|
import com.dc.dc_project.model.vo.PersonnelVo;
|
||||||
|
import com.dc.dc_project.model.vo.UserInfoVo;
|
||||||
import com.dc.dc_project.service.PersonnelService;
|
import com.dc.dc_project.service.PersonnelService;
|
||||||
import com.dc.dc_project.service.UserService;
|
import com.dc.dc_project.service.UserService;
|
||||||
import com.dc.dc_project.mapper.UserMapper;
|
import com.dc.dc_project.mapper.UserMapper;
|
||||||
@@ -20,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.dc.dc_project.model.vo.PersonnelVo.toVo;
|
import static com.dc.dc_project.model.vo.PersonnelVo.toVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,6 +77,22 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
|||||||
return ResponseResult.error(ResultCode.ERROR_PASSWORD);
|
return ResponseResult.error(ResultCode.ERROR_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseResult getUserInfo() {
|
||||||
|
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<User>()
|
||||||
|
.eq(User::getId, StpUtil.getLoginIdAsLong())
|
||||||
|
.eq(User::getIsDeleted, 0)
|
||||||
|
.eq(User::getStatus, 1);
|
||||||
|
User user = baseMapper.selectOne(queryWrapper);
|
||||||
|
Personnel personnel = personnelMapper.selectOne(new LambdaQueryWrapper<Personnel>().eq(Personnel::getUserId, user.getId()));
|
||||||
|
List<Role> roles = roleMapper.getRolesByUserId(user.getId());
|
||||||
|
|
||||||
|
UserInfoVo userInfoVo = new UserInfoVo();
|
||||||
|
|
||||||
|
return ResponseResult.success(userInfoVo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user