import { request } from '/@/utils/service';
import { UserPageQuery, AddReq, EditReq, InfoReq } from '@fast-crud/fast-crud';
import { Session } from '/@/utils/storage';
import { time } from 'console';


export function GetDocumentList(query: any) {
  return request({
    url: 'api/system/job/questions',
    method: 'get',
    params: {...query,tenant_id:Session.get('tenant_id')},
  });
}

export function AddDocument(obj: AddReq) {
  return request({
    url: 'api/system/job/add_question',
    method: 'post',
    data: {...obj,tenant_id:Session.get('tenant_id')},
  });
}

/* 文档管理编辑 /api/system/document/{id}/*/
export function UpdateDocument(obj: any) {
	return request({
		url: '/api/system/interview_question/update',
		method: 'post',
		data:{...obj,tenant_id:Session.get('tenant_id')}
	});
}

/* 文档管理查看 /api/system/document/{id}/*/
export function GetDocument(id: any) {
	return request({
		url: '/api/system/document/'+id+ '/',
		method: 'get',
	});
}

/* 文档管理删除 /api/system/document/{id}/*/
export function DelDocument(data:any) {
	return request({
		url: 'api/system/job/delete_question',
		method: 'post',
		data
	});
}

// 获取文档树结构
export function GetDocumentTree(query: any) {
  return request({
    url: '/api/system/job/list',
    method: 'get',
    params: {...query,tenant_id:Session.get('tenant_id')},
  });
}

// 添加文档分类
export function AddDocumentCategory(data: any) {
  return request({
    url: '/api/system/document-categories/',
    method: 'post',
    data:{...data,tenant_id:Session.get('tenant_id')}
  });
}

// 更新文档分类
export function UpdateDocumentCategory(data: any) {
  return request({
    url: `/api/system/document-categories/${data.id}/`,
    method: 'put',
    data:{...data,tenant_id:Session.get('tenant_id')}
  });
}

// 删除文档分类
export function DeleteDocumentCategory(id: any) {
  return request({
    url: `/api/system/document-categories/${id}/`,
    method: 'delete'
  });
}

// 添加获取面试问题的方法
export function GetInterviewQuestions(params: any, timeout = 60000) {
    return request({
        url: '/api/system/interview_question/list',
        method: 'get',
        params,
        timeout
    });
}

// 添加更新排序的API函数
export function UpdateSequence(data:any) {
  return request({
    url: '/api/system/job/update_question_sequence_numbers',
    method: 'post',
    data
  });
}

// 获取问题类型
export function GetQuestionTypeList() {
	return request({
		url: '/api/wechat/question_type_enums',
		method: 'get'
	});
}

// 添加 UpdateInterviewQuestion 函数到 API 文件
export const UpdateInterviewQuestion = (params: any) => {
  return request({
    url: '/api/system/interview_question/update',
    method: 'post',
    data: params
  });
};

/* 分类列表 */
export function GetCategoryList(query: UserPageQuery) {
	return request({
		url: '/api/system/question_category/list',
		method: 'get',
		params: {...query,tenant_id:Session.get('tenant_id')},
	});
}
/* 标签列表 */
export function GetTagList(query: UserPageQuery) {
	return request({
		url: '/api/system/question_tag/list',
		method: 'get',
		params: {...query,tenant_id:Session.get('tenant_id')},
	});
}
/* 公共列表 */
export function GetPublicList(query: any) {
	return request({
		url: '/api/system/interview_question/list',
		method: 'get',
    timeout: 60000,
		params: {...query,tenant_id:Session.get('tenant_id')},/* :Session.get('tenant_id').tenant_id || ,tenant_id:'Session.get('tenant_id')' */
	});
}

/* 添加分类 */
export function AddCategory(obj: AddReq) {
	return request({
		url: '/api/system/question_category/create',
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
	});
}
/* 添加标签 */
export function AddTag(obj: AddReq) {
	return request({
		url: '/api/system/question_tag/create',
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
	});
}