import service from '@/utils/request/index'
import type {
  UpdateUserInfoDto,
  SelfPublishDetailDto,
  AuditListSearchParams,
  AuditListItemDto,
  AuditArticleDto,
  SelfPublishSearchParams,
  SelfCollectSearchParams,
  SelfCollectDetailDto,
  SelfPraiseSearchParams,
  SelfPraiseDetailDto,
  OfficialAccountItemDto,
  SelfCaseItemDto,
  SelfCommentItemDto,
  SelfCommentSearchParams,
  SelfDraftSearchParams,
  SelfTaskSearchParams,
  SelfTaskItemDto,
  ComplaintListItemDto,
  AuditComplaintDto,
  ComplaintListSearchParams,
  SelfCaseSearchParams,
  SelfAuctionRecordSearchParams,
  SelfAuctionRecordItemDto,
} from './types'
import type { BackendServicePageResult } from '@/utils/request/types'

/**
 * 更新用户信息
 */
export const updateUserInfo = (data: UpdateUserInfoDto) => {
  return service.request({
    url: '/api/personalCenter/updateUser',
    method: 'POST',
    data,
  })
}

/**
 * 是否有官方账号权限
 */
export const hasOfficialAccount = () => {
  return service.request<OfficialAccountItemDto[]>({
    url: '/api/personalCenter/getIsOfficial',
    method: 'POST',
    data: {},
  })
}

/**
 * 获取我的发布列表
 */
export const getSelfPublishList = (data: SelfPublishSearchParams) => {
  return service.request<BackendServicePageResult<SelfPublishDetailDto>>({
    url: '/api/personalCenter/selfPublish',
    method: 'POST',
    data,
  })
}

/**
 * 获取我的草稿列表
 */
export const getSelfDraftList = (data: SelfDraftSearchParams) => {
  return service.request<BackendServicePageResult<SelfPublishDetailDto>>({
    url: '/api/personalCenter/selfDraft',
    method: 'POST',
    data,
  })
}

/**
 * 获取我的收藏列表
 */
export const getSelfCollectList = (data: SelfCollectSearchParams) => {
  return service.request<BackendServicePageResult<SelfCollectDetailDto>>({
    url: '/api/personalCenter/selfCollect',
    method: 'POST',
    data,
  })
}

/**
 * 获取我的点赞列表
 */
export const getSelfPraiseList = (data: SelfPraiseSearchParams) => {
  return service.request<BackendServicePageResult<SelfPraiseDetailDto>>({
    url: '/api/personalCenter/selfPraise',
    method: 'POST',
    data,
  })
}

/**
 * 获取我的案例库列表
 */
export const getSelfCaseList = (data: SelfCaseSearchParams) => {
  return service.request<BackendServicePageResult<SelfCaseItemDto>>({
    url: '/api/personalCenter/selfCase',
    method: 'POST',
    data,
  })
}

/**
 * 获取我的任务列表
 */
export const getSelfTaskList = (data: SelfTaskSearchParams) => {
  return service.request<BackendServicePageResult<SelfTaskItemDto>>({
    url: '/api/personalCenter/selfTaskConfig',
    method: 'POST',
    data,
  })
}

/**
 * 评论回复
 */
export const getSelfCommentList = (data: SelfCommentSearchParams) => {
  return service.request<BackendServicePageResult<SelfCommentItemDto>>({
    url: '/api/personalCenter/selfComment',
    method: 'POST',
    data,
  })
}

/**
 * 待审核列表
 */
export const getAuditList = (data: AuditListSearchParams) => {
  return service.request<BackendServicePageResult<AuditListItemDto>>({
    url: '/api/personalCenter/getAuditList',
    method: 'POST',
    data,
  })
}

/**
 * 审核推文
 */
export const auditArticle = (data: AuditArticleDto) => {
  return service.request({
    url: '/api/cultureArticle/auditArticle',
    method: 'POST',
    data,
  })
}

/**
 * 举报列表
 */
export const getComplaintList = (data: ComplaintListSearchParams) => {
  return service.request<BackendServicePageResult<ComplaintListItemDto>>({
    url: '/cultureReport/getReportList',
    method: 'POST',
    data,
  })
}

/**
 * 审核举报
 */
export const auditComplaint = (data: AuditComplaintDto) => {
  return service.request({
    url: '/cultureReport/auditReport',
    method: 'POST',
    data,
  })
}

/**
 * 获取我的竞拍记录-分页
 */
export const getSelfAuctionRecord = (data: SelfAuctionRecordSearchParams) => {
  return service.request<BackendServicePageResult<SelfAuctionRecordItemDto>>({
    url: '/api/personalCenter/listBidRecord',
    method: 'POST',
    data,
  })
}
