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

export const apiPrefix = '/system/interview_question/create';

export function GetPermission() {
	return request({
		url: apiPrefix + 'field_permission/',
		method: 'get',
	});
}

export function GetList(query: any) {
	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 GetObj(id: InfoReq) {
	return request({
		url: "/api/system/interview_question/detail",
		method: 'get',
		params: {...id,tenant_id:Session.get('tenant_id')},
	});
}

export function AddObj(obj: AddReq) {
	return request({
		url: "/api/system/interview_question/create",
		method: 'post',
		data: {...obj,tenant_id: Session.get('tenant_id')},/* Session.get('tenant_id').tenant_id ||,tenant_id: '1' */
	});
}

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 DelObj(id: DelReq) {
	return request({
		url: '/api/system/interview_question/delete',/* + id + '/' ,tenant_id: '1' */
		method: 'delete',
		data: { id},
	});
}

export function GetTagList(params: any) {
	return request({
		url: '/api/system/question_tag/list',
		method: 'get',
		params: {...params,tenant_id:Session.get('tenant_id')},
	});
}

export function GetcategoryList(params: any) {
	return request({
		url: '/api/system/question_category/list',
		method: 'get',
		params: {...params,tenant_id:Session.get('tenant_id')},
	});
}

// 批量更新标签
export function BatchUpdateTags(data: any) {
	return request({
		url: '/api/system/interview_question/batch_update_tags',
		method: 'post',
		data
	});
}

// 获取职位列表
export function GetPositionList(params: any) {
	return request({
		url: '/api/system/job/list',
		method: 'get',
		params
	});
}

// 批量更新分类
export function BatchUpdateCategory(data: any) {
	return request({
		url: '/api/system/interview_question/batch_update_category',
		method: 'post',
		data
	});
}

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

export const BatchUpdateCompetencyTags = (data: any) => {
	return request({
		url: '/api/system/question/batch_update_competency_tags',
		method: 'post',
		data
	});
}

// 获取胜任力标签列表
export function GetCompetencyList(params: any) {
	return request({
		url: '/api/system/competency/list',
		method: 'get',
		params: {...params, tenant_id: Session.get('tenant_id')},
		timeout: 0
	});
}



/* 添加填空题 */
export function AddFillQuestion(data:any) {
	return request({
	  url: '/api/system/interview_question/blank/create',
	  method: 'post',
	  data:{...data,tenant_id:Session.get('tenant_id')}
	});
}

// 更新评分标准
export function UpdateScoringStandard(data: any) {
	return request({
		url: '/api/system/question_category/update_scoring_standard',
		method: 'put',
		data: { ...data, tenant_id: Session.get('tenant_id') }
	});
}

/* 添加填空题 */
export function AddObjBlank(obj: AddReq) {
	return request({
		url: "/api/system/interview_question/blank/create",
		method: 'post',
		data: {...obj,tenant_id: Session.get('tenant_id')},/* Session.get('tenant_id').tenant_id ||,tenant_id: '1' */
	});
}

/* 编辑填空题 /api/system/interview_question/blank/update*/
export function editObjBlank(obj: AddReq) {
	return request({
		url: "/api/system/interview_question/blank/update",
		method: 'post',
		data: {...obj,tenant_id: Session.get('tenant_id')},/* Session.get('tenant_id').tenant_id ||,tenant_id: '1' */
	});
}