mirror of https://github.com/longtai-cn/hippo4j
parent
df450f4cbc
commit
2a8f7537b9
@ -0,0 +1,42 @@
|
||||
package com.github.dynamic.threadpool.console.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.dynamic.threadpool.auth.model.biz.permission.PermissionRespDTO;
|
||||
import com.github.dynamic.threadpool.auth.service.PermissionService;
|
||||
import com.github.dynamic.threadpool.common.web.base.Result;
|
||||
import com.github.dynamic.threadpool.common.web.base.Results;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* Permission controller.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/10/30 22:08
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/v1/auth/permissions")
|
||||
public class PermissionController {
|
||||
|
||||
private final PermissionService permissionService;
|
||||
|
||||
@GetMapping("/{pageNo}/{pageSize}")
|
||||
public Result<IPage<PermissionRespDTO>> listPermission(@PathVariable("pageNo") int pageNo, @PathVariable("pageSize") int pageSize) {
|
||||
IPage<PermissionRespDTO> resultPermissionPage = permissionService.listPermission(pageNo, pageSize);
|
||||
return Results.success(resultPermissionPage);
|
||||
}
|
||||
|
||||
@PostMapping("/{role}/{resource}/{action}")
|
||||
public Result<Void> addPermission(@PathVariable("role") String role, @PathVariable("resource") String resource, @PathVariable("action") String action) {
|
||||
permissionService.addPermission(role, resource, action);
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{role}/{resource}/{action}")
|
||||
public Result<Void> deleteUser(@PathVariable("role") String role, @PathVariable("resource") String resource, @PathVariable("action") String action) {
|
||||
permissionService.deletePermission(role, resource, action);
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.github.dynamic.threadpool.console.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.dynamic.threadpool.auth.model.biz.role.RoleRespDTO;
|
||||
import com.github.dynamic.threadpool.auth.service.RoleService;
|
||||
import com.github.dynamic.threadpool.common.web.base.Result;
|
||||
import com.github.dynamic.threadpool.common.web.base.Results;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Role controller.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/10/30 22:16
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/v1/auth/roles")
|
||||
public class RoleController {
|
||||
|
||||
private final RoleService roleService;
|
||||
|
||||
@GetMapping("/{pageNo}/{pageSize}")
|
||||
public Result<IPage<RoleRespDTO>> listUser(@PathVariable("pageNo") int pageNo, @PathVariable("pageSize") int pageSize) {
|
||||
IPage<RoleRespDTO> resultRolePage = roleService.listRole(pageNo, pageSize);
|
||||
return Results.success(resultRolePage);
|
||||
}
|
||||
|
||||
@PostMapping("/{role}/{userName}")
|
||||
public Result<Void> addUser(@PathVariable("role") String role, @PathVariable("userName") String userName) {
|
||||
roleService.addRole(role, userName);
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{role}/{userName}")
|
||||
public Result<Void> deleteUser(@PathVariable("role") String role, @PathVariable("userName") String userName) {
|
||||
roleService.deleteRole(role, userName);
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
@GetMapping("/search/{role}")
|
||||
public Result<List<String>> searchUsersLikeUserName(@PathVariable("role") String role) {
|
||||
List<String> resultRole = roleService.getRoleLike(role);
|
||||
return Results.success(resultRole);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.github.dynamic.threadpool.console.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.dynamic.threadpool.auth.model.biz.user.UserRespDTO;
|
||||
import com.github.dynamic.threadpool.auth.service.UserService;
|
||||
import com.github.dynamic.threadpool.common.web.base.Result;
|
||||
import com.github.dynamic.threadpool.common.web.base.Results;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User controller.
|
||||
*
|
||||
* @author chen.ma
|
||||
* @date 2021/10/30 21:15
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping({"/v1/auth", "/v1/auth/users"})
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
@GetMapping("/{pageNo}/{pageSize}")
|
||||
public Result<IPage<UserRespDTO>> listUser(@PathVariable("pageNo") int pageNo, @PathVariable("pageSize") int pageSize) {
|
||||
IPage<UserRespDTO> resultUserPage = userService.listUser(pageNo, pageSize);
|
||||
return Results.success(resultUserPage);
|
||||
}
|
||||
|
||||
@PostMapping("/{userName}/{password}")
|
||||
public Result<Void> addUser(@PathVariable("userName") String userName, @PathVariable("password") String password) {
|
||||
userService.addUser(userName, password);
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
@PutMapping("/{userName}/{password}")
|
||||
public Result<Void> updateUser(@PathVariable("userName") String userName, @PathVariable("password") String password) {
|
||||
userService.updateUser(userName, password);
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{userName}")
|
||||
public Result<Void> deleteUser(@PathVariable("userName") String userName) {
|
||||
userService.deleteUser(userName);
|
||||
return Results.success();
|
||||
}
|
||||
|
||||
@GetMapping("/search/{userName}")
|
||||
public Result<List<String>> searchUsersLikeUserName(@PathVariable("userName") String userName) {
|
||||
List<String> resultUserNames = userService.getUserLikeUsername(userName);
|
||||
return Results.success(resultUserNames);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue