package com.hotent.base.feign;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hotent.base.cache.annotation.Cacheable;
import com.hotent.base.conf.DecryptingFeignConfig;
import com.hotent.base.constants.CacheKeyConst;
import com.hotent.base.entity.URIEntity;
import com.hotent.base.feign.dto.PortalDataSensitive;
import com.hotent.base.feign.impl.PortalFeignServiceFactory;
import com.hotent.base.jms.Notice;
import com.hotent.base.model.CommonResult;
import com.hotent.base.query.QueryFilter;
import io.swagger.annotations.ApiParam;
import org.apache.http.client.ClientProtocolException;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;


/**
 *
 * @author liyg
 *
 */
@FeignClient(name="eip-portal",fallbackFactory=PortalFeignServiceFactory.class, configuration= DecryptingFeignConfig.class, primary = false)
public interface PortalFeignService {

	@RequestMapping(value="/biz/sysRoleAuth/v1/getMethodRoleAuth",method=RequestMethod.GET)
	public List<HashMap<String,String>> getMethodRoleAuth();

	@RequestMapping(value="/biz/sysRoleAuth/v1/removeByRoleAlias",method=RequestMethod.DELETE)
	public CommonResult<String> removeByRoleAlias(@RequestParam(value="roleAlias", required = true) String roleAlias);

    @RequestMapping(value="/biz/sysRoleAuth/v1/removeUserMenu",method=RequestMethod.GET)
    public CommonResult<String> removeUserMenu();

	@RequestMapping(value="/biz/sysProperties/v1/getByAlias",method=RequestMethod.GET)
	public String getPropertyByAlias(@RequestParam(value="alias", required = true)String alias);

    @RequestMapping(value="/biz/sysProperties/v1/getByAlias",method=RequestMethod.GET)
    @Cacheable(value = CacheKeyConst.EIP_SYS_PROPS, key="#alias")
    public String getByAlias(@RequestParam(value="alias", required = true)String alias,
                             @RequestParam(value="defaultValue", required = true)String defaultValue) ;

	/**
	 * 根据别名获取系统分类
	 *
	 */
	 @RequestMapping(value="/biz/sysType/v1/getJson",method=RequestMethod.GET)
	 public ObjectNode getSysTypeById(@RequestParam(value="id", required = true)String id);

	/**
	 * 根据别名和租户ID获取系统分类
	 *
	 */
	@RequestMapping(value="/biz/sysType/v1/getJson",method=RequestMethod.GET)
	public ObjectNode getSysTypeById(@RequestParam(value="id", required = true)String id , @RequestParam(value = "tenantId", required = true) String tenantId);

	 /**
	 * 根据queryFilter获取系统分类。不带分页
	 */
	 @RequestMapping(value="/biz/sysType/v1/list",method=RequestMethod.POST)
	 public ObjectNode getAllSysType(@RequestBody(required = true)QueryFilter queryFilter);

	 /**
	 * 发送消息
	 * @param notice
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
     @RequestMapping(value="/portal/jms/v1/sendNoticeToQueue",method=RequestMethod.POST)
	 public CommonResult<String> sendNoticeToQueue(@RequestBody(required = true)Notice notice);

     /**
 	 * 发送消息到队列中
 	 * @param model
 	 * @return
 	 * @throws ClientProtocolException
 	 * @throws IOException
 	 */
     @RequestMapping(value="/portal/jms/v1/sendToQueue",method=RequestMethod.POST)
 	 public CommonResult<String> sendToQueue(@RequestBody(required = true)ObjectNode model);


     /**
 	 * 根据用户，指定工时，指定开始时间,计算任务实际完成时间
 	 * @param userId		用户ID
 	 * @param startTime		开始时间
 	 * @param time			工时(分钟)
 	 * @return				完成时间
 	 * @throws Exception
 	 */
     @RequestMapping(value="/portal/calendar/v1/getEndTimeByUser",method=RequestMethod.POST)
 	 public String getEndTimeByUser(@RequestBody(required = true)ObjectNode param);


     /**
 	 * 根据用户开始时间和结束时间，获取这段时间的有效工时
 	 * @param model
 	 * @return
 	 * @throws ClientProtocolException
 	 * @throws IOException
 	 */
     @RequestMapping(value="/portal/calendar/v1/getWorkTimeByUser",method=RequestMethod.POST)
 	 public Long getWorkTimeByUser(@RequestBody(required = true)ObjectNode param);


     /**
 	 * 获取用户已读未读消息
 	 * @param account
 	 * @return
 	 * @throws Exception
 	 */
     @RequestMapping(value="/innermsg/messageReceiver/v1/getMessBoxInfo",method=RequestMethod.GET)
 	 public ObjectNode getMessBoxInfo(@RequestParam(value="account", required = true)String account);


     /**
      * 根据数据源别名，获取数据源的设置信息
      * @param alias
      * @return
      */
     @RequestMapping(value="/biz/sysDataSource/v1/getBeanByAlias", method=RequestMethod.GET)
 	 public JsonNode getBeanByAlias(@RequestParam(value="alias", required = true) String alias);

     /**
     * 根据流水号别名获取下一个流水号
     * @param alias
     * @return
     */
    @RequestMapping(value="/biz/identity/v1/getNextIdByAlias", method=RequestMethod.GET)
	public String getNextIdByAlias(@RequestParam(value="alias", required = true) String alias);

	/**
	 * 根据流水号别名和数量批量获取流水号
	 *
	 * @param offset 个数
	 * @param alias 别名
	 * @return
	 */
	@RequestMapping(value = "/biz/identity/v1/getBatchByAlias", method = RequestMethod.GET)
	public CommonResult<List<String>> getIdentityBatch(@RequestParam(value = "alias") String alias, @RequestParam(value = "offset") Integer offset);

    /**
   	 * 根据queryFilter获取新闻公告
   	 */
   	 @RequestMapping(value="/portal/messageNews/v1/list",method=RequestMethod.POST)
   	 public ObjectNode getMessageNews(@RequestBody(required = true)JsonNode queryFilter);

     /**
	 * 根据新闻公告id发布新闻公告
	 */
	 @RequestMapping(value="/portal/messageNews/v1/publicMsgNews",method=RequestMethod.POST)
	 public ObjectNode publicMsgNews(@RequestBody(required = true)String array);

	 @RequestMapping(value="/sys/sysLogsSettings/v1/getSysLogsSettingStatusMap",method=RequestMethod.GET)
	 public Map<String, String> getSysLogsSettingStatusMap();

	 /**
 	 * 根据权限数据判断当前人是否有权限
 	 * @param permssionJson
 	 * @return
 	 * @throws Exception
 	 */
     @RequestMapping(value="/biz/authUser/v1/calcPermssion",method=RequestMethod.GET)
 	 public boolean calcPermssion(@RequestParam(value="permssionJson", required = true)String permssionJson);

     /**
  	 * 根据权限数据判断当前人是否有权限
  	 * @param permssionJson
  	 * @return
  	 * @throws Exception
  	 */
      @RequestMapping(value="/biz/authUser/v1/calcAllPermssion",method=RequestMethod.GET)
  	 public ObjectNode calcAllPermssion(@RequestParam(value="permssionJson", required = true)String permssionJson);

	@RequestMapping(value="sys/authUser/v1/getAuthorizeIdsByUserMap", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	public List<String> getAuthorizeIdsByUserMap(@RequestParam(value="objType" , required = true)String objType) ;

	@RequestMapping(value="sys/authUser/v1/getUserRightMap", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	public Map<String,Set<String>> getUserRightMap() ;

	@RequestMapping(value="sys/authUser/v1/getUserIdRightMap", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	public Map<String,Set<String>> getUserIdRightMap(@RequestParam(value="userId" , required = true)String userId) ;


	@RequestMapping(value="/portal/sysExternalUnite/v1/getToken", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	public String getToken(@RequestParam(value="type" , required = true) String type);

	/**
	 * 创建租户时 初始化租户数据
	 * @param tenantId
	 * @return
	 */
	@RequestMapping(value="/portal/tenantInitData/v1/initData", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	public CommonResult<String> initData(@RequestParam(value="tenantId" , required = true) String tenantId);

	@RequestMapping(value="/portal/sysExternalUnite/v1/getUserInfoUrl", method=RequestMethod.GET, produces={"application/json; charset=utf-8" })
	public String getUserInfoUrl(@RequestParam(value="type" , required = true) String type,@RequestParam(value="code" , required = true) String code);

	@RequestMapping(value="/infra/file/v1/wordPrint",method=RequestMethod.POST)
	public String wordPrint(@RequestBody ObjectNode objectNode) ;

	@RequestMapping(value="/portal/portalDataSensitive/v1/getByDsNameAndTableName",method=RequestMethod.GET)
	@Cacheable(value = CacheKeyConst.EIP_SYS_DATA_SENSITIVE, key="#root.args[1].toLowerCase()")
	public CommonResult<PortalDataSensitive> getPortalDataSensitive(@RequestParam(value="dataSourceAlias" , required = false) String dataSourceAlias, @RequestParam(value="tableName" , required = true) String tableName);

	@RequestMapping(value="/infra/file/v1/getFileBytesById",method=RequestMethod.GET)
	public byte[] getFileBytesById(@RequestParam(value="fileId", required = true)String fileId);

	@RequestMapping(value="/infra/file/v1/fileGet",method=RequestMethod.GET)
	ObjectNode fileGet(@RequestParam(value="id") String id);

	 /**
	 * 根据组别名和分类别名获取系统分类
	 *
	 */
	 @RequestMapping(value="/biz/sysType/v1/getSysTypeByType",method=RequestMethod.GET)
	 public ObjectNode getSysTypeByType(@RequestParam(value="group", required = true)String group,@RequestParam(value="typeKey", required = true)String typeKey);

	@RequestMapping(value="/portal/sysExternalUnite/v1/getDingtalkIdFromScanCode",method=RequestMethod.GET)
	public CommonResult<String> getDingtalkIdFromScanCode(@RequestParam(value="code", required = true)String code);

	@RequestMapping(value="/portal/sysExternalUnite/v1/getWxWorkIdFromScanCode",method=RequestMethod.GET)
	public CommonResult<String> getWxWorkIdFromScanCode(@RequestParam(value="code", required = true)String code);


	// 验证系统编码是否正确
	@RequestMapping(value = "/portalBizSystem/v1/checkSysCode",method = RequestMethod.GET)
	public CommonResult checkSysCode(@RequestParam(value = "sysCode")String sysCode,@RequestParam(value = "secretKey",required = false)String secretKey);

	// 获取三方登录跳转地址
	@RequestMapping(value = "/portalBizSystem/v1/getPortalBizSystemUrlBySysCode",method = RequestMethod.GET)
	public CommonResult getPortalBizSystemUrlBySysCode(@RequestParam(value = "sysCode")String sysCode);

	// 验证系统编码是否正确和URI是否被授权
	@RequestMapping(value = "/portalBizSystem/v1/checkSysCodeAndUri",method = RequestMethod.GET)
	public CommonResult checkSysCodeAndUri(@RequestParam(value = "sysCode")String sysCode,@RequestParam(value = "secretKey",required = false)String secretKey,
									 @RequestParam(value = "uri")String uri,@RequestParam(value = "tenantId")String tenantId);

	// 根据系统编码获取外部系统的配置信息，用于远程调用
	@RequestMapping(value = "/portalBizSystem/v1/getPortalBizSystemBySysCode",method = RequestMethod.GET)
	public CommonResult getPortalBizSystemBySysCode(@RequestParam(value = "sysCode",required = true)String sysCode);

	// 远程调用取得系统信息（包含外部系统及微服务系统）
	@RequestMapping(value = "/portalBizSystem/v1/getServiceList",method = RequestMethod.POST)
	public List<ObjectNode> getServiceList();

	// 远程调用取得系统信息（包含外部系统及微服务系统）
	@RequestMapping(value = "/portalBizSystem/v1/getList",method = RequestMethod.POST)
	public List<ObjectNode> getList();

	// 把消息转发到外部系统对应的Queue
	@RequestMapping(value = "/portalMsgSendLog/v1/sendMsgToExternalQueue",method = RequestMethod.POST)
	public CommonResult sendMsgToExternalQueue(@RequestBody Notice notice,@RequestParam(value = "sysCode")String sysCode);

	/**
	 * 根据ID获取外部系统信息
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/portalBizSystem/v1/getDetail",method = RequestMethod.GET)
	public ObjectNode getBizSystem(@RequestParam(value="id", required = true)String id);

	/**
	 * 根据code获取外部系统信息
	 * @param code 外部系统编码
	 * @return 外部系统信息
	 */
	@RequestMapping(value = "/portalBizSystem/v1/getPortalBizSystemByCode",method = RequestMethod.GET)
	public CommonResult getBizSystemByCode(@RequestParam(value="code", required = true)String code);

	/**
	 * 用户变更信息推送给三方
	 * @return
	 */
	@RequestMapping(value = "/portalBizSystem/v1/pushThreePartyByUserChange",method = RequestMethod.POST)
	public CommonResult pushThreePartyByUserChange(@RequestParam(value = "type")String type,
												   @RequestParam(value = "userId")String userId);

	/**
	 * 根据用户id 删除所有的外部系统 用户关联信息
	 * @return
	 */
	@RequestMapping(value = "/portalBizSystemOrgAuth/v1/pushThreePartyByUserDelete",method = RequestMethod.POST)
	public CommonResult pushThreePartyByUserDelete(@RequestParam(value = "userId")String userId);

	/**
	 * 根据alias调用接口
	 * @param alias
	 * @param queryData
	 * @param resultData
	 * @param paramData
	 * @return
	 */
	@RequestMapping(value = "/portal/portalInterfaceManager/v1/doQuery",method = RequestMethod.GET)
	public Object executeIntefaceJob(@RequestParam(value="alias", required = true)String alias, @RequestParam(value="queryData", required = false) String queryData, @RequestParam(value="resultData", required = false) String resultData ,@RequestParam(value="paramData", required = false) String paramData);

	/**
	 * 根据alias执行服务编排
	 * @param alias
	 * @return
	 */
	@RequestMapping(value = "/portal/portalServiceChoreography/v1/execute",method = RequestMethod.GET)
	public Object executeServiceJob(@RequestParam(value="alias", required = true)String alias, @RequestParam(value="paramData", required = false) String paramData);

	/**
	 * 保存服务调用日志
	 * @param objectNode
	 * @return
	 */
	@RequestMapping(value = "/portal/portalServiceLog/v1/saveLog",method = RequestMethod.POST)
	public CommonResult<String> saveServiceLog(@RequestBody(required = true)ObjectNode objectNode);

	/**
	 * 保存定时任务触发器
	 * @param param
	 * @return
	 */
	@RequestMapping(value="/job/scheduler/v1/saveOrDeleteTrigger",method=RequestMethod.POST)
	public ObjectNode saveOrDeleteTrigger(@RequestBody(required = true)ObjectNode param);

	/**
	 * 通过图表id修改系统模块相关信息
	 * @param param
	 * @return
	 */
	@RequestMapping(value="/biz/sysModule/v1/updateSysModuleByCustomId",method=RequestMethod.GET)
	public CommonResult updateSysModuleByCustomId(@RequestParam(value="customChartId", required = true)String  customChartId,@RequestBody(required = true)ObjectNode objectNode);

    @RequestMapping(value="/base/common/getMicroURIEntity",method=RequestMethod.GET)
    public Set<URIEntity> getMicroURIEntity();

    @RequestMapping(value="/portal/menuBookmark/v1/removeBookmarkByMenuIds",method=RequestMethod.POST)
    public void removeBookmarkByMenuIds(@RequestBody List<String> menuIds);



	/**
	 * 根据组织id获取组织钉钉参数配置
	 * @return
	 */
	@RequestMapping(value="/portal/appModel/v1/getDingUserByCode",method=RequestMethod.GET)
	public JsonNode getDingUserByCode(@RequestParam(value="code",required=true) String code,@RequestParam(value="corpId",required=true) String corpId,@RequestParam(value="appId",required=true) String appId);


	/**
	 * 获取待办和钉钉关联数据
	 * @return
	 */
	@RequestMapping(value="/portal/dingTodoTask/v1/queryEntityById",method=RequestMethod.GET)
	public ArrayNode queryEntityById(@RequestParam(value="taskId",required=true) String taskId);

	/**
	 * 获取待办和钉钉关联数据
	 * @return
	 */
	@RequestMapping(value="/portal/dingTodoTask/v1/saveEntity",method=RequestMethod.GET)
	public void saveTodoDataEntity(@RequestParam(value="dingTodoTaskId", required = true) String dingTodoTaskId,
								   @RequestParam(value="dingtalkIds", required = true) String dingtalkIds,
								   @RequestParam(value="userDingUnionId", required = true) String userDingUnionId,
								   @RequestParam(value="taskId", required = true) String taskId,
								   @RequestParam(value="orgId", required = true) String orgId
	);

	/**
	 * 获取未登录用户的应用列表
	 * @return
	 */
	@RequestMapping(value="/portal/appModel/v1/getAppByNoAuth",method=RequestMethod.GET)
	public ArrayNode getAppByNoAuth(@RequestParam(value="typeKey",required=true) String typeKey);

	/**
	 * 获取未登录用户的应用列表
	 * @return
	 */
	@RequestMapping(value="/portal/sysApp/v1/portal/loadMySysAppOftenByNoAuth",method=RequestMethod.GET)
	public ArrayNode loadMySysAppOftenByNoAuth(@RequestParam(value="type",required=true) String type);


	@RequestMapping(value="/portal/appModel/v1/getJson", method=RequestMethod.GET)
	public ObjectNode getAppModelById(@RequestParam(value="id",required=true) String id);

	@RequestMapping(value="/portal/sysApp/v1/getDetail", method=RequestMethod.GET)
	public ObjectNode getSysApplById(@RequestParam(value="id",required=true) String id);

	/**
	 * 获取未登录用户的应用列表
	 * @return
	 */
	@RequestMapping(value="/innermsg/messageReceiver/v1/listNoUser",method=RequestMethod.POST)
	public ObjectNode messagelistNoUser(@RequestBody(required = true)QueryFilter queryFilter);


	/**
	 * @description  获取第三方系统授权的用户和组织id集合
	 * @author  yangzibin
	 * @date    2024/7/13 14:57
	 * @param	sysCode
	 * @param	type
	 * @param	tenantId
	 * @param	demId
	 * @return  com.fasterxml.jackson.databind.node.ArrayNode
	 */
	@RequestMapping(value="/portalBizSystemOrgAuth/v1/getOrgIdList",method=RequestMethod.GET)
	public ArrayNode getOrgIdList(@RequestParam(value="sysCode",required=true) String sysCode,
								  @RequestParam(value="type",required=true) String type,
								  @RequestParam(value="tenantId",required=false) String tenantId,
								  @RequestParam(value="demId",required=false) String demId);

	/**
	 * @description  获取字典
	 * @author  yangzibin
	 * @date    2025/5/29 17:25
	 * @param	typeKey
	 * @return  com.fasterxml.jackson.databind.node.ObjectNode
	 */
	@RequestMapping(value="/biz/dataDict/v1/getByTypeKey", method=RequestMethod.GET)
	public ArrayNode getByTypeKey(@RequestParam(value="typeKey",required=true) String typeKey);


}
