/**
 * 授权记录相关 API
 */

import { BaseService } from '../BaseService'
import type { BaseResponse, PaginationResponse } from '@/types/api'
import type {
  AuthorizationItem,
  AuthorizationListParams,
  UpdateAuthorizationRemarkRequest
} from '@/types/api/authorization'

export class AuthorizationService extends BaseService {
  /**
   * 获取授权记录列表
   * @param params 查询参数
   */
  static getAuthorizations(
    params?: AuthorizationListParams
  ): Promise<PaginationResponse<AuthorizationItem>> {
    return this.getPage<AuthorizationItem>('/api/admin/authorizations', params)
  }

  /**
   * 获取授权记录详情
   * @param id 授权记录ID
   */
  static getAuthorizationDetail(id: number): Promise<BaseResponse<AuthorizationItem>> {
    return this.getOne<AuthorizationItem>(`/api/admin/authorizations/${id}`)
  }

  /**
   * 修改授权备注
   * @param id 授权记录ID
   * @param data 备注数据
   */
  static updateAuthorizationRemark(
    id: number,
    data: UpdateAuthorizationRemarkRequest
  ): Promise<BaseResponse<AuthorizationItem>> {
    return this.put<BaseResponse<AuthorizationItem>>(`/api/admin/authorizations/${id}/remark`, data)
  }
}
