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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.talentcard.server.business.admin;
 
import java.time.LocalDate;
import java.util.Map;
 
import com.talentcard.server.business.PageResult;
import com.talentcard.server.common.ApiResponse;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/api/admin/cards/child-applications")
public class ChildInformationAdminController {
 
    private final ChildInformationAdminService service;
 
    public ChildInformationAdminController(ChildInformationAdminService service) {
        this.service = service;
    }
 
    @GetMapping
    public ApiResponse<PageResult<Map<String, Object>>> page(
            @RequestParam(required = false) String childKeyword,
            @RequestParam(required = false) String talentKeyword,
            @RequestParam(required = false) String cardLevel,
            @RequestParam(required = false) String status,
            @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate applyStart,
            @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate applyEnd,
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int size
    ) {
        return ApiResponse.success(service.page(
                childKeyword,
                talentKeyword,
                cardLevel,
                status,
                applyStart,
                applyEnd,
                page,
                size
        ));
    }
 
    @GetMapping("/{id}")
    public ApiResponse<Map<String, Object>> detail(@PathVariable Long id) {
        return ApiResponse.success(service.detail(id));
    }
 
    @PatchMapping("/{id}/audit")
    public ApiResponse<Map<String, Object>> audit(
            @PathVariable Long id,
            @RequestBody Map<String, String> body
    ) {
        return ApiResponse.success(service.audit(id, body.get("status"), body.get("auditRemark")));
    }
}