import type { List } from '@/model';
import type {
  SatisfactionSendRecordModel,
  SatisfactionSendRecordQuery,
  SatisfactionModel,
  SatisfactionQuery,
  SatisfactionStatisticsModel,
  SatisfactionStatisticsQuery,
} from '@/model/satisfaction.model';

import request from '@/request/alova';

// 获取满意度调研问卷发送记录分页列表
export function satisfactionSendRecordMethod(page: number, size: number, query?: SatisfactionSendRecordQuery) {
  return request.Post<List<SatisfactionSendRecordModel>, List<any>>(`/fdhb-pc/satisfiesyManage/selectSatisfiesySendRecord`, query ?? {}, {
    hitSource: /satisfaction-send-record$/,
    params: { pageNum: page, pageSize: size },
  });
}
// 获取满意度调研问卷列表
export function satisfactionMethod(page?: number, size?: number, query?: SatisfactionQuery) {
  const params: any = { ...query };
  if (page !== undefined && size !== undefined) {
    params.pageNum = page;
    params.pageSize = size;
  }
  return request.Post<List<SatisfactionModel>, List<any>>(`/fdhb-pc/satisfiesyManage/pageSatisfiesy`, params, {
    hitSource: /satisfaction$/,
    // params,
  });
}
//满意度问卷统计
export function satisfactionStatisticsMethod(query?: SatisfactionStatisticsQuery) {
  return request.Post<SatisfactionStatisticsModel, List<any>>(`/fdhb-pc/satisfiesyManage/satisfiesyStatistics`, query ?? {}, {
    hitSource: /satisfaction-statistics$/,
    params: {},
  });
}

//根据满意度调研问卷ID获取满意度调研问卷详情
export function getSatisfactionDetailMethod(id: string) {
  return request.Post(`/fdhb-pc/satisfiesyManage/detail/${id}`, { name: 'get-satisfaction-detail' });
  // return request.Post(`/fdhb-pc/satisfiesyManage/getContentBySendRecordId/${id}`, { name: 'get-satisfaction-detail' });
}
// 查看个人的满意度调研问卷详情
export function getSatisfactionContentBySendRecordIdMethod(id: string) {
  return request.Post(`/fdhb-pc/satisfiesyManage/getContentBySendRecordId/${id}`, { name: 'get-personal-satisfaction-detail' });
}

// 设置触发条件
export function setSatisfactionTriggerMethod(data: Partial<SatisfactionModel>) {
  return request.Post(
    `/fdhb-pc/satisfiesyManage/configTrigger/${data.id}/${data.status}/${data.pushType}`,
    { triggerType: data.satisfiesyPmr?.triggerType, triggerIntervalHours: data.satisfiesyPmr?.triggerIntervalHours },
    { name: 'set-satisfaction-trigger' }
  );
}
//新增满意度调研问卷
export function addSatisfactionMethod(data: Partial<SatisfactionModel>) {
  return request.Post(`/fdhb-pc/satisfiesyManage/addContent`, data, { name: 'add-satisfaction' });
}
