import request from '/@/utils/request';

/**
 * 分页查询安全教育列表
 * @param query
 */
export const fetchList = (query?: any) => {
  return request({
    url: '/stuwork/classsafeedu/page',
    method: 'get',
    params: query
  });
};

/**
 * 新增安全教育
 * @param data
 */
export const addObj = (data: any) => {
  return request({
    url: '/stuwork/classsafeedu',
    method: 'post',
    data
  });
};

/**
 * 获取详情
 * @param id
 */
export const getDetail = (id: string) => {
  return request({
    url: '/stuwork/classsafeedu/detail',
    method: 'get',
    params: { id }
  });
};

/**
 * 编辑安全教育
 * @param data
 */
export const editObj = (data: any) => {
  return request({
    url: '/stuwork/classsafeedu/edit',
    method: 'post',
    data
  });
};

/**
 * 删除安全教育
 * @param ids
 */
export const delObj = (ids: string[]) => {
  return request({
    url: '/stuwork/classsafeedu/delete',
    method: 'post',
    data: ids
  });
};

/**
 * 导出安全教育
 * @param query
 */
export const exportExcel = (query?: any) => {
  return request({
    url: '/stuwork/classsafeedu/export',
    method: 'get',
    params: query,
    responseType: 'blob' // Important for file downloads
  });
};

/**
 * 按学年学期统计各班级安全教育次数
 * @param schoolYear 学年
 * @param schoolTerm 学期
 */
export const statisticsByYearTerm = (schoolYear?: string, schoolTerm?: string) => {
  return request({
    url: '/stuwork/classsafeedu/statistics',
    method: 'get',
    params: { schoolYear, schoolTerm }
  });
};

