import request from '/@/utils/request';

// Skill 技能项
export interface SkillItem {
	id: number;
	name: string;
	description: string;
	category: string;
	fileName: string;
	fileUrl: string;
	createdAt: string;
	updatedAt: string;
}

// Skill 列表响应
export interface SkillListResponse {
	list: SkillItem[];
	total: number;
}

// 创建 Skill 参数
export interface CreateSkillParams {
	name?: string;
	description?: string;
	category?: string;
	fileName?: string;
	fileUrl?: string;
	[property: string]: any;
}

// 系统技能列表查询参数
export interface SkillListParams {
	pageNum?: number;
	pageSize?: number;
	keyword?: string;
	Total?: number;
}

// 用户技能列表查询参数
export interface UserSkillListParams {
	pageNum?: number;
	pageSize?: number;
	keyword?: string;
	Total?: number;
}

/**
 * 获取 Skill 系统技能列表
 */
export function getSkillList(params?: SkillListParams, config?: any) {
	return request<SkillListResponse>({
		url: '/ai-agent/skill/template/list',
		method: 'get',
		params,
		...config,
	});
}

/**
 * 创建 Skill 系统技能
 */
export function createSkill(data: CreateSkillParams, config?: any) {
	return request({
		url: '/ai-agent/skill/template/create',
		method: 'post',
		data,
		...config,
	});
}

/**
 * 删除 Skill 系统技能
 */
export function deleteSkill(id: number, config?: any) {
	return request({
		url: '/ai-agent/skill/template/delete',
		method: 'delete',
		data: { id },
		...config,
	});
}

/**
 * 获取 Skill 用户技能列表
 */
export function getUserSkillList(params?: UserSkillListParams, config?: any) {
	return request<SkillListResponse>({
		url: '/ai-agent/skill/user/list',
		method: 'get',
		params,
		...config,
	});
}
/**
 * 获取 Skill 用户技能列表
 */
export function getUserSkilllistUser(params?: UserSkillListParams, config?: any) {
	return request<SkillListResponse>({
		url: '/ai-agent/skill/user/listUser',
		method: 'get',
		params,
		...config,
	});
}

/**
 * 创建 Skill 用户技能
 */
export function createUserSkill(data: CreateSkillParams, config?: any) {
	return request({
		url: '/ai-agent/skill/user/create',
		method: 'post',
		data,
		...config,
	});
}

/**
 * 删除 Skill 用户技能
 */
export function deleteUserSkill(id: number, config?: any) {
	return request({
		url: '/ai-agent/skill/user/delete',
		method: 'delete',
		data: { id },
		...config,
	});
}

/**
 * 获取 Skill 用户技能详情
 */
export function getUserSkillDetail(id: number, config?: any) {
	return request<SkillItem>({
		url: '/ai-agent/skill/user/get',
		method: 'get',
		params: { id },
		...config,
	});
}

/**
 * 更新 Skill 用户技能
 */
export function updateUserSkill(data: CreateSkillParams & { id: number }, config?: any) {
	return request({
		url: '/ai-agent/skill/user/update',
		method: 'put',
		data,
		...config,
	});
}
