
package org.sky.scientific.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.sky.core.boot.ctrl.KdController;
import org.sky.core.secure.utils.SecureUtil;
import org.sky.core.tool.api.R;
import org.sky.scientific.pojo.entity.SettingEntity;
import org.sky.scientific.service.SettingService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 出勤时间设置 控制器
 *
 * @author Kd
 * @since 2025-07-01
 */
@RestController
@AllArgsConstructor
@RequestMapping("/setting")
@Tag(name = "设置-出勤时长/高企证书/火炬发展年报")
public class SettingController extends KdController {

	private final SettingService service;

	@GetMapping("/detail/{year}")
	@ApiOperationSupport(order = 1)
	@Operation(summary = "详情")
	public R<SettingEntity> detail(@PathVariable("year") String year) {
		SettingEntity detail = service.detail(year);
		return R.data(detail);
	}

	@GetMapping("/torch-dev/list")
	@ApiOperationSupport(order = 1)
	@Operation(summary = "火炬发展年报")
	public R<List<SettingEntity>> torchDevList(String yearMin, String yearMax) {
		List<SettingEntity> list = service.torchDevList(yearMin,yearMax);
 		return R.data(list);
	}

	@PostMapping("/submit")
	@ApiOperationSupport(order = 3)
	@Operation(summary = "新增或修改" )
	public R submit(@Valid @RequestBody SettingEntity dto) {
		dto.setTenantId(SecureUtil.getTenantId());
		return R.status(service.submit(dto));
	}

	@GetMapping("/fetchLastYearData")
	@ApiOperationSupport(order = 4)
	@Operation(summary = "读取上年度数据")
	public R<Boolean> fetchLastYearData(SettingEntity settingEntity) {
		return R.status(service.fetchLastYearData(settingEntity));
	}

}
