bannner.ts 1.52 KB
import { AnyObject, QueryForParams, ServiceResponse } from '@/types/global';
import { Banner } from '@/utils/model';
import axios from 'axios';

export default class useBannerApi {
  static roleOption = [
    { value: 'UnLogin', label: '未登录' },
    { value: 'Visitor', label: '游客' },
    { value: 'Singer', label: '音乐人' },
    { value: 'Business', label: '经纪人' },
    { value: 'Project', label: '厂牌管理员' },
    { value: 'System', label: '平台管理员' },
  ];

  static statusOption = [
    { value: 0, label: '下架' },
    { value: 1, label: '上架' },
  ];

  static scopeOption = [{ value: 1, label: '首页banner' }];

  static typeOption = [
    { value: 1, label: '普通' },
    { value: 2, label: '外链' },
    { value: 3, label: '交互' },
    { value: 4, label: '自定义H5' },
  ];

  static get(params?: QueryForParams): Promise<ServiceResponse<Banner[]>> {
    return axios.get('system/banners', { params });
  }

  static async create(data: AnyObject): Promise<Banner> {
    return axios.post('system/banners', data).then((res) => Promise.resolve(res.data));
  }

  static async update(id: number, data: AnyObject): Promise<Banner> {
    return axios.put(`system/banners/${id}`, data).then((res) => Promise.resolve(res.data));
  }

  static async changeStatus(id: number, data: { status: number }) {
    return axios.put(`system/banners/${id}/change-status`, data);
  }

  static async destroy(id: number) {
    return axios.delete(`system/banners/${id}`).then((res) => Promise.resolve(res.data));
  }
}