补丁
This commit is contained in:
parent
43416fee10
commit
238c1e1718
@ -1,14 +1,13 @@
|
||||
package com.jsl.oa.controllers;
|
||||
|
||||
import com.jsl.oa.model.voData.RoleAddUser;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUser;
|
||||
import com.jsl.oa.model.voData.RoleAddUserVO;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUserVO;
|
||||
import com.jsl.oa.services.RoleService;
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
import com.jsl.oa.utils.ErrorCode;
|
||||
import com.jsl.oa.utils.Processing;
|
||||
import com.jsl.oa.utils.ResultUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@ -24,31 +23,31 @@ public class RoleController {
|
||||
|
||||
/**
|
||||
* 用户权限授予
|
||||
* @param roleAddUser
|
||||
* @param roleAddUserVO
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("role/user/add")
|
||||
public BaseResponse roleAddUser(@RequestBody @Validated RoleAddUser roleAddUser, BindingResult bindingResult){
|
||||
public BaseResponse roleAddUser(@RequestBody @Validated RoleAddUserVO roleAddUserVO, BindingResult bindingResult){
|
||||
// 判断是否有参数错误
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult));
|
||||
}
|
||||
return roleService.roleAddUser(roleAddUser);
|
||||
return roleService.roleAddUser(roleAddUserVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户权限删除
|
||||
* @param roleRemoveUser
|
||||
* @param roleRemoveUserVO
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("role/user/remove")
|
||||
public BaseResponse roleRemoveUser(@RequestBody @Validated RoleRemoveUser roleRemoveUser, BindingResult bindingResult){
|
||||
public BaseResponse roleRemoveUser(@RequestBody @Validated RoleRemoveUserVO roleRemoveUserVO, BindingResult bindingResult){
|
||||
// 判断是否有参数错误
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult));
|
||||
}
|
||||
return roleService.roleRemoveUser(roleRemoveUser);
|
||||
return roleService.roleRemoveUser(roleRemoveUserVO);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.jsl.oa.controllers;
|
||||
|
||||
import com.jsl.oa.model.voData.*;
|
||||
import com.jsl.oa.services.AuthService;
|
||||
import com.jsl.oa.services.UserService;
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
import com.jsl.oa.utils.ErrorCode;
|
||||
@ -12,8 +11,6 @@ import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
@ -49,13 +46,19 @@ public class UserController {
|
||||
return userService.userLock(userLockVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户编辑自己的信息
|
||||
* @param userEditProfileVO
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/user/profile/edit")
|
||||
public BaseResponse userEditProfile(@RequestBody @Validated UserEditProfile userEditProfile, BindingResult bindingResult){
|
||||
public BaseResponse userEditProfile(@RequestBody @Validated UserEditProfileVO userEditProfileVO, BindingResult bindingResult){
|
||||
// 判断是否有参数错误
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultUtil.error(ErrorCode.REQUEST_BODY_ERROR, Processing.getValidatedErrorList(bindingResult));
|
||||
}
|
||||
return userService.userEditProfile(userEditProfile);
|
||||
return userService.userEditProfile(userEditProfileVO);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.jsl.oa.dao;
|
||||
|
||||
import com.jsl.oa.mapper.RoleMapper;
|
||||
import com.jsl.oa.model.voData.RoleAddUser;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUser;
|
||||
import com.jsl.oa.model.voData.RoleAddUserVO;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUserVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -11,11 +11,11 @@ import org.springframework.stereotype.Component;
|
||||
public class RoleDAO {
|
||||
private final RoleMapper roleMapper;
|
||||
|
||||
public void roleAddUser(RoleAddUser roleAddUser) {
|
||||
roleMapper.roleAddUser(roleAddUser);
|
||||
public void roleAddUser(RoleAddUserVO roleAddUserVO) {
|
||||
roleMapper.roleAddUser(roleAddUserVO);
|
||||
}
|
||||
|
||||
public void roleRemoveUser(RoleRemoveUser roleRemoveUser) {
|
||||
roleMapper.roleRemoveUser(roleRemoveUser);
|
||||
public void roleRemoveUser(RoleRemoveUserVO roleRemoveUserVO) {
|
||||
roleMapper.roleRemoveUser(roleRemoveUserVO);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.jsl.oa.dao;
|
||||
import com.jsl.oa.mapper.UserMapper;
|
||||
import com.jsl.oa.model.doData.UserDO;
|
||||
import com.jsl.oa.model.voData.UserDeleteVO;
|
||||
import com.jsl.oa.model.voData.UserEditProfile;
|
||||
import com.jsl.oa.model.voData.UserEditProfileVO;
|
||||
import com.jsl.oa.model.voData.UserLockVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -60,7 +60,7 @@ public class UserDAO {
|
||||
userMapper.userLock(userLockVO);
|
||||
}
|
||||
|
||||
public void userEditProfile(UserEditProfile userEditProfile) {
|
||||
userMapper.userEditProfile(userEditProfile);
|
||||
public void userEditProfile(UserEditProfileVO userEditProfileVO) {
|
||||
userMapper.userEditProfile(userEditProfileVO);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.jsl.oa.mapper;
|
||||
|
||||
import com.jsl.oa.model.voData.RoleAddUser;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUser;
|
||||
import com.jsl.oa.model.voData.RoleAddUserVO;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUserVO;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -10,8 +10,8 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface RoleMapper {
|
||||
|
||||
@Insert("insert into organize_oa.oa_role_user (uid, rid) VALUE (#{uid},#{rid})")
|
||||
void roleAddUser(RoleAddUser roleAddUser);
|
||||
void roleAddUser(RoleAddUserVO roleAddUserVO);
|
||||
|
||||
@Delete("delete from organize_oa.oa_role_user where uid=#{uid}")
|
||||
void roleRemoveUser(RoleRemoveUser roleRemoveUser);
|
||||
void roleRemoveUser(RoleRemoveUserVO roleRemoveUserVO);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.jsl.oa.mapper;
|
||||
|
||||
import com.jsl.oa.model.doData.UserDO;
|
||||
import com.jsl.oa.model.voData.UserDeleteVO;
|
||||
import com.jsl.oa.model.voData.UserEditProfile;
|
||||
import com.jsl.oa.model.voData.UserEditProfileVO;
|
||||
import com.jsl.oa.model.voData.UserLockVO;
|
||||
import com.jsl.oa.model.voData.UserLoginVO;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
@ -24,16 +24,10 @@ public interface UserMapper {
|
||||
"VALUES (#{jobId}, #{username}, #{password}, #{address}, #{phone}, #{email}, #{age}, #{sex})")
|
||||
boolean insertUser(UserDO userDO);
|
||||
|
||||
@Select("SELECT password FROM organize_oa.oa_user WHERE job_id = #{jobId}")
|
||||
String loginPassword(UserLoginVO userLoginVO);
|
||||
|
||||
@Select("SELECT * FROM organize_oa.oa_user WHERE job_id = #{jobId}")
|
||||
UserDO login(UserLoginVO userLoginVO);
|
||||
|
||||
@Update("UPDATE organize_oa.oa_user SET enabled = 0 WHERE id = #{id} ")
|
||||
@Update("UPDATE organize_oa.oa_user SET enabled = 0 ,updated_at = CURRENT_TIMESTAMP WHERE id = #{id} ")
|
||||
void userDelete(UserDeleteVO userDeleteVO);
|
||||
|
||||
@Update("UPDATE organize_oa.oa_user SET account_no_locked = 1 WHERE id = #{id} ")
|
||||
@Update("UPDATE organize_oa.oa_user SET account_no_locked = 1 ,updated_at = CURRENT_TIMESTAMP WHERE id = #{id} ")
|
||||
void userLock(UserLockVO userLockVO);
|
||||
|
||||
@Select("SELECT * FROM organize_oa.oa_user WHERE id = #{id}")
|
||||
@ -48,5 +42,5 @@ public interface UserMapper {
|
||||
@Select("SELECT * FROM organize_oa.oa_user WHERE job_id = #{jobId}")
|
||||
UserDO getUserByJobId(String user);
|
||||
|
||||
void userEditProfile(UserEditProfile userEditProfile);
|
||||
void userEditProfile(UserEditProfileVO userEditProfileVO);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import lombok.Getter;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Getter
|
||||
public class RoleAddUser {
|
||||
public class RoleAddUserVO {
|
||||
@NotNull(message = "角色id不能为空")
|
||||
private Long uid;
|
||||
@NotNull(message = "角色id不能为空")
|
@ -5,7 +5,7 @@ import lombok.Getter;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Getter
|
||||
public class RoleRemoveUser {
|
||||
public class RoleRemoveUserVO {
|
||||
@NotNull(message = "用户id不能为空")
|
||||
private Long uid;
|
||||
}
|
@ -5,10 +5,11 @@ import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class UserEditProfile {
|
||||
public class UserEditProfileVO {
|
||||
private Long id;
|
||||
@Pattern(regexp = "^[0-9A-Za-z_]{3,40}$", message = "用户名只能为字母、数字或下划线")
|
||||
private String username;
|
@ -1,11 +1,11 @@
|
||||
package com.jsl.oa.services;
|
||||
|
||||
import com.jsl.oa.model.voData.RoleAddUser;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUser;
|
||||
import com.jsl.oa.model.voData.RoleAddUserVO;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUserVO;
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
|
||||
public interface RoleService {
|
||||
BaseResponse roleAddUser(RoleAddUser roleAddUser);
|
||||
BaseResponse roleAddUser(RoleAddUserVO roleAddUserVO);
|
||||
|
||||
BaseResponse roleRemoveUser(RoleRemoveUser roleRemoveUser);
|
||||
BaseResponse roleRemoveUser(RoleRemoveUserVO roleRemoveUserVO);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.jsl.oa.services;
|
||||
|
||||
import com.jsl.oa.model.doData.UserDO;
|
||||
import com.jsl.oa.model.voData.UserDeleteVO;
|
||||
import com.jsl.oa.model.voData.UserEditProfile;
|
||||
import com.jsl.oa.model.voData.UserEditProfileVO;
|
||||
import com.jsl.oa.model.voData.UserLockVO;
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
|
||||
@ -41,5 +41,5 @@ public interface UserService {
|
||||
*/
|
||||
BaseResponse userLock(UserLockVO userLockVO);
|
||||
|
||||
BaseResponse userEditProfile(UserEditProfile userEditProfile);
|
||||
BaseResponse userEditProfile(UserEditProfileVO userEditProfileVO);
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package com.jsl.oa.services.impl;
|
||||
|
||||
import com.jsl.oa.dao.RoleDAO;
|
||||
import com.jsl.oa.dao.UserDAO;
|
||||
import com.jsl.oa.model.voData.RoleAddUser;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUser;
|
||||
import com.jsl.oa.model.voData.RoleAddUserVO;
|
||||
import com.jsl.oa.model.voData.RoleRemoveUserVO;
|
||||
import com.jsl.oa.services.RoleService;
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
import com.jsl.oa.utils.ErrorCode;
|
||||
@ -19,17 +19,17 @@ public class RoleServiceImpl implements RoleService {
|
||||
private final UserDAO userDAO;
|
||||
|
||||
@Override
|
||||
public BaseResponse roleAddUser(RoleAddUser roleAddUser) {
|
||||
if(userDAO.isExistUser(roleAddUser.getUid())) {
|
||||
roleDAO.roleAddUser(roleAddUser);
|
||||
public BaseResponse roleAddUser(RoleAddUserVO roleAddUserVO) {
|
||||
if(userDAO.isExistUser(roleAddUserVO.getUid())) {
|
||||
roleDAO.roleAddUser(roleAddUserVO);
|
||||
return ResultUtil.success();
|
||||
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse roleRemoveUser(RoleRemoveUser roleRemoveUser) {
|
||||
if(userDAO.isExistUser(roleRemoveUser.getUid())) {
|
||||
roleDAO.roleRemoveUser(roleRemoveUser);
|
||||
public BaseResponse roleRemoveUser(RoleRemoveUserVO roleRemoveUserVO) {
|
||||
if(userDAO.isExistUser(roleRemoveUserVO.getUid())) {
|
||||
roleDAO.roleRemoveUser(roleRemoveUserVO);
|
||||
return ResultUtil.success();
|
||||
} else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.jsl.oa.services.impl;
|
||||
import com.jsl.oa.dao.UserDAO;
|
||||
import com.jsl.oa.model.doData.UserDO;
|
||||
import com.jsl.oa.model.voData.UserDeleteVO;
|
||||
import com.jsl.oa.model.voData.UserEditProfile;
|
||||
import com.jsl.oa.model.voData.UserEditProfileVO;
|
||||
import com.jsl.oa.model.voData.UserLockVO;
|
||||
import com.jsl.oa.services.UserService;
|
||||
import com.jsl.oa.utils.BaseResponse;
|
||||
@ -14,6 +14,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.mindrot.jbcrypt.BCrypt;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class UserServiceImpl implements UserService {
|
||||
@ -44,12 +46,12 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseResponse userEditProfile(@NotNull UserEditProfile userEditProfile) {
|
||||
if(userDAO.isExistUser(userEditProfile.getId())) {
|
||||
if(userEditProfile.getPassword()!=null){
|
||||
userEditProfile.setPassword(BCrypt.hashpw(userEditProfile.getPassword(), BCrypt.gensalt()));
|
||||
public BaseResponse userEditProfile(@NotNull UserEditProfileVO userEditProfileVO) {
|
||||
if(userDAO.isExistUser(userEditProfileVO.getId())) {
|
||||
if(userEditProfileVO.getPassword()!=null) {
|
||||
userEditProfileVO.setPassword(BCrypt.hashpw(userEditProfileVO.getPassword(), BCrypt.gensalt()));
|
||||
}
|
||||
userDAO.userEditProfile(userEditProfile);
|
||||
userDAO.userEditProfile(userEditProfileVO);
|
||||
return ResultUtil.success("修改成功");
|
||||
}else return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
|
||||
}
|
||||
|
@ -14,3 +14,6 @@ mybatis:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -38,8 +38,9 @@
|
||||
nickname = #{nickname},
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
description = #{description}
|
||||
description = #{description},
|
||||
</if>
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
Loading…
x
Reference in New Issue
Block a user