package com.chinaweal.aiccs.outside.api;

import com.chinaweal.aiccs.door.dto.XCOrgDTO;
import com.chinaweal.aiccs.door.dto.XCRoleDTO;
import com.chinaweal.aiccs.door.dto.XCUserRoleDTO;
import com.chinaweal.aiccs.door.entity.TUserportal;
import com.chinaweal.aiccs.outside.interceptor.XCDoorInterceptor;
import com.chinaweal.aiccs.outside.util.DoorResult;
import com.chinaweal.aiccs.outside.vo.DoorTask;
import com.dtflys.forest.annotation.*;
import com.dtflys.forest.http.ForestResponse;

import java.util.List;
import java.util.Map;

/**
 * 门户的接口
 */
@BaseRequest(baseURL = "${xcDoorBaseUrl}", interceptor = XCDoorInterceptor.class)
public interface XCDoorApi {

    /**
     * cas 获取单点登录票据校验 (信创门户)
     */
    @GetRequest(url = "${xcDoorCasUrl}/cas/serviceValidate?service={service}&ticket={ticket}", headers = "Content-Type:application/x-www-form-urlencoded")
    String casServiceValidate(@Var("service") String service, @Var("ticket") String ticket);

    // 待办推送
    @Post(url = "/esb/api/portal/tasks/send", async = true)
    void tasksSend(@JSONBody DoorTask doorTask);

    // 待办更新
    @Post(url = "/esb/api/portal/tasks/update", async = true)
    void tasksSendUpdate(@JSONBody DoorTask doorTask);

    // 获取所有用户
    @Get(url = "/esb/api/portal/users/all")
    ForestResponse<DoorResult<List<TUserportal>>> usersAll();

    // 根据id获取用户信息
    @Get(url = "/esb/api/portal/users/queryById")
    ForestResponse<DoorResult<TUserportal>> queryUserById(@Query("id") String id);

    // 根据机构ID获取组织机构数据
    @Get(url = "/esb/api/portal/orgs/queryById")
    ForestResponse<DoorResult<XCOrgDTO>> queryOrgById(@Query("id") String id);

    // 根据角色ID获取角色数据
    @Get(url = "/esb/api/portal/roles/queryById")
    ForestResponse<DoorResult<XCRoleDTO>> queryRoleById(@Query("id") String id);

    // 根据updateAfter获取用户信息
    @Get(url = "/esb/api/portal/users")
    ForestResponse<DoorResult<List<TUserportal>>> usersByUpdateAfter(@Query("updateAfter") long updateAfter);

    // 根据updateAfter等条件获取用户角色关联信息
    @Get(url = "/esb/api/portal/users/roles")
    ForestResponse<DoorResult<List<XCUserRoleDTO>>> userRolesByCondition(@Query("updateAfter") long updateAfter, @Query("roleId") String roleId, @Query("appId") String appId);

    // 根据userId获取用户角色关联信息
    @Get(url = "/esb/api/portal/roles/queryByUserId")
    ForestResponse<DoorResult<List<XCUserRoleDTO>>> userRolesByUserId(@Query("id") String userId, @Query("appId") String appId);

    // Post接口哟
    @Post(url = "${url}")
    ForestResponse<DoorResult<?>> testPost(@Var("url") String url,
                                           @JSONBody Map paramMap);

    // Get接口哟
    @Get(url = "${url}${param}")
    ForestResponse<DoorResult<?>> testGet(@Var("url") String url,
                                           @Var("param") String param);
}
