ClientCustomerController.java 3.2 KB
package com.infoloop.tianting.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.ClientCustomerDto;
import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.HospitalRecordDto;
import com.infoloop.tianting.model.dto.ClientCustomerDbDTO.TodayOrderDto;
import com.infoloop.tianting.service.ClientCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "ClientCustomer")
@ApiSupport(order = -1)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ClientCustomerController {

  private final ClientCustomerService clientCustomerService;

  @ApiOperation(value = "根据hisCustomerId获取ClientCustomer")
  @GetMapping("/customers/his/{hisCustomerId}")
  @ResponseStatus(HttpStatus.OK)
  public ClientCustomerDto getClientCustomerByHISCustomerId(@PathVariable String hisCustomerId) {
    return  clientCustomerService.getClientCustomerByHISCustomerId(hisCustomerId);
  }

  @ApiOperation(value = "根据customerId获取ClientCustomer")
  @GetMapping("/customers/{customerId}")
  @ResponseStatus(HttpStatus.OK)
  public ClientCustomerDto getClientCustomerByCustomerId(@PathVariable Integer customerId) {
    return  clientCustomerService.getClientCustomerByCustomerId(customerId);
  }

  @ApiOperation(value = "根据phone获取ClientCustomer")
  @GetMapping("/customers/phone/{phone}")
  @ResponseStatus(HttpStatus.OK)
  public ClientCustomerDto getClientCustomerByPhone(@PathVariable String phone) {
    return  clientCustomerService.getClientCustomerByPhone(phone);
  }

  @ApiOperation(value = "根据customerId获取住院记录")
  @GetMapping("/enterprise/{enterpriseId}/hospitalRecords/customers/{customerId}")
  @ResponseStatus(HttpStatus.OK)
  public List<HospitalRecordDto> getHospitalRecords(@PathVariable Integer enterpriseId,
      @PathVariable Integer customerId) {
    return  clientCustomerService.getClientCustomerHospitalRecordsByCustomerId(
        enterpriseId, customerId);
  }

  @ApiOperation(value = "获取今日在住")
  @GetMapping("/clientCustomers/today/statistic")
  @ResponseStatus(HttpStatus.OK)
  public TodayOrderDto getClientCustomerTodayOrderStatistic(@RequestParam String customerToken) {
    return clientCustomerService.getTodayOrderStatistic(customerToken);
  }

  @ApiOperation(value = "获取his今日在住")
  @GetMapping("/hisClientCustomers/today/statistic")
  @ResponseStatus(HttpStatus.OK)
  public TodayOrderDto getHisClientCustomerTodayOrderStatistic(@RequestParam String customerToken) {
    return clientCustomerService.getTodayOrderStatisticForHis(customerToken);
  }

}