mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-24 02:09:35 +08:00
学员权限
This commit is contained in:
parent
ad3ff5ec41
commit
b1022fde0a
@ -37,6 +37,11 @@ public class AdminPermissionCheck implements ApplicationRunner {
|
|||||||
{"部门", "15", "部门-删除", BPermissionConstant.DEPARTMENT_DESTROY},
|
{"部门", "15", "部门-删除", BPermissionConstant.DEPARTMENT_DESTROY},
|
||||||
|
|
||||||
{"资源分类", "0", "资源分类管理", BPermissionConstant.RESOURCE_CATEGORY},
|
{"资源分类", "0", "资源分类管理", BPermissionConstant.RESOURCE_CATEGORY},
|
||||||
|
|
||||||
|
{"学员", "0", "学员-查看", BPermissionConstant.USER_INDEX},
|
||||||
|
{"学员", "5", "学员-添加", BPermissionConstant.USER_STORE},
|
||||||
|
{"学员", "10", "学员-编辑", BPermissionConstant.USER_UPDATE},
|
||||||
|
{"学员", "15", "学员-删除", BPermissionConstant.USER_DESTROY},
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,4 +23,9 @@ public class BPermissionConstant {
|
|||||||
|
|
||||||
public final static String RESOURCE_CATEGORY = "resource-category";
|
public final static String RESOURCE_CATEGORY = "resource-category";
|
||||||
|
|
||||||
|
public final static String USER_INDEX = "user-index";
|
||||||
|
public final static String USER_STORE = "user-store";
|
||||||
|
public final static String USER_UPDATE = "user-update";
|
||||||
|
public final static String USER_DESTROY = "user-destroy";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import xyz.playedu.api.constant.BackendConstant;
|
import xyz.playedu.api.constant.BackendConstant;
|
||||||
import xyz.playedu.api.domain.AdminUser;
|
|
||||||
import xyz.playedu.api.domain.Resource;
|
import xyz.playedu.api.domain.Resource;
|
||||||
import xyz.playedu.api.domain.ResourceCategory;
|
import xyz.playedu.api.domain.ResourceCategory;
|
||||||
import xyz.playedu.api.request.backend.ResourceRequest;
|
import xyz.playedu.api.request.backend.ResourceRequest;
|
||||||
|
@ -22,7 +22,7 @@ public class SystemController {
|
|||||||
public JsonResponse imageCaptcha() throws IOException {
|
public JsonResponse imageCaptcha() throws IOException {
|
||||||
ImageCaptchaResult imageCaptchaResult = imageCaptchaService.generate();
|
ImageCaptchaResult imageCaptchaResult = imageCaptchaService.generate();
|
||||||
|
|
||||||
HashMap<String, String> data = new HashMap();
|
HashMap<String, String> data = new HashMap<>();
|
||||||
data.put("key", imageCaptchaResult.getKey());
|
data.put("key", imageCaptchaResult.getKey());
|
||||||
data.put("image", imageCaptchaResult.getImage());
|
data.put("image", imageCaptchaResult.getImage());
|
||||||
|
|
||||||
|
@ -5,8 +5,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import xyz.playedu.api.constant.BPermissionConstant;
|
||||||
import xyz.playedu.api.domain.User;
|
import xyz.playedu.api.domain.User;
|
||||||
import xyz.playedu.api.event.UserDestroyEvent;
|
import xyz.playedu.api.event.UserDestroyEvent;
|
||||||
|
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
|
||||||
import xyz.playedu.api.request.backend.UserRequest;
|
import xyz.playedu.api.request.backend.UserRequest;
|
||||||
import xyz.playedu.api.service.UserService;
|
import xyz.playedu.api.service.UserService;
|
||||||
import xyz.playedu.api.types.JsonResponse;
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
@ -32,6 +34,7 @@ public class UserController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_INDEX)
|
||||||
@GetMapping("/index")
|
@GetMapping("/index")
|
||||||
public JsonResponse index(
|
public JsonResponse index(
|
||||||
@RequestParam(name = "page", defaultValue = "1") Integer page,
|
@RequestParam(name = "page", defaultValue = "1") Integer page,
|
||||||
@ -79,11 +82,13 @@ public class UserController {
|
|||||||
return JsonResponse.data(result);
|
return JsonResponse.data(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_STORE)
|
||||||
@GetMapping("/create")
|
@GetMapping("/create")
|
||||||
public JsonResponse create() {
|
public JsonResponse create() {
|
||||||
return JsonResponse.data(null);
|
return JsonResponse.data(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_STORE)
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public JsonResponse store(@RequestBody @Validated UserRequest request) {
|
public JsonResponse store(@RequestBody @Validated UserRequest request) {
|
||||||
if (userService.emailIsExists(request.getEmail())) {
|
if (userService.emailIsExists(request.getEmail())) {
|
||||||
@ -118,6 +123,7 @@ public class UserController {
|
|||||||
return JsonResponse.success();
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_UPDATE)
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public JsonResponse edit(@PathVariable(name = "id") Integer id) {
|
public JsonResponse edit(@PathVariable(name = "id") Integer id) {
|
||||||
User user = userService.getById(id);
|
User user = userService.getById(id);
|
||||||
@ -131,6 +137,7 @@ public class UserController {
|
|||||||
return JsonResponse.data(data);
|
return JsonResponse.data(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_UPDATE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
public JsonResponse update(@PathVariable(name = "id") Integer id, @RequestBody @Validated UserRequest request) {
|
public JsonResponse update(@PathVariable(name = "id") Integer id, @RequestBody @Validated UserRequest request) {
|
||||||
User user = userService.getById(id);
|
User user = userService.getById(id);
|
||||||
@ -169,6 +176,7 @@ public class UserController {
|
|||||||
return JsonResponse.success();
|
return JsonResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BackendPermissionMiddleware(slug = BPermissionConstant.USER_DESTROY)
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public JsonResponse destroy(@PathVariable(name = "id") Integer id) {
|
public JsonResponse destroy(@PathVariable(name = "id") Integer id) {
|
||||||
User user = userService.getById(id);
|
User user = userService.getById(id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user