hejianhao
2026-08-28 16a57a8fc6868cea9171a1119698572407a2fc03
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
package com.tcm.training.admin.agent.controller;
 
import com.tcm.training.admin.agent.dto.ProvincialAgentSaveRequest;
import com.tcm.training.admin.agent.service.ProvincialAgentAppService;
import com.tcm.training.admin.agent.vo.ProvincialAgentDetailVO;
import com.tcm.training.admin.agent.vo.ProvincialAgentListItemVO;
import com.tcm.training.admin.common.ApiResponse;
import com.tcm.training.admin.common.PageResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.Valid;
 
@Validated
@RestController
@RequestMapping({"/api/v1", "/api"})
public class ProvincialAgentController {
    private final ProvincialAgentAppService service;
 
    public ProvincialAgentController(ProvincialAgentAppService service) {
        this.service = service;
    }
 
    @GetMapping("/provincial-agents")
    public ApiResponse<PageResponse<ProvincialAgentListItemVO>> page(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int pageSize, @RequestParam(required = false) String regionCode, @RequestParam(required = false) String clinicName, @RequestParam(required = false) String contactInfo, @RequestParam(required = false) Integer status) {
        return ApiResponse.ok(service.page(page, pageSize, regionCode, clinicName, contactInfo, status));
    }
 
    @GetMapping("/provincial-agents/{id}")
    public ApiResponse<ProvincialAgentDetailVO> detail(@PathVariable Long id) {
        return ApiResponse.ok(service.detail(id));
    }
 
    @PostMapping("/provincial-agents")
    public ApiResponse<ProvincialAgentDetailVO> create(@Valid @RequestBody ProvincialAgentSaveRequest r) {
        return ApiResponse.ok(service.create(r));
    }
 
    @PutMapping("/provincial-agents/{id}")
    public ApiResponse<ProvincialAgentDetailVO> update(@PathVariable Long id, @Valid @RequestBody ProvincialAgentSaveRequest r) {
        return ApiResponse.ok(service.update(id, r));
    }
 
    @DeleteMapping("/provincial-agents/{id}")
    public ApiResponse<Void> delete(@PathVariable Long id) {
        service.delete(id);
        return ApiResponse.ok(null);
    }
}