package jnpf.attendance;

import jnpf.attendance.fallback.AttendanceDailyRuleApiFallback;
import jnpf.base.ActionResult;
import jnpf.util.NoDataSourceBind;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;

/**
 * 组队动态
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * @date 2021-03-24
 */
@FeignClient(name = "jnpf-ftb", fallbackFactory = AttendanceDailyRuleApiFallback.class, path = "/arranging/work")
public interface AttendanceDailyRuleApi {


    /**
     * 定时执行初始化下个月固定排班
     */
    @PostMapping("initFixedScheduleRule")
    ActionResult initFixedScheduleRule(@RequestParam(value = "tenantId") String tenantId);


    /**
     * 定时执行初始化下个月固定排班
     */
    @PostMapping("autoGrantBalance")
    ActionResult autoGrantBalance(@RequestParam(value = "tenantId") String tenantId);

    /**
     * 用户是否排班
     *
     * @param tenantId 租户ID
     * @param userId   用户ID
     * @return
     */
    @NoDataSourceBind
    @GetMapping("userIsScheduling")
    ActionResult<Boolean> userIsScheduling(@RequestParam("tenantId") String tenantId, @RequestParam("userId") String userId);

    @PostMapping("userIsSchedulingOrdinary")
    ActionResult<List<String>> userIsSchedulingOrdinary(@RequestBody List<String> organizeIds);
    /**
     * 判断用户指定时间范围内是否排班
     *
     * @param userId 用户ID
     * @param start  开始时间
     * @param end    结束时间
     * @return
     */
    @GetMapping("hasRuleByUserIdAndTime")
    ActionResult<Boolean> hasRuleByUserIdAndTime(@RequestParam("userId") String userId, @RequestParam("start") Date start, @RequestParam("end") Date end);
}
