package com.prolog.rdc.tms.rmi.hystrix;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.prolog.cs.platform.power.model.Organization;
import com.prolog.cs.platform.power.model.enterprise.User;
import com.prolog.framework.authority.core.dto.UserDTO;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.product.core.tools.util.LogUtils;
import com.prolog.rdc.tms.rmi.feign.UserFeign;

import feign.hystrix.FallbackFactory;

/**
 * 
 *
 * 用户服务调用
 *
 * @className :UserHystrix
 * @author :fanzw
 * @creationTime :2022/05/18
 * @description :
 *
 * @modifier :fanzw
 * @modifyTime :2022/05/18
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Component
public class UserHystrix implements FallbackFactory<UserFeign> {

	private final Logger logger = LoggerFactory.getLogger(UserHystrix.class);

	@Override
	public UserFeign create(Throwable cause) {
		if (null != cause && StringUtils.hasLength(cause.getMessage())) {
			LogUtils.error(logger, cause.getMessage(), cause);
		}

		return new UserFeign() {
			@Override
			public RestMessage<List<User>> usersByRoleId(Integer pageNum, Integer pageSize, String roleId) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|根据角色ID查询用户信息|usersByRoleId】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<Organization>> search(String parentId, String name, String code, String enterpriseId) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|根据code/name查询部门信息|search】请求服务失败！", null);
			}

			@Override
			public RestMessage<Organization> getById(String id) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|根据ID查询部门|getById】请求服务失败！", null);
			}

			@Override
			public RestMessage<String> addTmsUser(User user) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|用户信息注册|addTmsUser】请求服务失败！", null);
			}

			@Override
			public RestMessage<UserDTO> getPlatformUserByUserName(String username, String userkey) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|根据用户名查询用户信息|getPlatformUserByUserName】请求服务失败！", null);
			}

			@Override
			public RestMessage<Boolean> delEnterpriseUser(String ids) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|删除企业用户|delEnterpriseUser】请求服务失败！", null);
			}

			@Override
			public RestMessage<Boolean> updateEnterpriseUser2(User user) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|修改企业用户|updateEnterpriseUser2】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<Organization>> selectByUserId(String userId) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|查询用户部门列表|selectByUserId】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<User>> getUserByIdList(String userIdList) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|根据用户id集合查询用户信息|getEnterpriseUserByUserIds】请求服务失败！", null);
			}

			@Override
			public RestMessage<List<User>> getEnterpriseUsers(Integer pageNum, Integer pageSize, String name, String enterpriseId, String companyName, String employeeNum, Integer type, String userCategory, String companyId) {
				return RestMessage.newInstance(false, "【service-platform-power-base-mysql-rdc|根据用户id集合查询用户信息|getEnterpriseUsers】请求服务失败！", null);
			}
		};
	}
}