import { CategoryForm, CategoryQuery, CategoryTreeVO, CategoryVO, Formaget, QueryParamOV } from '@/api/workflow/category/types';

import { AxiosPromise } from 'axios';
import request from '@/utils/request';

export interface QueryChildOV {
  current: number;
  size: number;
  fatherCommentId: number | string;
}

/**
 * 视频列表
 * @param query
 * @returns {*}
 */

export const listCategory = (query?: CategoryQuery): AxiosPromise<CategoryVO[]> => {
  return request({
    // url: '/workflow/category/list',old
    url: '/cms/vlog/page',
    method: 'post',
    data: query
  });
};
/**
 * 视频通过和反驳
 * @param vlogId 视频id
 * @param reason 反驳理由
 * @param status 状态1：通过 2：反驳
 */
export const updateaudit = (data?: Formaget) => {
  return request({
    url: `/cms/video/audit?vlogId=${data.vlogId}&reason=${data.reason}&status=${data.status}`,
    method: 'post'
  });
};
/**
 * 视频评论列表
 * @param vlogId 视频id
 * @param mobile 手机号
 */
export const getcommentlist = (data?: QueryParamOV) => {
  return request({
    url: `/cms/comment/list`,
    method: 'post',
    data
  });
};
/**
 * 视频评论列表
//  * @param vlogId 视频id
//  * @param reason 反驳理由
//  * @param status 状态1：通过 2：反驳
 */
export const getchildList = (data?: QueryChildOV) => {
  return request({
    url: `/cms/comment/childList?fatherCommentId=${data.fatherCommentId}&current=${data.current}&size=${data.size}`,
    method: 'get'
  });
};
/**
 * 获取去视频详情
 * @param vlogId 视频id
 */
export const gerdetail = (data?: string) => {
  return request({
    url: `/video/detail?fileId=${data}`,
    method: 'get'
  });
};
/**
 * 删除评论
 * @param data 评论id
 */
export const deldetail = (data?: string) => {
  return request({
    url: `/cms/comment/delete?commentId=${data}`,
    method: 'post'
  });
};
/**
 * 上下架评论
 * @param id 评论id
 */
export const deloffline = (data?: string) => {
  return request({
    url: `/cms/comment/offline?commentId=${data}`,
    method: 'post'
  });
};

/**
 * 视频删除
 * @param vlogId 视频id
 */
export const updateaforbid = (vlogId?: string) => {
  return request({
    url: `/cms/video/forbid`,
    method: 'post',
    data: { fileIds: vlogId, operation: 'forbid' }
  });
};
/**
 * 查询流程分类详细
 * @param categoryId
 */
export const getCategory = (categoryId: string | number): AxiosPromise<CategoryVO> => {
  return request({
    url: '/workflow/category/' + categoryId,
    method: 'get'
  });
};

/**
 * 新增流程分类
 * @param data
 */
export const addCategory = (data: CategoryForm) => {
  return request({
    url: '/workflow/category',
    method: 'post',
    data: data
  });
};

/**
 * 修改流程分类
 * @param data
 */
export const updateCategory = (data: CategoryForm) => {
  return request({
    url: '/workflow/category',
    method: 'put',
    data: data
  });
};

/**
 * 删除流程分类
 * @param categoryId
 */
export const delCategory = (categoryId: string | number | Array<string | number>) => {
  return request({
    url: '/workflow/category/' + categoryId,
    method: 'delete'
  });
};

/**
 * 获取流程分类树列表
 * @param query 流程实例id
 * @returns
 */
export const categoryTree = (query?: CategoryForm): AxiosPromise<CategoryTreeVO[]> => {
  return request({
    url: `/workflow/category/categoryTree`,
    method: 'get',
    params: query
  });
};
