import { request } from 'umi';
import type { NewsListParams } from './data';
import service from '@/services/http/service';
import { NewsParams } from '../news/data';


export async function queryNewsItem(id: number) {

  console.log("queryNewsItem: ", id)
  let result = await service.post('/api/v1/news/list', {
    id,
    all: true,
    // order_asc: false,
    // tag: params.tag,
    // is_deleted: params.is_deleted,
    "page_no": 0,
    "page_size": 100
  });

  return Promise.resolve({
    data: result.data.list,
    success: true,
  })
}


export async function queryNewsDraftItem(id: number) {

  console.log("queryNewsDraftItem: ", id)
  let result = await service.post('/api/v1/news/draft/list', {
    id,
    all: true,
    // order_asc: false,
    // tag: params.tag,
    // is_deleted: params.is_deleted,
    "page_no": 0,
    "page_size": 100
  });

  return Promise.resolve({
    data: result.data.list,
    success: true,
  })
}

// 今日订阅编辑 订阅文章编辑

export async function editSubItem(params: NewsParams) {

  console.log("editSubItem: ", params)
  let result = await service.post('/api/v1/sub/edit', {
    ...params
  });

  return Promise.resolve({
    data: result.data.list,
    success: true,
  })
}


// 保存草稿箱
export async function editDraftItem(params: NewsParams) {

  console.log("editNewsItem: ", params)
  let result = await service.post('/api/v1/news/draft/edit', {
    ...params
  });

  return Promise.resolve({
    data: result.data.list,
    success: true,
  })
}

export async function newsDraftPublish(id: number) {

  console.log("newsDraftPublish: ", id)
  let result = await service.post('/api/v1/news/draft/publish', {
    id: id
  });

  return Promise.resolve({
    data: result.data,
    success: true,
  })
}







