|
@@ -48,21 +48,33 @@ public class BadgeController {
|
|
|
|
|
|
|
|
@Operation(summary = "创建勋章")
|
|
@Operation(summary = "创建勋章")
|
|
|
@PostMapping("/create")
|
|
@PostMapping("/create")
|
|
|
- public Result<String> createBadge(@RequestBody Badge badge) {
|
|
|
|
|
|
|
+ public Result<String> createBadge(@RequestBody Badge badge,
|
|
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
|
|
+ return Result.error("无权限");
|
|
|
|
|
+ }
|
|
|
badgeService.createBadge(badge);
|
|
badgeService.createBadge(badge);
|
|
|
return Result.success("创建成功");
|
|
return Result.success("创建成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "更新勋章")
|
|
@Operation(summary = "更新勋章")
|
|
|
@PostMapping("/update")
|
|
@PostMapping("/update")
|
|
|
- public Result<String> updateBadge(@RequestBody Badge badge) {
|
|
|
|
|
|
|
+ public Result<String> updateBadge(@RequestBody Badge badge,
|
|
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
|
|
+ return Result.error("无权限");
|
|
|
|
|
+ }
|
|
|
badgeService.updateBadge(badge);
|
|
badgeService.updateBadge(badge);
|
|
|
return Result.success("更新成功");
|
|
return Result.success("更新成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Operation(summary = "删除勋章")
|
|
@Operation(summary = "删除勋章")
|
|
|
@PostMapping("/delete")
|
|
@PostMapping("/delete")
|
|
|
- public Result<String> deleteBadge(@RequestBody Map<String, Object> body) {
|
|
|
|
|
|
|
+ public Result<String> deleteBadge(@RequestBody Map<String, Object> body,
|
|
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
|
|
+ return Result.error("无权限");
|
|
|
|
|
+ }
|
|
|
Long id = ParamUtils.getLong(body.get("id"));
|
|
Long id = ParamUtils.getLong(body.get("id"));
|
|
|
badgeService.deleteBadge(id);
|
|
badgeService.deleteBadge(id);
|
|
|
return Result.success("删除成功");
|
|
return Result.success("删除成功");
|