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

/**
 * 分页查询操行考核列表
 * @param query
 */
export const fetchList = (query?: any) => {
  return request({
    url: '/stuwork/stuconduct/page',
    method: 'get',
    params: query
  });
};

/**
 * 新增操行考核
 * @param data
 */
export const addObj = (data: any) => {
  return request({
    url: '/stuwork/stuconduct',
    method: 'post',
    data
  });
};

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

/**
 * 通过学年学号查看详情（接口文档：GET /stuwork/stuconduct/queryDataByStuNo）
 * @param params stuNo 学号, schoolYear 学年
 */
export const queryDataByStuNo = (params: { stuNo: string; schoolYear: string }) => {
  return request({
    url: '/stuwork/stuconduct/queryDataByStuNo',
    method: 'get',
    params
  });
};

/**
 * 编辑操行考核
 * @param data
 */
export const editObj = (data: any) => {
  return request({
    url: '/stuwork/stuconduct/edit',
    method: 'post',
    data
  });
};

/**
 * 删除操行考核
 * @param ids
 */
export const delObj = (ids: string[]) => {
  return request({
    url: '/stuwork/stuconduct/delete',
    method: 'post',
    data: ids
  });
};

/**
 * 导入操行考核
 * @param file
 */
export const importExcel = (file: File) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/stuwork/stuconduct/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

/**
 * 学期操行考核查询
 * @param query
 */
export const getStuConductTerm = (query?: any) => {
  return request({
    url: '/stuwork/stuconduct/getStuConductTerm',
    method: 'get',
    params: query
  });
};

/**
 * 学年操行考核查询
 * @param query
 */
export const getStuConductYear = (query?: any) => {
  return request({
    url: '/stuwork/stuconduct/getStuConductYear',
    method: 'get',
    params: query
  });
};

/**
 * 发送学期操行考核预警
 * @param schoolYear 学年
 * @param schoolTerm 学期
 */
export const sendConductWarning = (schoolYear: string, schoolTerm: string) => {
  return request({
    url: '/stuwork/stuconduct/sendWarning',
    method: 'post',
    params: { schoolYear, schoolTerm }
  });
};

