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

import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.salary.service.SalaryUploadService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryAccountVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 标准薪酬上传
 *
 * @author hgw
 * @date 2019-9-4 11:59:33
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/salary")
@Tag(name = "标准薪酬上传")
public class SalaryUploadController {

	private final SalaryUploadService salaryUploadService;

	/**
	 * @param jsonString   Excel表-JsonString
	 * @param settleDepart 结算主体id
	 * @param configId     配置方案id
	 * @param salaryType   报表类型id
	 * @param repeatFlag   默认 0：不允许重复导入已存在系统内的数据；1：允许重复导入
	 * @Description:
	 * @Author: hgw
	 * @Date: 2019/9/11 15:21
	 * @return: com.yifu.cloud.v1.common.core.util.R
	 **/
	@Operation(description = "上传：jsonString：表格json；settleDepart：结算主体id；configId：工资配置结算月等信息的id；salaryType：工资类型")
	@SysLog("上传薪资表")
	@PostMapping("/upload")
	public R upload(@RequestBody String jsonString, @RequestParam String settleDepart, @RequestParam String configId
			, @RequestParam String salaryType, @RequestParam int repeatFlag) {
		return salaryUploadService.salaryUpload(jsonString, settleDepart, configId, salaryType, repeatFlag);
	}

	/**
	 * @param savList 工资表volist
	 * @Description: 保存并提交报账表
	 * @Author: hgw
	 * @Date: 2019/9/18 18:17
	 * @return: com.yifu.cloud.v1.common.core.util.R
	 **/
	@Operation(description = "保存并提交")
	@SysLog("保存并提交薪资表")
	@PostMapping("/saveAndSubmit")
	public R saveAndSubmit(@RequestBody List<TSalaryAccountVo> savList) {
		return salaryUploadService.saveAndSubmit(savList);
	}

}
