| | |
| | | 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 cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | @Validated @RestController @RequestMapping({"/api/v1","/api"}) |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | |
| | | @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 agentName,@RequestParam(required=false) String province){return ApiResponse.ok(service.page(page,pageSize,agentName,province));} |
| | | @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);} |
| | | private final ProvincialAgentAppService service; |
| | | |
| | | public ProvincialAgentController(ProvincialAgentAppService service) { |
| | | this.service = service; |
| | | } |
| | | |
| | | @GetMapping("/provincial-agents") |
| | | @SaCheckPermission("member:agent:view") |
| | | 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/export") |
| | | @SaCheckPermission("member:agent:view") |
| | | public void export(@RequestParam(required = false) String regionCode, |
| | | @RequestParam(required = false) String clinicName, |
| | | @RequestParam(required = false) String contactInfo, |
| | | @RequestParam(required = false) Integer status, |
| | | HttpServletResponse response) throws IOException { |
| | | service.export(regionCode, clinicName, contactInfo, status, response); |
| | | } |
| | | |
| | | @GetMapping("/provincial-agents/{id}") |
| | | @SaCheckPermission("member:agent:detail") |
| | | public ApiResponse<ProvincialAgentDetailVO> detail(@PathVariable Long id) { |
| | | return ApiResponse.ok(service.detail(id)); |
| | | } |
| | | |
| | | @PostMapping("/provincial-agents") |
| | | @SaCheckPermission("member:agent:add") |
| | | public ApiResponse<ProvincialAgentDetailVO> create(@Valid @RequestBody ProvincialAgentSaveRequest r) { |
| | | return ApiResponse.ok(service.create(r)); |
| | | } |
| | | |
| | | @PutMapping("/provincial-agents/{id}") |
| | | @SaCheckPermission("member:agent:edit") |
| | | public ApiResponse<ProvincialAgentDetailVO> update(@PathVariable Long id, @Valid @RequestBody ProvincialAgentSaveRequest r) { |
| | | return ApiResponse.ok(service.update(id, r)); |
| | | } |
| | | |
| | | @DeleteMapping("/provincial-agents/{id}") |
| | | @SaCheckPermission("member:agent:delete") |
| | | public ApiResponse<Void> delete(@PathVariable Long id) { |
| | | service.delete(id); |
| | | return ApiResponse.ok(null); |
| | | } |
| | | } |