import { post, get, del, download } from '@/request/reviewHttp'

interface PageParams{
    page?: number;
    page_size?: number;
    keyword?: number|string;
    include_default?: boolean;
    status?: number;
}

// 2.1 获取审核方案列表
export const reviewPlanPageList:(params: PageParams) => Promise<any> = (params) =>  {
    return get(`/v1/review_plan`, params)
}

// 2.2 新建审核方案
export const saveReviewPlan: (data: any) => Promise<any> = (data) => {
    return post(`/v1/review_plan`, data)
}

// 2.3 编辑审核方案
export const updateReviewPlan: (id: any, data: any) => Promise<any> = (id, data) => {
    return post(`/v1/review_plan/${id}`, data)
}

// 2.4 删除审核方案
export const deleteReviewPlan: (ids: any) => Promise<any> = (ids) => {
    return del(`/v1/review_plan`, undefined, { review_plan_ids: ids })
}

// 2.8 规则清单---待后端提供接口
export const reviewRuleList:(params: PageParams) => Promise<any> = (params) =>  {
    return get(`/v1/review_plan`, params)
}

// 2.8 预览审核方案
export const reviewPlanList:(id:any, params: PageParams) => Promise<any> = (id, params) =>  {
    return get(`/v1/review_plan/${id}`, params)
}

// 2.9 删除规则
export const deleteReviewRule: (ids: any) => Promise<any> = (ids) => {
    return del(`/v1/review_rule`, undefined, { review_rule_ids: ids })
}

// 2.5 新建规则
export const saveReviewRule: (data: any) => Promise<any> = (data) => {
    return post(`/v1/review_rule`, data)
}

// 2.5.5 规则详情
export const getReviewRule: (rule_id: string) => Promise<any> = (rule_id) => {
    return get(`/v1/review_rule/${rule_id}`)
}
// 2.6 编辑规则
export const editReviewRule: (rule_id: string, data: any) => Promise<any> = (rule_id, data) => {
    return post(`/v1/review_rule/${rule_id}`, data)
}

// 2.7 规则测试
export const testRule: (rule: string, content: string) => Promise<any> = (rule, content) => {
    return post(`/v1/review_rule/validate`, { content, rule })
}

// 2.10 上传文档
export const uploadDocument: ( data: any) => Promise<any> = ( data) => {
    return post(`/v1/document`, data)
}

// 2.11 获取文档
export const getDocument: ( document_id: string) => Promise<any> = ( document_id) => {
    return get(`/v1/document/${document_id}`)
}

// 2.12 编辑文档(保存)
export const saveDocumentApi: ( document_id: string, content: any) => Promise<any> = ( document_id, content) => {
    return post(`/v1/document/${document_id}`, { content })
}


// 2.15 获取审核状态
export const getReviewStatus: ( document_id: string) => Promise<any> = ( document_id) => {
    return get(`/v1/document/${document_id}/status`)
}

// 2.16 获取审核结果
export const getReviewResult: ( document_id: string) => Promise<any> = ( document_id) => {
    return get(`/v1/document/${document_id}/result`)
}

// 2.15 审核操作
export const reviewDocument: (document_id: string, action: string) => Promise<any> = (document_id, action) => {
    return post(`/v1/document/${document_id}/review`, { action })
}

// 2.13 文档列表
export const documentPageList:(params: PageParams) => Promise<any> = (params) =>  {
    return get(`/v1/document`, params)
}

// 2.14 删除文档
export const deleteDocument: (ids: any) => Promise<any> = (ids) => {
    return del(`/v1/document`, undefined, { document_ids: ids })
}

// 2.19 设置文档审核方案
export const setReviewPlan: ( document_id: string, data: any) => Promise<any> = ( document_id, data) => {
    return post(`/v1/document/${document_id}/review_plan`, data)
}



// 2.20 审核规则列表
export const reviewRulePageList:(params: PageParams) => Promise<any> = (params) =>  {
    return get(`/v1/review_rule`, params)
}

// 2.21 切换审核规则状态
export const reviewRuleCheckStatus: ( id: any, status: any) => Promise<any> = ( id, status) => {
    return post(`/v1/review_rule/${id}/status`, { status })
}
// 2.17 获取审核方案结果
export const getReviewResultPlan: ( document_id: string, review_plan_id: string) => Promise<any> = ( document_id, review_plan_id) => {
    return get(`/v1/document/${document_id}/result/${review_plan_id}`)
}
// 2.24 审核结果修订
export const revisionOfAuditResults: ( document_id: string, data: any) => Promise<any> = ( document_id, data) => {
    return post(`/v1/document/${document_id}/result`, data)
}

/**
 * 2.15 ai润色
 * @returns
 */
export const downloadDocument: (document_id: string,) => Promise<any> = (document_id) => {
    return download(`/v1/document/${document_id}/download`, 'get')
}

/**
 * 规则抽取预留接口
 * @param data 
 * @returns 
 */
export const saveReference: (data: any) => Promise<any> = (data) => {
    console.log(data)
    return Promise.resolve(true);
}
