陶杰
2024-08-22 ee9032d9baf5f33e376d2d2699136e0a7b26bec7
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package com.mzl.flower.web.customer;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.dto.request.customer.BindPartnerDTO;
import com.mzl.flower.dto.request.customer.ChangePartnerDTO;
import com.mzl.flower.dto.request.customer.QueryCustomerDTO;
import com.mzl.flower.dto.request.customer.UpdateCustomerDTO;
import com.mzl.flower.dto.request.supplier.AuditSupplierDTO;
import com.mzl.flower.dto.request.supplier.QuerySupplierDTO;
import com.mzl.flower.dto.request.supplier.UpdateSupplierDTO;
import com.mzl.flower.dto.response.customer.CustomerDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.service.customer.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.validation.constraints.NotBlank;
 
@RestController
@RequestMapping("/api/customer")
@Api(value = "商户(花店)管理", tags = "商户(花店)管理")
@Validated
@Slf4j
public class CustomerController extends BaseController {
 
    private final CustomerService customerService;
 
    public CustomerController(CustomerService customerService) {
        this.customerService = customerService;
    }
 
    @PostMapping("/addOrUpdate")
    @ApiOperation(value = "商户(花店)信息登记、修改", notes = "商户(花店)信息登记、修改")
    public ResponseEntity<ReturnDataDTO> addOrUpdateCustomer(@Validated @RequestBody UpdateCustomerDTO dto) {
        customerService.addOrUpdateCustomer(dto);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @GetMapping("/page")
    @ApiOperation(value = "运营端-商户(花店)分页查询", notes = "运营端-商户(花店)分页查询")
    public ResponseEntity<ReturnDataDTO<Page<CustomerDTO>>> queryCustomer(QueryCustomerDTO dto, Page page) {
        return returnData(R.SUCCESS.getCode(),customerService.queryCustomer(dto,page));
    }
 
    @GetMapping("/page/detail/{id}")
    @ApiOperation(value = "商户(花店)详情", notes = "商户(花店)详情")
    public ResponseEntity<ReturnDataDTO<SupplierDTO>> findDetail(@PathVariable("id") Long id) {
        return returnData(R.SUCCESS.getCode(),customerService.findDetail(id));
    }
 
 
    @GetMapping("/partner/page")
    @ApiOperation(value = "合伙人-商户(花店)分页查询", notes = "合伙人-商户(花店)分页查询")
    public ResponseEntity<ReturnDataDTO<Page<CustomerDTO>>> queryPartnerCustomer(QueryCustomerDTO dto, Page page) {
        dto.setPartnerUserId(SecurityUtils.getUserId());
        return returnData(R.SUCCESS.getCode(),customerService.queryCustomer(dto,page));
    }
 
 
    @PostMapping("/change/partner")
    @ApiOperation(value = "变更合伙人", notes = "变更合伙人")
    public ResponseEntity<ReturnDataDTO> changeCustomerPartner(@Validated @RequestBody ChangePartnerDTO dto) {
        customerService.changeCustomerPartner(dto);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @PostMapping("/bind/partner")
    @ApiOperation(value = "绑定合伙人", notes = "绑定合伙人")
    public ResponseEntity<ReturnDataDTO> bindPartner(@Validated @RequestBody BindPartnerDTO dto) {
        customerService.bindPartner(dto);
        return returnData(R.SUCCESS.getCode(),null);
    }
 
    @GetMapping("/partner/name")
    @ApiOperation(value = "商户(花店)详情", notes = "商户(花店)详情")
    public ResponseEntity<ReturnDataDTO<SupplierDTO>> getPartnerName(@NotBlank(message = "参数不能为空") String partnerUserId) {
        return returnData(R.SUCCESS.getCode(),customerService.getPartnerName(partnerUserId));
    }
}