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

/* 获取胜任力标签 */
export function GetCompetencyList(query: UserPageQuery) {
	return request({
		url: '/api/system/competency/list',
		method: 'get',
		params: {...query,tenant_id:Session.get('tenant_id')},
	});
}
/* 获取题库列表 */
export function GetQuestionList(query: PageQuery) {
	return request({
		url: '/api/system/interview_question/list',
		method: 'get',
		params: {...query,tenant_id:Session.get('tenant_id')},/* :Session.get('tenant_id').tenant_id || ,tenant_id:'1' */
	});
}
/* 根据职位及胜任力标签生成题目 */

export function GenerateQuestions(obj: AddReq) {
	return request({
		url: '/api/system/interview_question/ai_generated',
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
        timeout: 0
	});
}
/* 获取生成题目的列表 */
export function GetDraftList(obj: EditReq) {
	return request({
		url: `/api/system/interview_question/draft_list`,
		method: 'get',
		params: {...obj,tenant_id:Session.get('tenant_id')},
	});
}

/* 暂存生成的题目 */
export function SaveDraft(obj: EditReq) {
	return request({
		url: `/api/system/interview_question/confirm_draft`,
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
		 timeout: 0
	});
}
/* 获取数字人列表 */
export function GetDigitalList(obj: EditReq) {
	return request({
		url: `/api/system/digital_human/`,
		method: 'get',
		params: {...obj,tenant_id:Session.get('tenant_id')},
	});
}

/* 创建配置 */
export function CreateConfig(data:any) {
	return request({
		url:`/api/system/job_config/list`,
		method: 'post',
		data: {...data,tenant_id:Session.get('tenant_id')},
	});
}
/* 更新配置 */
export function UpdateConfig(data:any) {
	return request({
		url:`/api/system/job_config/detail/${data.id}`,
		method: 'put',
		data: {...data,tenant_id:Session.get('tenant_id')},
	});
}
/* 获取当前配置 */
export function GetConfig(id:any) {
	return request({
		url:`/api/system/job_config/position/detail/${id}`,
		method: 'get',
		
	});
}

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

/* 生成开场白 */
export function GetOpeningSpeech(obj: AddReq) {
	return request({
	  url: '/api/system/digital_human/generate_opening_video',
	  method: 'post',
	  data: {...obj,tenant_id:Session.get('tenant_id')},
	  timeout: 0
	});
  }

 /* 生成视频 */
 export function GetVideo(obj: AddReq) {
	return request({
	  url: '/api/system/digital_human/generate_question_videos',
	  method: 'post',
	  data: {...obj,tenant_id:Session.get('tenant_id'),force_regenerate: true},
	  timeout: 0
	});
  }
/* 批量绑定 */
export function BatchBind(obj: AddReq) {
	return request({
		url: 'api/system/job/add_question',
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
	});
}
/* 批量取消绑定 */
export function BatchUnbind(obj: AddReq) {
	return request({
		url: '/api/system/job/batch_delete_questions',
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
	});
}

/* export function GetPermission(query: UserPageQuery) {
    return request({
        url: '/api/system/competency/list',
        method: 'get',
        params: {...query,tenant_id:Session.get('tenant_id')},
    });
}
 */
/* 更新为红线题 */
export function UpdateObj(obj: EditReq) {
	return request({
		url: "/api/system/interview_question/update",/* + obj.id+'/' */
		method: 'put',
		data: {...obj,tenant_id:Session.get('tenant_id')},
	});
}
/* 生成胜任力标签 */
export function GenerateCompetency(obj: AddReq) {
	return request({
		url: '/competency/generate_from_position/',
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
		timeout: 0
	});
}
/* 保存胜任力标签 */
export function SaveCompetency(obj: AddReq) {
	return request({
		url: '/competency/save_position_tags/',
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
	});
}

/* 获取当前职位下的标签 */
export function GetPositionTags(obj: AddReq) {
	return request({
		url: '/api/system/competency/list',
		method: 'get',
		params: {...obj,tenant_id:Session.get('tenant_id')},
	});
}
/* 修改问题 */
export function UpdateQuestion(obj: AddReq) {
	return request({
		url: '/api/system/interview_question/update',
		method: 'put',
		data: {...obj,tenant_id:Session.get('tenant_id')},
	});
}
/* 获取当前职位下的所有问题 */
export function GetPositionQuestions(obj: AddReq) {
	return request({
		url: '/api/system/job/questions',
		method: 'get',
		params: {...obj,tenant_id:Session.get('tenant_id')},
	});
}
/* 创建胜任力标签 */
export function CreateCompetency(obj: AddReq) {
	return request({
		url: '/api/system/competency/create',
		method: 'post',
		data: {...obj,tenant_id:Session.get('tenant_id')},
	});
}
/* 绑定当前胜任力标签 */
export function BatchUpdateTags(data: any) {
	return request({
		url: '/api/system/competency/batch_bind',
		method: 'post',
		data: {...data,tenant_id:Session.get('tenant_id')}
	});
}
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 GetPositionList(query: UserPageQuery) {
	return request({
		url: '/api/system/job/list',
		method: 'get',
		params: {...query,tenant_id:Session.get('tenant_id')},
	});
}

/* 检测是否有题目可以发布 */
export function CheckQuestionVideosStatus(data:any) {
	return request({
		url: 'api/system/job/question_videos_status',
		method: 'get',
		params: data,
	});
}

/* 查看问题详情 */

export function GetQuestionDetail(id:any) {
	return request({
		url: `/api/system/interview_question/detail?question_id=${id}&tenant_id=${Session.get('tenant_id')}`,
		method: 'get'
	});
}

/* 获取已选择的职位问题数据 */
export function GetSelectedApplications(params: any) {
	return request({
		url: '/api/system/job/questions',
		method: 'get',
		params: { ...params, tenant_id: Session.get('tenant_id') }
	});
}

/* 批量删除已绑定问题 */
export function DeleteSelectedApplications(params: any) {
	return request({
		url: '/api/system/job/batch_delete_questions',
		method: 'post',
		data: { ...params, tenant_id: Session.get('tenant_id') }
	});
}