deat: 用户删除功能完成
This commit is contained in:
parent
19300abbd4
commit
223bbc904c
@ -97,8 +97,22 @@ public class AuthController {
|
|||||||
public ResponseEntity getRoleAll() {
|
public ResponseEntity getRoleAll() {
|
||||||
return ResponseEntity.ok(authService.getRoleAll());
|
return ResponseEntity.ok(authService.getRoleAll());
|
||||||
}
|
}
|
||||||
|
@Operation(
|
||||||
|
summary = "角色更新",
|
||||||
|
description = "更新角色信息",
|
||||||
|
tags = {"权限相关接口"}
|
||||||
|
)
|
||||||
@PostMapping("/role-update")
|
@PostMapping("/role-update")
|
||||||
public ResponseEntity updateRole(@RequestBody SystemRole role) {
|
public ResponseEntity updateRole(@RequestBody SystemRole role) {
|
||||||
return ResponseEntity.ok(authService.updateRole(role));
|
return ResponseEntity.ok(authService.updateRole(role));
|
||||||
}
|
}
|
||||||
|
@Operation(
|
||||||
|
summary = "角色新增",
|
||||||
|
description = "新增角色",
|
||||||
|
tags = {"权限相关接口"}
|
||||||
|
)
|
||||||
|
@PostMapping("/role-add")
|
||||||
|
public ResponseEntity addRole(@RequestBody SystemRole role) {
|
||||||
|
return ResponseEntity.ok(authService.addRole(role));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,4 +109,17 @@ public class UserController {
|
|||||||
public ResponseEntity updateUser(@RequestBody ParamUserAdd userAddParam){
|
public ResponseEntity updateUser(@RequestBody ParamUserAdd userAddParam){
|
||||||
return ResponseEntity.ok(userService.updateUser(userAddParam));
|
return ResponseEntity.ok(userService.updateUser(userAddParam));
|
||||||
}
|
}
|
||||||
|
@Operation(
|
||||||
|
summary = "用户 删除",
|
||||||
|
description = "用户逻辑删除",
|
||||||
|
tags = {"用户相关接口"}
|
||||||
|
)
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public ResponseEntity deleteUser(@RequestBody ParamUserAdd userAddParam){
|
||||||
|
return ResponseEntity.ok(userService.deleteUser(userAddParam));
|
||||||
|
}
|
||||||
|
@PostMapping("/delete-realy")
|
||||||
|
public ResponseEntity deleteUserRealy(@RequestBody ParamUserAdd userAddParam){
|
||||||
|
return ResponseEntity.ok(userService.deleteUserReay(userAddParam));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,9 @@ public class ResponseResult<T> {
|
|||||||
private Integer code; // 消息代码,不填写默认1
|
private Integer code; // 消息代码,不填写默认1
|
||||||
private String msg; // 消息内容,不填写默认"success"
|
private String msg; // 消息内容,不填写默认"success"
|
||||||
private T data; // 数据内容,可以为空
|
private T data; // 数据内容,可以为空
|
||||||
|
public static <T> ResponseResult<T> success() {
|
||||||
|
return success(null, "ok");
|
||||||
|
}
|
||||||
public static <T> ResponseResult<T> success(T data) {
|
public static <T> ResponseResult<T> success(T data) {
|
||||||
return success(data, "success");
|
return success(data, "success");
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.guaiguailang.harmony.domain.vo.UserListNum;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -39,4 +40,6 @@ public interface UserMapper extends BaseMapper<UserInfo> {
|
|||||||
*/
|
*/
|
||||||
@Select("select * from system_role where role_id = (select role_id from user_info where user_info.id=#{id})")
|
@Select("select * from system_role where role_id = (select role_id from user_info where user_info.id=#{id})")
|
||||||
SystemRole getRoleLevelByUserId(Long id);
|
SystemRole getRoleLevelByUserId(Long id);
|
||||||
|
@Update("update user_info set deleted=1 where id=#{id}")
|
||||||
|
Integer changeDelete(Long id);
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,6 @@ public interface AuthService {
|
|||||||
ResponseResult getRoleAll();
|
ResponseResult getRoleAll();
|
||||||
|
|
||||||
ResponseResult updateRole(SystemRole systemRole);
|
ResponseResult updateRole(SystemRole systemRole);
|
||||||
|
|
||||||
|
ResponseResult addRole(SystemRole role);
|
||||||
}
|
}
|
||||||
|
@ -19,4 +19,8 @@ public interface UserService {
|
|||||||
ResponseResult registerUser(ParamUserAdd userAddParam);
|
ResponseResult registerUser(ParamUserAdd userAddParam);
|
||||||
|
|
||||||
ResponseResult updateUser(ParamUserAdd userAddParam);
|
ResponseResult updateUser(ParamUserAdd userAddParam);
|
||||||
|
|
||||||
|
ResponseResult deleteUser(ParamUserAdd userAddParam);
|
||||||
|
|
||||||
|
ResponseResult deleteUserReay(ParamUserAdd userAddParam);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.guaiguailang.harmony.service.impl;
|
|||||||
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.dev33.satoken.util.SaResult;
|
import cn.dev33.satoken.util.SaResult;
|
||||||
|
import com.github.yitter.idgen.YitIdHelper;
|
||||||
import com.guaiguailang.harmony.domain.dto.ParamLogin;
|
import com.guaiguailang.harmony.domain.dto.ParamLogin;
|
||||||
import com.guaiguailang.harmony.domain.entity.SystemRole;
|
import com.guaiguailang.harmony.domain.entity.SystemRole;
|
||||||
import com.guaiguailang.harmony.domain.entity.UserInfo;
|
import com.guaiguailang.harmony.domain.entity.UserInfo;
|
||||||
@ -108,4 +109,19 @@ public class AuthServiceImpl implements AuthService {
|
|||||||
return ResponseResult.error("更新失败");
|
return ResponseResult.error("更新失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseResult addRole(SystemRole role) {
|
||||||
|
// todo 此处可以进行性能优化,获取level从redis中获取
|
||||||
|
// 做一个校验,更新的level不能小于操作人的level
|
||||||
|
Long id = Long.parseLong(StpUtil.getLoginId().toString());// 获取用户id
|
||||||
|
// 获取level
|
||||||
|
SystemRole systemRoleCreator = userMapper.getRoleLevelByUserId(id);
|
||||||
|
if(role.getLevel()<=systemRoleCreator.getLevel()){
|
||||||
|
return ResponseResult.error("权限不足");
|
||||||
|
}
|
||||||
|
role.setId(YitIdHelper.nextId());
|
||||||
|
// 角色等级校验
|
||||||
|
return ResponseResult.success(roleMapper.insert(role));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,6 +265,26 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseResult deleteUser(ParamUserAdd userAddParam) {
|
||||||
|
Integer result = userMapper.changeDelete(userAddParam.getId());
|
||||||
|
if (result==1){
|
||||||
|
return ResponseResult.success();
|
||||||
|
}else {
|
||||||
|
return ResponseResult.error("删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseResult deleteUserReay(ParamUserAdd userAddParam) {
|
||||||
|
Integer result = userMapper.deleteById(userAddParam.getId());
|
||||||
|
if (result==1){
|
||||||
|
return ResponseResult.success();
|
||||||
|
}else {
|
||||||
|
return ResponseResult.error("删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 方法
|
// 方法
|
||||||
public UserInfo getUserByAccount(String username){
|
public UserInfo getUserByAccount(String username){
|
||||||
return userMapper.getUserByAccount(username);
|
return userMapper.getUserByAccount(username);
|
||||||
|
Loading…
Reference in New Issue
Block a user