package jnpf.attendance.fallback;

import jnpf.attendance.AttendanceDailyRuleApi;
import jnpf.base.ActionResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

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

/**
 * 获取用户信息Api降级处理
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * @date 2021-03-24
 */
@Component
@Slf4j
public class AttendanceDailyRuleApiFallback implements FallbackFactory<AttendanceDailyRuleApi> {
    @Override
    public AttendanceDailyRuleApi create(Throwable cause) {
        cause.printStackTrace();
        return new AttendanceDailyRuleApi() {
            @Override
            public ActionResult initFixedScheduleRule(String tenantId) {
                return ActionResult.fail("请求失败");
            }

            @Override
            public ActionResult autoGrantBalance(String tenantId) {
                return ActionResult.fail("请求失败");
            }

            @Override
            public ActionResult<Boolean> userIsScheduling(String tenantId, String userId) {
                return ActionResult.fail("请求失败");
            }

            @Override
            public ActionResult<List<String>> userIsSchedulingOrdinary(List<String> organizeId) {
                return ActionResult.fail("请求失败");
            }

            @Override
            public ActionResult<Boolean> hasRuleByUserIdAndTime(String userId, Date start, Date end) {
                return ActionResult.fail("请求失败");
            }
        };
    }
}
