longz
2026-04-21 58c73134fb1ce10c1ea1d95ee66d8c89557d7dee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.sinata.appointment.controller;
 
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.sinata.appointment.common.Result;
import com.sinata.appointment.common.ResultUtil;
import com.sinata.appointment.service.ExportApplicationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.HashMap;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
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/exports")
@RequiredArgsConstructor
public class ExportController {
 
    private final ExportApplicationService exportApplicationService;
 
    @Operation(summary = "异步导出任务入队")
    @PostMapping("/enqueue")
    @SaCheckPermission("exports:enqueue")
    public Result<Map<String, String>> enqueue(@RequestBody Map<String, Object> body) {
        String type = body.get("type") != null ? body.get("type").toString() : "appointment";
        @SuppressWarnings("unchecked")
        Map<String, Object> criteria =
                body.get("criteria") instanceof Map ? (Map<String, Object>) body.get("criteria") : Map.of();
        String taskId = exportApplicationService.enqueueExport(type, criteria);
        Map<String, String> res = new HashMap<>();
        res.put("taskId", taskId);
        return ResultUtil.data(res);
    }
}