import { get, post, put, del } from "@/utils/request";

// 模型相关接口
export function queryModelProvidersUsingGet(params?: Record<string, unknown>) {
  return get("/api/models/providers", params);
}

export function queryModelListUsingGet(data: Record<string, unknown>) {
  return get("/api/models/list", data);
}

export function queryModelDetailByIdUsingGet(id: string | number) {
  return get(`/api/models/${id}`);
}

export function updateModelByIdUsingPut(
  id: string | number,
  data: Record<string, unknown>
) {
  return put(`/api/models/${id}`, data);
}

export function createModelUsingPost(data: Record<string, unknown>) {
  return post("/api/models/create", data);
}

export function deleteModelByIdUsingDelete(id: string | number) {
  return del(`/api/models/${id}`);
}

// 获取系统参数列表
export function getSysParamList() {
  return get("/api/sys-param/list");
}

// 更新系统参数值
export const updateSysParamValue = async (params: {
  id: string;
  paramValue: string;
}) => {
  return put(`/api/sys-param/${params.id}`, params);
};

export interface AuthUserWithRoles {
  id: number;
  username: string;
  fullName?: string;
  email?: string;
  enabled?: boolean;
  roleCodes: string[];
}

export interface AuthRoleInfo {
  id: string;
  roleCode: string;
  roleName: string;
  description?: string;
  enabled?: boolean;
}

export interface AuthPermissionInfo {
  id: string;
  permissionCode: string;
  permissionName: string;
  module?: string;
  action?: string;
  pathPattern?: string;
  method?: string;
  enabled?: boolean;
}

// 用户与权限管理接口
export function listAuthUsersUsingGet() {
  return get("/api/auth/users");
}

export function listAuthRolesUsingGet() {
  return get("/api/auth/roles");
}

export function listAuthPermissionsUsingGet() {
  return get("/api/auth/permissions");
}

export function assignUserRolesUsingPut(userId: number, roleIds: string[]) {
  return put(`/api/auth/users/${userId}/roles`, { roleIds });
}
