/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.feign.client.fallbackfactory;

import com.crunii.micro.common.dto.PageReq;
import com.crunii.micro.common.dto.PageRsp;
import com.crunii.micro.common.dto.Result;
import com.crunii.micro.domain.dto.LoginInfoDto;
import com.crunii.micro.domain.dto.Worker;
import com.crunii.micro.domain.entity.main.TsmPropertyValue;
import com.crunii.micro.feign.client.SysService;
import com.crunii.micro.feign.client.dto.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * @author shenhs create 2023/7/6 19:36
 */
public class SysServiceFallbackFactory implements FallbackFactory<SysService> {
	private static final Logger logger = LoggerFactory.getLogger(SysServiceFallbackFactory.class);

	@Override public SysService create(Throwable cause) {
		logger.error("fallback; exception was: {}", cause.toString());
		logger.error("fallback; reason was: {}", cause.getMessage());
		return new SysService() {

			@Override public Result<Worker> login(LoginDto loginDto) {
				return Result.ofFail("登录失败");
			}

			@Override public Result<Worker> smsCodeLogin(LoginPhoneDto loginDto) {
				return Result.ofFail("验证码登录失败");
			}

			@Override public Result<String> getPhoneCode(SmsCodeSend smsCodeSend) {
				return Result.ofFail("发送短信验证码失败");
			}

			@Override
			public Result<List<TsmPropertyValue>> getValuesByCode(String propCode) {
				return Result.ofFail("通过属性编码获取属性值列表失败");
			}

			@Override
			public Result<String> createValue(TsmPropertyValue valueC) {
				return Result.ofFail("创建属性值失败");
			}

			@Override
			public Result<String> updateValue(TsmPropertyValue valueC) {
				return Result.ofFail("修改属性值失败");
			}

			@Override
			public Result<String> delValue(String propCode, Integer valueId) {
				return Result.ofFail("删除属性值失败");
			}

			@Override
			public Result<WorkerCreateDTO> createWorker(WorkerC workerC) {
				return Result.ofFail("新增失败");
			}

			@Override
			public Result<Integer> createWorkerInfo(WorkerC workerC) {
				return Result.ofFail("新增失败");
			}

			@Override
			public Result<List<OrgNode>> getOrgChildrenByParentOrgId(Long parentOrgId) {
				return Result.ofFail("通过父组织Id获取子组织(数据权限过滤)失败");
			}
			@Override
			public Result<Worker> loginExternalMobile(LoginInfoDto loginInfoDto) {
				return Result.ofFail("登录失败");
			}
			
			@Override
			public Result<Integer> createWorkerCustomPwd(WorkerC workerC) {
				return Result.ofFail("新增失败");
			}
			
		};
	}
}
