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

/**
 * 分页查询班级宣传列表
 * @param query
 */
export const fetchList = (query?: any) => {
  return request({
    url: '/stuwork/classpublicity/page',
    method: 'get',
    params: query
  });
};

/**
 * 新增班级宣传
 * @param data
 */
export const addObj = (data: any) => {
  return request({
    url: '/stuwork/classpublicity',
    method: 'post',
    data
  });
};

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

/**
 * 编辑班级宣传
 * @param data
 */
export const editObj = (data: any) => {
  return request({
    url: '/stuwork/classpublicity/edit',
    method: 'post',
    data
  });
};

/**
 * 归档班级宣传
 * @param data
 */
export const editBelong = (data: any) => {
  return request({
    url: '/stuwork/classpublicity/editBelong',
    method: 'post',
    data
  });
};

/**
 * 删除班级宣传
 * @param ids
 */
export const delObj = (ids: string[]) => {
  return request({
    url: '/stuwork/classpublicity/delete',
    method: 'post',
    data: ids
  });
};

/**
 * 加分
 * @param data
 */
export const addScore = (data: any) => {
  return request({
    url: '/stuwork/classpublicity/edit',
    method: 'post',
    data: {
      ...data,
      isAddScore: '1'
    }
  });
};

/**
 * 根据班级代码查询班级宣传
 * @param classCode 班级代码
 */
export const queryDataByClassCode = (classCode: string | number) => {
  return request({
    url: '/stuwork/classpublicity/queryDataByClassCode',
    method: 'get',
    params: { classCode },
  });
};
