• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { defHttp } from '/@/utils/http/axios';
17import { Modal } from 'ant-design-vue';
18
19enum Api {
20  LIST = '/sample/video/list',
21  SAVE = '/sample/video/add',
22  EDIT = '/sample/video/edit',
23  DELETE = '/sample/video/delete',
24  DELETE_BATCH = '/sample/video/deleteBatch',
25}
26
27/**
28 * 列表接口
29 */
30export const list = (params): Promise<string> => defHttp.get({ url: Api.LIST, params });
31
32/**
33 * 删除
34 */
35export const deleteVideo = (params, handleSuccess): Promise<void> => {
36  return defHttp.delete({ url: Api.DELETE, params }).then(() => {
37    handleSuccess();
38  });
39};
40
41/**
42 * 批量删除
43 */
44export const batchDeleteVideo = (params, handleSuccess): void => {
45  Modal.confirm({
46    title: '确认删除',
47    content: '是否删除选中数据',
48    okText: '确认',
49    cancelText: '取消',
50    onOk: () => {
51      return defHttp.delete({ url: Api.DELETE_BATCH, data: params }, { joinParamsToUrl: true }).then(() => {
52        handleSuccess();
53      });
54    },
55  });
56};
57
58/**
59 * 保存或者更新
60 */
61export const saveOrUpdate = (params, isUpdate): Promise<any> => {
62  const url = isUpdate ? Api.EDIT : Api.SAVE;
63  return defHttp.post({ url: url, params });
64};
65