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

import com.yifu.cloud.plus.v1.permission.service.QiWeiService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.DateUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.permission.entity.EkpQiwiChuchai;
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 2024-4-10 11:26:50
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/qiWei")
@Tag(name = "工资服务-获取微信")
public class QiWeiController {

	private final QiWeiService wxSalaryService;

	/**
	 * @Description: 每日获取当日企业微信审批里的出差
	 * @Author: hgw
	 * @Date: 2024-4-11 11:03:34
	 * @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TEventFeeDetail>>
	 **/
	@PostMapping("/inner/everyDaySaveQiWeiChuChai")
	@Inner
	public R<List<EkpQiwiChuchai>> everyDaySaveQiWeiChuChai() {
		String startDay = DateUtil.addDay(-29);
		String endDay = DateUtil.addDay(0);
		return wxSalaryService.getQiWeiChuChaiAndSave(startDay, endDay, 1);
	}

	/**
	 * @param startTime
	 * @param endTime
	 * @Description: 获取企业微信审批里的出差
	 * @Author: hgw
	 * @Date: 2024-4-11 11:03:30
	 * @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>>
	 **/
	@Operation(description = "获取企业微信审批里的出差数据：startTime格式：2024-04-10")
	@PostMapping("/getQiWeiChuCHaiInfoAndSave")
	//@PreAuthorize("@pms.hasPermission('wxhr:wxsalaryauth')")
	public R<List<EkpQiwiChuchai>> getQiWeiChuCHaiInfoAndSave(@RequestParam String startTime, @RequestParam String endTime) {
		return wxSalaryService.getQiWeiChuChaiAndSave(startTime, endTime, 1);
	}

	/**
	 * @Description: 每日获取当日HCM的E人事审批里的出差
	 * @Author: hgw
	 * @Date: 2024-4-28 16:51:16
	 * @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TEventFeeDetail>>
	 **/
	@PostMapping("/inner/everyDaySaveHcmChuChai")
	@Inner
	public R<List<EkpQiwiChuchai>> everyDaySaveHcmChuChai() {
		String startDay = DateUtil.addDay(-1);
		String endDay = DateUtil.addDay(0);
		return wxSalaryService.getQiWeiChuChaiAndSave(startDay, endDay, 2);
	}

	/**
	 * @param startTime
	 * @param endTime
	 * @Description: 获取HCM的E人事审批里的出差
	 * @Author: hgw
	 * @Date: 2024-4-28 16:51:39
	 * @return: com.yifu.cloud.v1.common.core.util.R<java.util.List < com.yifu.cloud.v1.hrms.api.entity.TStatisticsProjectReimburse>>
	 **/
	@Operation(description = "获取HCM的E人事审批里的出差：startTime格式：2024-04-10")
	@PostMapping("/getHcmChuChaiInfoAndSave")
	//@PreAuthorize("@pms.hasPermission('wxhr:wxsalaryauth')")
	public R<List<EkpQiwiChuchai>> getHcmChuChaiInfoAndSave(@RequestParam String startTime, @RequestParam String endTime) {
		return wxSalaryService.getQiWeiChuChaiAndSave(startTime, endTime, 2);
	}

}
