LabelController.java 4.37 KB
package com.infoloop.tianting.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.infoloop.tianting.clientcustomerservice.BatchCreateClientCustomerLabelRefsRpcRequest;
import com.infoloop.tianting.model.dto.ClientLabelDTO;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchCreateCustomerLabelRefResponseDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.BatchDeleteCustomerLabelRefResponseDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.CustomerLabelRefDetailDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.HisAllergy;
import com.infoloop.tianting.model.dto.ClientLabelDTO.HisMedicalAdviceDto;
import com.infoloop.tianting.model.dto.ClientLabelDTO.LabelDto;
import com.infoloop.tianting.model.dto.MealDbDTO;
import com.infoloop.tianting.model.dto.MealDbDTO.MealDto;
import com.infoloop.tianting.service.ClientCustomerService;
import com.infoloop.tianting.service.DeliveryRuleService;
import com.infoloop.tianting.service.MeiZhongYiHeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.validation.Valid;
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.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "标签")
@ApiSupport(order = -1)
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class LabelController {
  private final DeliveryRuleService deliveryRuleService;
  private final ClientCustomerService clientCustomerService;
  private final MeiZhongYiHeService meiZhongYiHeService;

  @ApiOperation(value = "按类型获取标签")
  @PostMapping("/labels")
  @ResponseStatus(HttpStatus.OK)
  public List<LabelDto> getMiniProgramLabels(@Valid @RequestBody ClientLabelDTO.QueryLabelsDto queryLabelsDto) {
    return deliveryRuleService.getLabelsByTypes(queryLabelsDto);
  }

  @ApiOperation(value = "批量创建用户绑定标签")
  @PostMapping("/labels/batch")
  @ResponseStatus(HttpStatus.OK)
  public BatchCreateCustomerLabelRefResponseDto batchCreateCustomerLabelRef(
      @Valid @RequestBody ClientLabelDTO.BatchCreateCustomerLabelRefDto
          batchCreateCustomerLabelRefDto) {
    return clientCustomerService.batchCreateClientCustomerLabelRefs(batchCreateCustomerLabelRefDto);
  }

  @ApiOperation(value = "获取用户已绑定的标签")
  @PostMapping("/enterprises/{enterpriseId}/labels/customers/{customerId}")
  @ResponseStatus(HttpStatus.OK)
  public List<CustomerLabelRefDetailDto> getCustomerLabelsByCustomerId(
      @PathVariable Integer enterpriseId, @PathVariable Integer customerId) {
    return clientCustomerService.getCustomerLabelsByCustomerId(enterpriseId, customerId);
  }

  @ApiOperation(value = "批量删除用户绑定的标签")
  @DeleteMapping("/customer/label/refs")
  @ResponseStatus(HttpStatus.OK)
  public BatchDeleteCustomerLabelRefResponseDto getCustomerLabelsByCustomerId(
      @Valid@RequestBody ClientLabelDTO.BatchDeleteCustomerLabelRefRequestDto request) {
    return clientCustomerService.deleteClientCustomerLabelRefsByIds(request);
  }

  @ApiOperation(value = "根据hisCustomerId查询用户绑定过敏源标签")
  @GetMapping("/allergy/hisCustomer/{hisCustomerId}")
  @ResponseStatus(HttpStatus.OK)
  public List<HisAllergy> getHisCustomerAllergiesByCustomerId(@PathVariable String hisCustomerId) {
    return meiZhongYiHeService.getHisCustomerAllergiesByCustomerId(hisCustomerId);
  }

  @ApiOperation(value = "根据contractNo查询His用户医嘱")
  @GetMapping("/medicalAdvice/hisCustomer/{contractNo}")
  @ResponseStatus(HttpStatus.OK)
  public List<HisMedicalAdviceDto> getHisCustomerMedicalAdviceByContractNo(@PathVariable String contractNo) {
    return meiZhongYiHeService.getHisCustomerMedicalAdvicesByContractNo(contractNo);
  }
}