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.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.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; import javax.validation.constraints.NotNull; @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 addOrUpdateCustomer(@Validated @RequestBody UpdateCustomerDTO dto) { customerService.addOrUpdateCustomer(dto); return returnData(R.SUCCESS.getCode(),null); } @GetMapping("/page") @ApiOperation(value = "运营端-商户(花店)分页查询", notes = "运营端-商户(花店)分页查询") public ResponseEntity>> queryCustomer(QueryCustomerDTO dto, Page page) { return returnData(R.SUCCESS.getCode(),customerService.queryCustomer(dto,page)); } @GetMapping("/page/detail/{id}") @ApiOperation(value = "商户(花店)详情", notes = "商户(花店)详情") public ResponseEntity> findDetail(@PathVariable("id") Long id) { return returnData(R.SUCCESS.getCode(),customerService.findDetail(id)); } @GetMapping("/partner/page") @ApiOperation(value = "合伙人-商户(花店)分页查询", notes = "合伙人-商户(花店)分页查询") public ResponseEntity>> 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 changeCustomerPartner(@Validated @RequestBody ChangePartnerDTO dto) { customerService.changeCustomerPartner(dto); return returnData(R.SUCCESS.getCode(),null); } @PostMapping("/bind/partner") @ApiOperation(value = "绑定合伙人", notes = "绑定合伙人") public ResponseEntity bindPartner(@Validated @RequestBody BindPartnerDTO dto) { customerService.bindPartner(dto); return returnData(R.SUCCESS.getCode(),null); } @GetMapping("/partner/name") @ApiOperation(value = "商户(花店)详情", notes = "商户(花店)详情") public ResponseEntity> getPartnerName(@NotBlank(message = "参数不能为空") String id) { return returnData(R.SUCCESS.getCode(),customerService.getPartnerName(id)); } @GetMapping("/page/isEnable") @ApiOperation(value = "启用/禁用", notes = "启用/禁用商品") public ResponseEntity> isEnable(@NotNull(message = "id不能为空") Long id) { customerService.isEnable(id); return returnData(R.SUCCESS.getCode(),null); } @GetMapping("/info/{phone}") @ApiOperation(value = "用户详情", notes = "用户详情") public ResponseEntity> findCustomerByPhone(@PathVariable("phone") String phone) { return returnData(R.SUCCESS.getCode(),customerService.findCustomerByPhone(phone)); } }