package org.springblade.thirdparty.mk.feign;

import feign.Response;
import org.springblade.thirdparty.mk.config.MKFeignClientConfig;
import org.springblade.thirdparty.mk.pojo.dto.*;
import org.springblade.thirdparty.mk.pojo.dto.approval.MKApprovalDTO;
import org.springblade.thirdparty.mk.pojo.dto.approval.MKProcessDTO;
import org.springblade.thirdparty.mk.pojo.vo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 *  MK接口
 * @author bfhuange
 * @date 2024/9/11
 */
@FeignClient(name = "MK", url = "${thirdParty.mk.baseUrl}", configuration = MKFeignClientConfig.class)
public interface IMKClient {

    /**
     *  获取mk token
     * @param param
     * @return
     */
    @PostMapping("${thirdParty.mk.getTokenUrl:/authapi/getToken}")
    MKTokenVO getToken(@RequestBody MKTokenDTO param);

    /**
     *  流程提交接口
     * @param param
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.processSubmitUrl:/openapi/sys-lbpm/sysLbpmProcess/openSupport/submit}")
    MKResultVO<String> processSubmit(@RequestBody MKProcessCreateDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  流程执行接口
     * @param param
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.processExecuteUrl:/openapi/sys-lbpm/sysLbpmProcess/openSupport/execute}")
    MKResultVO<Void> processExecute(@RequestBody MKProcessExecuteDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  流程删除接口
     * @param param
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.processDeleteUrl:/openapi/sys-lbpm/sysLbpmProcess/openSupport/delete}")
    MKResultVO<Void> processDelete(@RequestBody MKProcessDeleteDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  获取流程当前节点详情
     * @param param
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.getCurrentNodesUrl:/openapi/sys-lbpm/sysLbpmProcess/openSupport/getCurNodesInfo}")
    MKResultVO<List<MKNodeVO>> getCurrentNodes(@RequestBody MKCurrentNodesDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  获取节点处理人信息
     * @param param
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.getNodeHandlersUrl:/openapi/sys-lbpm/sysLbpmProcess/openSupport/getNodeHandlerInfos}")
    MKResultVO<MKAllHandlerVO> getNodeHandlers(@RequestBody MKNodeHandlersDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  根据流程模板获取该模板下所有的人工节点信息
     * @param param
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.getManualNodeUrl:/openapi/sys-lbpm/sysLbpmTemplate/openSupport/getManualNode}")
    MKResultVO<List<MKManualNodeVO>> getManualNode(@RequestBody MKManualNodeDTO param, @RequestParam("access_token") String accessToken);

    //===========================人员组织推送接口============================================

    /**
     *  推送公司部门
     * @param param
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.pushOrgDeptUrl:/openapi/sys-org/v2/push/orgDept}")
    MKResultVO<Object> pushOrgDept(@RequestBody MKPushDTO<MKPushOrgDeptDTO> param, @RequestParam("access_token") String accessToken);

    /**
     *  推送人员
     * @param param
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.pushPersonUrl:/openapi/sys-org/v2/push/person}")
    MKResultVO<Object> pushPerson(@RequestBody MKPushDTO<MKPushPersonDTO> param, @RequestParam("access_token") String accessToken);

    //===========================认证相关接口========================================

    /**
     *  获取oauth 认证code
     * @param param
     */
    @PostMapping("${thirdParty.mk.getOAuthCodeUrl:/openapi/sys-oauth/openOauth/getCode}")
    MKResultVO<MKOAuthCodeVO> getOAuthCode(@RequestBody MKOAuthCodeDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  获取oauth token
     * @param param
     */
    @PostMapping("${thirdParty.mk.getOAuthTokenUrl:/openapi/sys-oauth/openOauth/getToken}")
    MKResultVO<MKOAuthTokenVO> getOAuthToken(@RequestBody MKOAuthTokenDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  获取oauth 用户信息
     * @param param
     * @return
     */
    @PostMapping("${thirdParty.mk.getOAuthUserInfoUrl:/openapi/sys-oauth/openOauth/getUserInfo}")
    MKResultVO<MKOAuthUserVO> getOAuthUserInfo(@RequestBody MKOAuthUserDTO param, @RequestParam("access_token") String accessToken);

    //===========================审批记录相关接口========================================
    /**
     *  流程审批意见信息API - 获取审批意见接口
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.queryAuditNotesUrl:/openapi/sys-lbpm/lbpmAuditNote/openSupport/listNote}")
    MKResultVO<List<MKAuditNoteVO>> queryAuditNotes(@RequestBody MKAuditNoteDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  流程卡片操作API- 获取抄送人列表
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.querySenderListUrl:/openapi/sys-lbpm/sysLbpmProcessCard/openSupport/getSenderList}")
    MKResultVO<MKPageVO<MKSenderVO>> querySenderList(@RequestBody MKSenderDTO param, @RequestParam("access_token") String accessToken);

    /**
     *  附件文件流操作开放API- 附件下载
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.downloadFileUrl:/openapi/sys-attach/fileStream/download}")
    Response downloadFile(@RequestBody MKFileDTO param, @RequestParam("access_token") String accessToken);

    //===========================待办相关接口========================================
    /**
     *  审批中心-流程门户API-审批中心查询列表
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.queryApprovalListUrl:/openapi/lbpm-approval/lbpmApproval/portal/list}")
    MKResultVO<MKPageVO<MKApprovalVO>> queryApprovalList(@RequestBody MKApprovalDTO param, @RequestParam("access_token") String accessToken);
    /**
     *  流程实例操作API-列表
     * @param accessToken
     * @return
     */
    @PostMapping("${thirdParty.mk.queryProcessListUrl:/openapi/sys-lbpm/sysLbpmProcess/openSupport/list}")
    MKResultVO<MKPageVO<MKProcessVO>> queryProcessList(@RequestBody MKProcessDTO param, @RequestParam("access_token") String accessToken);
}
