93 lines
3.8 KiB
Java
93 lines
3.8 KiB
Java
package com.lesingle.creation.controller;
|
|
|
|
import com.lesingle.creation.common.core.Result;
|
|
import com.lesingle.creation.common.security.UserPrincipal;
|
|
import com.lesingle.creation.dto.presetcomment.CreatePresetCommentDTO;
|
|
import com.lesingle.creation.service.ContestPresetCommentService;
|
|
import com.lesingle.creation.service.ContestReviewService;
|
|
import com.lesingle.creation.vo.presetcomment.PresetCommentVO;
|
|
import com.lesingle.creation.vo.review.JudgeContestVO;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 竞赛预设评语管理控制器
|
|
*/
|
|
@Tag(name = "竞赛预设评语管理")
|
|
@RestController
|
|
@RequestMapping("/api/contests/preset-comments")
|
|
@RequiredArgsConstructor
|
|
public class ContestPresetCommentController {
|
|
|
|
private final ContestPresetCommentService presetCommentService;
|
|
private final ContestReviewService reviewService;
|
|
|
|
@PostMapping
|
|
@Operation(summary = "创建预设评语")
|
|
@PreAuthorize("hasAuthority('contest:preset-comment:create')")
|
|
public Result<PresetCommentVO> create(
|
|
@AuthenticationPrincipal UserPrincipal userPrincipal,
|
|
@RequestBody @Validated CreatePresetCommentDTO dto) {
|
|
Long tenantId = userPrincipal.getTenantId();
|
|
PresetCommentVO result = presetCommentService.create(dto, tenantId);
|
|
return Result.success(result);
|
|
}
|
|
|
|
@DeleteMapping("/{id}")
|
|
@Operation(summary = "删除预设评语")
|
|
@PreAuthorize("hasAuthority('contest:preset-comment:delete')")
|
|
public Result<Void> delete(@PathVariable Long id) {
|
|
presetCommentService.delete(id);
|
|
return Result.success(null);
|
|
}
|
|
|
|
@GetMapping("/{id}")
|
|
@Operation(summary = "获取预设评语详情")
|
|
@PreAuthorize("hasAuthority('contest:read')")
|
|
public Result<PresetCommentVO> getDetail(@PathVariable Long id) {
|
|
PresetCommentVO result = presetCommentService.getDetail(id);
|
|
return Result.success(result);
|
|
}
|
|
|
|
@GetMapping("/contest/{contestId}")
|
|
@Operation(summary = "查询活动的预设评语列表")
|
|
@PreAuthorize("hasAuthority('contest:read')")
|
|
public Result<List<PresetCommentVO>> listByContest(
|
|
@AuthenticationPrincipal UserPrincipal userPrincipal,
|
|
@PathVariable Long contestId) {
|
|
Long tenantId = userPrincipal.getTenantId();
|
|
List<PresetCommentVO> result = presetCommentService.listByContest(contestId, tenantId);
|
|
return Result.success(result);
|
|
}
|
|
|
|
@GetMapping("/common")
|
|
@Operation(summary = "查询通用评语列表")
|
|
@PreAuthorize("hasAuthority('contest:read')")
|
|
public Result<List<PresetCommentVO>> listCommon(
|
|
@AuthenticationPrincipal UserPrincipal userPrincipal) {
|
|
Long tenantId = userPrincipal.getTenantId();
|
|
List<PresetCommentVO> result = presetCommentService.listCommon(tenantId);
|
|
return Result.success(result);
|
|
}
|
|
|
|
/**
|
|
* 与 {@code GET /api/contests/reviews/judge/contests} 一致,供前端在预设评语模块复用
|
|
*/
|
|
@GetMapping("/judge/contests")
|
|
@Operation(summary = "评委参与的活动列表")
|
|
@PreAuthorize("hasAnyAuthority('review:score','contest:review:score')")
|
|
public Result<List<JudgeContestVO>> getJudgeContests(
|
|
@AuthenticationPrincipal UserPrincipal userPrincipal) {
|
|
Long judgeId = userPrincipal.getUserId();
|
|
Long tenantId = userPrincipal.getTenantId();
|
|
return Result.success(reviewService.getJudgeContests(judgeId, tenantId));
|
|
}
|
|
}
|