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

/**
 * 分页查询学生违纪列表
 * @param query
 */
export const fetchList = (query?: any) => {
  return request({
    url: '/stuwork/stupunlish/page',
    method: 'get',
    params: query
  });
};

/**
 * 新增学生违纪
 * @param data
 */
export const addObj = (data: any) => {
  return request({
    url: '/stuwork/stupunlish',
    method: 'post',
    data
  });
};

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

/**
 * 编辑学生违纪
 * @param data
 */
export const editObj = (data: any) => {
  return request({
    url: '/stuwork/stupunlish/edit',
    method: 'post',
    data
  });
};

/**
 * 删除学生违纪
 * @param ids
 */
export const delObj = (ids: string[]) => {
  return request({
    url: '/stuwork/stupunlish/delete',
    method: 'post',
    data: ids
  });
};

/**
 * 导出学生违纪
 * @param query
 */
export const exportData = (query?: any) => {
  return request({
    url: '/stuwork/stupunlish/export',
    method: 'post',
    data: query,
    responseType: 'blob'
  });
};

/**
 * 根据班级代码查询惩罚数量
 * @param classCode 班级代码
 */
export const queryPunlishNumByClass = (classCode: string | number) => {
  return request({
    url: '/stuwork/stupunlish/queryPunlishNumByClass',
    method: 'get',
    params: { classCode }
  });
};

/**
 * 撤销处分
 * @param data 包含id和publishStatus的对象，publishStatus设置为"0"即可撤销处分
 */
export const revokePunishment = (data: any) => {
  return request({
    url: '/stuwork/stupunlish/cancelStatus',
    method: 'post',
    data
  });
};
