import request from "@/utils/request";
const { api } = process.env.CONFIG;

export interface CorpListProps {
    pageSize: number,
    pageNum: number,
    corpName?: string,
    originCorpId?: string,
    authStatus?: 1 | -1
    configStatus?: 'ING' | 'SUCCESS' | 'ERROR'
}
/**
 * 企微号列表
 * @param data 
 * @returns 
 */
export async function getCorpListApi(data: CorpListProps) {
    return request({
        url: '/corp/list',
        method: 'POST',
        data
    })
}

/**
 * 刷新企微信息
 * @param {*} corpId 
 * @returns 
 */
export function putRefreshCorpApi(corpId: string) {
    return request({
        url: `/corp/refresh/${corpId}`,
        method: 'PUT'
    })
}

/**
 * 修改企业
 * @param corpId 
 * @returns 
 */
export function editCorpApi(data: any) {
    return request({
        url: `/admin/corp/modify`,
        method: 'POST',
        data
    })
}

export interface CorpMailListProps {
    pageNum: number,
    pageSize: number,
    corpId?: string,
    name?: string,
    mpAccountId?:any,
    putUserIds?:any[],
    operUserIds?:any[],
    operAssistantIds?:any[]
}
/**
 * 获取企微通讯录
 * @param {*} data {pageNum: 1, pageSize: 20, corpId: "企微 id(必传)", name: ""}
 * @returns 
 */
export function getCorpMailListApi(data: CorpMailListProps) {
    return request({
        url: `/corpUser/list`,
        method: 'POST',
        data
    })
}

/**获取全部成员*/ 

export function getCorpUserAllListApi(corpId:any) {
    return request({
        url: `/corpUser/allList/${corpId}`,
        method: 'GET',
    })
}
/**
 * 同步企微通讯录
 * @param {*} corpId 
 * @returns 
 */
export function putSyncCorpUser(corpId: string) {
    return request({
        url: `/corp/admin/corpUser/sync/${corpId}`,
        method: 'PUT'
    })
}

interface PutCorpSYsUserProps {
    corpId: string,
    corpUserId: string,
    beginTime: string,
    putUserId: number,
    operUserId: number
}
/**
 * 指派投手运营
 * @param {*} data  {corpId: "", corpUserId: "", beginTime: "2023-01-01", putUserId: 1, operUserId: 2}
 * @returns 
 */
export function putCorpSysUserApi(data: PutCorpSYsUserProps) {
    return request({
        url: `/corpUser/configSysUser`,
        method: 'PUT',
        data
    })
}


export interface ConfigCorpUsersProps {
    corpId: string,
    corpUserRelations: {
        corpUserId: string,
        userIds?: number[]
    }
}
/**
 * 指派运营助手yun
 * @param data 
 * @returns 
 */
export function configCorpUsersApi(data: ConfigCorpUsersProps) {
    return request({
        url: `/corpUser/configCorpUsers`,
        method: 'PUT',
        data
    })
}
/**
 * 批量指派公众号
 * @param data
 * */ 
// export interface 
export function configCorpUserWxApi(data: {
    appId:string,
    appName:string,
    corpId:string,
    corpUserIds:any[],
    platform:string,
}) {
    return request({
        url:api+ `/corpOperation/corpUser/configCorpUsers`,
        method: 'PUT',
        data
    })
}
/**
 * 获取全部公众号列表
*/

export function getAllWxListApi() {
    return request({
        url:api+ `/corpOperation/corpUser/getMpList`,
        method: 'GET',
    })
}

/**
 * 获取已绑定书城公众号列表
 * @returns 
 */
export function getBindMpListApi() {
    return request({
        url:api+ `/corpOperation/corpUser/getBindMpList`,
        method: 'GET',
    })
}
/**
 * 获取公众号变更记录
 * */ 
export function getChangeLogApi(data: {
    corpId:string,
    corpUserId:string
}) {
    return request({
        url:api+ `/corpOperation/corpUser/getMpChangeRecord/${data.corpId}/${data.corpUserId}`,
        method: 'GET',
    })
}