import request from '@/utils/http'

/**
 * 底注配置 API
 */
export default {
  list(params: Record<string, unknown>) {
    return request.get<Api.Common.ApiPage>({
      url: '/core/dice/ante_config/DiceAnteConfig/index',
      params
    })
  },

  read(id: number | string) {
    return request.get<Api.Common.ApiData>({
      url: '/core/dice/ante_config/DiceAnteConfig/read?id=' + id
    })
  },

  save(params: Record<string, unknown>) {
    return request.post({
      url: '/core/dice/ante_config/DiceAnteConfig/save',
      data: params
    })
  },

  update(params: Record<string, unknown>) {
    return request.put({
      url: '/core/dice/ante_config/DiceAnteConfig/update',
      data: params
    })
  },

  delete(params: Record<string, unknown>) {
    return request.del({
      url: '/core/dice/ante_config/DiceAnteConfig/destroy',
      data: params
    })
  },

  /** 底注下拉（按渠道） */
  async getOptions(params?: Record<string, unknown>) {
    const res = await request.get<
      Array<{ id: number; name: string; title: string; mult: number; is_default: number }>
    >({
      url: '/core/dice/ante_config/DiceAnteConfig/getOptions',
      params
    })
    return Array.isArray(res) ? res : []
  }
}
