package com.yifu.cloud.plus.v1.yifu.insurances.controller;

import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.insurances.entity.InsuranceRefundCheck;
import com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceDetailService;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceAddParam;
import com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceBatchParam;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.List;

/**
 * @author licancan
 * @description 针对表【t_insurance_detail(商险明细表)】的数据库操作controller
 * @date 2022-07-18 16:38:48
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/insuranceDetail")
@Tag(name = "商险相关")
@Validated
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class TInsuranceDetailController {
	@Resource
	private TInsuranceDetailService tInsuranceDetailService;

	/***********************商险办理********************************/
	/**
	 * 商险新增
	 *
	 * @author licancan
	 * @param paramList
	 * @return {@link R<List<InsuranceAddParam>>}
	 */
	@PostMapping("/addInsurance")
	public R<List<InsuranceAddParam>> addInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<InsuranceAddParam> paramList){
		return tInsuranceDetailService.addInsurance(paramList);
	}

	/**
	 * 商险批增
	 *
	 * @author licancan
	 * @param paramList
	 * @return {@link R<List<InsuranceBatchParam>>}
	 */
	@PostMapping("/batchInsurance")
	public R<List<InsuranceBatchParam>> batchInsurance(@RequestBody @Valid @Size(min = 1,message = "集合不能为空") List<InsuranceBatchParam> paramList){
		return tInsuranceDetailService.batchInsurance(paramList);
	}

	/***********************减员办理********************************/

	/**
	 * 导入减员校验
	 * @param insuranceRefundCheckList 导入减员校验
	 * @author zhaji
	 * @date 2022-07-19
	 * @since v1.0
	 */
	@PostMapping("/checkPayRollList")
	public R checkInsuranceRefundList(@RequestBody List<InsuranceRefundCheck> insuranceRefundCheckList){

		return tInsuranceDetailService.checkInsuranceRefundList(insuranceRefundCheckList);
	}
}
