|
|
@@ -12,11 +12,12 @@ import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import com.etotem.cfc.util.ParamUtils;
|
|
|
+import com.etotem.cfc.common.RolesUtil;
|
|
|
|
|
|
@Tag(name = "训练方案管理", description = "规划师端训练方案CRUD/生成/下发/看板")
|
|
|
@RestController
|
|
|
@RequestMapping("/api/guide/training-plans")
|
|
|
-public class TrainingPlanController {
|
|
|
+public class TrainingPlanController extends TrainingPlanControllerCompatBase {
|
|
|
|
|
|
@Resource
|
|
|
private TrainingPlanService trainingPlanService;
|
|
|
@@ -56,9 +57,17 @@ public class TrainingPlanController {
|
|
|
|
|
|
@Operation(summary = "创建空白训练方案")
|
|
|
@PostMapping("/create")
|
|
|
+ @Override
|
|
|
public Result<Long> createPlan(@RequestAttribute("userId") Long guideId,
|
|
|
@RequestBody Map<String, Object> body,
|
|
|
- @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
|
|
|
+ @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId,
|
|
|
+ @RequestAttribute(value = "role", required = false) String role,
|
|
|
+ @RequestAttribute(value = "roles", required = false) List<String> roles) {
|
|
|
+ // S-cfc-238 teacher.plan.create:规划师端点角色门禁(teacher/admin),
|
|
|
+ // 参照 GuideFamilyQueryController.myFamilies 的 RolesUtil.hasTeacherRole 403 门禁。
|
|
|
+ if (!RolesUtil.hasTeacherRole(role, roles) && !"admin".equals(role)) {
|
|
|
+ return Result.error(403, "无权访问该接口");
|
|
|
+ }
|
|
|
Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
|
|
|
String title = body.get("title") != null ? body.get("title").toString() : null;
|
|
|
String description = body.get("description") != null ? body.get("description").toString() : null;
|
|
|
@@ -71,7 +80,14 @@ public class TrainingPlanController {
|
|
|
|
|
|
@Operation(summary = "更新方案基本信息")
|
|
|
@PostMapping("/update")
|
|
|
- public Result<Boolean> updatePlan(@RequestBody Map<String, Object> body) {
|
|
|
+ @Override
|
|
|
+ public Result<Boolean> updatePlan(@RequestBody Map<String, Object> body,
|
|
|
+ @RequestAttribute(value = "role", required = false) String role,
|
|
|
+ @RequestAttribute(value = "roles", required = false) List<String> roles) {
|
|
|
+ // S-cfc-238 teacher.plan.create:规划师端点角色门禁(teacher/admin)。
|
|
|
+ if (!RolesUtil.hasTeacherRole(role, roles) && !"admin".equals(role)) {
|
|
|
+ return Result.error(403, "无权访问该接口");
|
|
|
+ }
|
|
|
Long planId = ParamUtils.getLong(body.get("planId"));
|
|
|
String title = body.get("title") != null ? body.get("title").toString() : null;
|
|
|
String description = body.get("description") != null ? body.get("description").toString() : null;
|