2026-04-27 10:27:57 +08:00
|
|
|
package com.labelsys.backend.controller;
|
|
|
|
|
|
|
|
|
|
import com.labelsys.backend.common.Result;
|
|
|
|
|
import com.labelsys.backend.context.UserContext;
|
|
|
|
|
import com.labelsys.backend.dto.common.PageResult;
|
|
|
|
|
import com.labelsys.backend.dto.request.AnnotationTaskPageQuery;
|
|
|
|
|
import com.labelsys.backend.dto.request.CreateAnnotationTaskRequest;
|
|
|
|
|
import com.labelsys.backend.dto.request.UpdateAnnotationTaskRequest;
|
|
|
|
|
import com.labelsys.backend.dto.response.AnnotationTaskResponse;
|
|
|
|
|
import com.labelsys.backend.service.AnnotationTaskService;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
2026-04-27 16:25:39 +08:00
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
2026-04-27 10:27:57 +08:00
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import jakarta.validation.Valid;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
2026-04-27 16:25:39 +08:00
|
|
|
import org.springdoc.core.annotations.ParameterObject;
|
2026-04-27 10:27:57 +08:00
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
@Tag(name = "标注任务管理")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/annotation-tasks")
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class AnnotationTaskController {
|
|
|
|
|
|
|
|
|
|
private final AnnotationTaskService annotationTaskService;
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "创建标注任务")
|
|
|
|
|
@PostMapping
|
|
|
|
|
public Result<AnnotationTaskResponse> create(@Valid @RequestBody CreateAnnotationTaskRequest request) {
|
|
|
|
|
return Result.success(annotationTaskService.createTask(UserContext.requireUser(), request));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "更新标注任务")
|
|
|
|
|
@PutMapping("/{id}")
|
2026-04-27 16:25:39 +08:00
|
|
|
public Result<AnnotationTaskResponse> update(
|
|
|
|
|
@Parameter(description = "任务ID", example = "191000000000000301")
|
|
|
|
|
@PathVariable Long id,
|
|
|
|
|
@Valid @RequestBody UpdateAnnotationTaskRequest request
|
|
|
|
|
) {
|
2026-04-27 10:27:57 +08:00
|
|
|
return Result.success(annotationTaskService.updateTask(UserContext.requireUser(), id, request));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "分页查询标注任务")
|
|
|
|
|
@GetMapping
|
2026-04-27 16:25:39 +08:00
|
|
|
public Result<PageResult<AnnotationTaskResponse>> page(@ParameterObject AnnotationTaskPageQuery query) {
|
2026-04-27 10:27:57 +08:00
|
|
|
return Result.success(annotationTaskService.pageTasks(UserContext.requireUser(), query));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "查询标注任务详情")
|
|
|
|
|
@GetMapping("/{id}")
|
2026-04-27 16:25:39 +08:00
|
|
|
public Result<AnnotationTaskResponse> detail(
|
|
|
|
|
@Parameter(description = "任务ID", example = "191000000000000301")
|
|
|
|
|
@PathVariable Long id
|
|
|
|
|
) {
|
2026-04-27 10:27:57 +08:00
|
|
|
return Result.success(annotationTaskService.getTask(UserContext.requireUser(), id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除标注任务")
|
|
|
|
|
@DeleteMapping("/{id}")
|
2026-04-27 16:25:39 +08:00
|
|
|
public Result<Void> delete(
|
|
|
|
|
@Parameter(description = "任务ID", example = "191000000000000301")
|
|
|
|
|
@PathVariable Long id
|
|
|
|
|
) {
|
2026-04-27 10:27:57 +08:00
|
|
|
annotationTaskService.deleteTask(UserContext.requireUser(), id);
|
|
|
|
|
return Result.success();
|
|
|
|
|
}
|
|
|
|
|
}
|