package com.ads.common.dingTalk.service;

import com.ads.common.dingTalk.domain.DepartmentDTO;
import com.ads.common.dingTalk.domain.ServiceResult;
import com.ads.common.dingTalk.domain.UserDTO;
import com.dingtalk.api.request.*;
import com.dingtalk.api.response.*;

import java.util.List;

/**
 * @Return
 * @Author hou
 * @Date 2021/9/2 17:04
 * @Destription 调用dingding openApi接口服务
 */
public interface DingTalkService {

    /**
     * 获取accessToken
     *
     * @return
     */
    ServiceResult<String> getAccessToken();

    /**
     * 获取JSTicket, 用于js的签名计算
     *
     * @param accessToken accessToken
     * @return
     */
    ServiceResult<String> getJsTicket(String accessToken);

    /**
     * 获取用户userId
     *
     * @param accessToken accessToken
     * @param authCode    临时授权码
     * @return
     */
    ServiceResult<String> getUserInfo(String accessToken, String authCode);

    /**
     * 根据userId获取用户信息
     *
     * @param accessToken accessToken
     * @param userId      用户userId
     * @return
     */
    ServiceResult<UserDTO> getUser(String accessToken, String userId);

    /**
     * 获取部门列表
     *
     * @param accessToken accessToken
     * @param id          上级部门id，根部门为1
     * @return
     */
    ServiceResult<List<DepartmentDTO>> getDepartmentList(String accessToken, String id);

    /**
     * 获取部门用户列表
     *
     * @param accessToken accessToken
     * @param id          部门id
     * @return
     */
    ServiceResult<List<UserDTO>> getDepartmentUsers(String accessToken, Long id, Long offset, Long size);

    /**
     * 获取角色列表
     *
     * @param accessToken accessToken
     * @return
     */
    ServiceResult<List<OapiRoleListResponse.OpenRoleGroup>> getRoleList(String accessToken);

    /**
     * 根据角色查询用户列表
     *
     * @param accessToken accessToken
     * @param roleId      角色id
     * @return
     */
    ServiceResult<List<OapiRoleSimplelistResponse.OpenEmpSimple>> getRoleUsers(String accessToken, Long roleId);

    /**
     * 创建或更新审批模板
     *
     * @param accessToken accessToken
     * @param request     请求
     * @return
     */
    ServiceResult<OapiProcessSaveResponse.ProcessTopVo> saveProcess(String accessToken, OapiProcessSaveRequest.SaveProcessRequest request);

    /**
     * 删除模板
     *
     * @param accessToken accessToken
     * @param request     请求
     * @return
     */
    ServiceResult deleteProcess(String accessToken, OapiProcessDeleteRequest.DeleteProcessRequest request);

    /**
     * 创建实例
     *
     * @param accessToken accessToken
     * @param request     请求
     * @return
     */
    ServiceResult<OapiProcessWorkrecordCreateResponse.SaveFaceProcessInstanceResponse> createWorkRecord(String accessToken, OapiProcessWorkrecordCreateRequest.SaveFakeProcessInstanceRequest request);

    /**
     * 更新实例状态
     *
     * @param accessToken accessToken
     * @param request     request
     * @return
     */
    ServiceResult updateWorkRecord(String accessToken, OapiProcessWorkrecordUpdateRequest.UpdateProcessInstanceRequest request);

    /**
     * 批量更新实例状态
     *
     * @param accessToken accessToken
     * @param request     request
     * @return
     */
    ServiceResult batchUpdateWorkRecord(String accessToken, OapiProcessWorkrecordBatchupdateRequest.BatchUpdateProcessInstanceRequest request);

    /**
     * 查询部门详情
     *
     * @param deptId
     * @return
     */
    ServiceResult<OapiDepartmentGetResponse> getDeptDetail(String accessToken, Long deptId);

    /**
     * 发送钉钉消息通知
     *
     * @param request
     * @return
     */
    ServiceResult sendDingMessage(String accessToken, OapiMessageCorpconversationAsyncsendV2Request request);

    /**
     * 发起待办
     *
     * @param request
     * @return
     */
    ServiceResult<OapiWorkrecordAddResponse> addWorkRecord(String accessToken, OapiWorkrecordAddRequest request);

    /**
     * 更新待办任务状态
     *
     * @param request
     * @return
     */
    ServiceResult workRecordUpdate(String accessToken, OapiWorkrecordUpdateRequest request);

    /**
     * 分页查询用户待办列表
     *
     * @param request
     * @return
     */
    ServiceResult<OapiWorkrecordGetbyuseridResponse.PageResult> getWorkRecordByUserId(String accessToken, OapiWorkrecordGetbyuseridRequest request);

    /***
     * 创建群会话
     * @param request
     * @return
     */
    ServiceResult<OapiChatCreateResponse> create(OapiChatCreateRequest request);

    /***
     * 根据手机号获取userid
     * @param mobile 手机号
     * @return
     */
    ServiceResult<OapiV2UserGetbymobileResponse> getbymobile(String mobile);

    /***
     *获取群会话信息
     * @param chatId 会话id
     * @return
     */
    ServiceResult<OapiChatGetResponse > getChatInfo(String chatId);
}
