/*
 *    Copyright (c) 2018-2025, cyweb All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 */

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

/**
 * 获取列表
 * @param query
 */
export const fetchList = (query?: any) => {
	return request({
		url: '/basic/basicclass/page',
		method: 'get',
		params: query,
	});
};

/**
 * 新增
 * @param obj
 */
export const addObj = (obj: any) => {
	return request({
		url: '/basic/basicclass',
		method: 'post',
		data: obj,
	});
};

/**
 * 获取详情
 * @param id
 */
export const getObj = (id: string | number) => {
	return request({
		url: `/basic/basicclass/${id}`,
		method: 'get',
	});
};

/**
 * 获取详情（使用 detail 接口）
 * @param id
 */
export const getDetail = (id: string | number) => {
	return request({
		url: '/basic/basicclass/detail',
		method: 'get',
		params: { id }
	});
};

/**
 * 删除
 * @param id
 */
export const delObj = (id: string | number) => {
	return request({
		url: `/basic/basicclass/${id}`,
		method: 'delete',
	});
};

/**
 * 更新（编辑）
 * @param obj 含 id 及需修改字段，走接口文档 /edit 接口
 */
export const putObj = (obj: any) => {
	return request({
		url: '/basic/basicclass/edit',
		method: 'post',
		data: obj,
	});
};

/**
 * 批量更新规则
 * @param obj
 */
export const putObjs = (obj: any) => {
	return request({
		url: '/basic/basicclass/batchUpdataRuleById',
		method: 'post',
		data: obj,
	});
};

/**
 * 根据信息查询所有班级
 * @param query
 */
export const queryAllClassByInfo = (query: string | number) => {
	return request({
		url: `/basic/basicclass/queryAllClassByInfo/${query}`,
		method: 'get',
	});
};

/**
 * 根据专业查询班级年级
 * @param query
 */
export const queryClassGradeByMajor = (query: string | number) => {
	return request({
		url: `/basic/basicclass/queryClassGradeByMajor/${query}`,
		method: 'get',
	});
};

/**
 * 根据班级编号获取班级信息
 * @param obj
 */
export const getClassByClassNo = (obj: string | number) => {
	return request({
		url: `/basic/basicclass/queryClassInfoByCode/${obj}`,
		method: 'get',
	});
};

/**
 * 获取专业名称列表
 */
export const getMajorNameList = () => {
	return request({
		url: '/basic/major/getMajorNameList',
		method: 'get',
	});
};

/**
 * 获取二级学院列表
 */
export const getDeptList = () => {
	return request({
		url: '/basic/basicdept/getDeptList?secondFlag=1',
		method: 'get',
	});
};

/**
 * 获取二级部门列表
 */
export const getDeptListByLevel2 = () => {
	return request({
		url: '/basic/basicdept/getDeptList?deptLevel=2',
		method: 'get',
	});
};

/**
 * 查询所有年级列表
 */
export const queryAllGradeList = () => {
	return request({
		url: '/basic/basicclass/queryAllGradeList',
		method: 'get',
	});
};

/**
 * 获取年级列表
 */
export const getGradeList = () => {
	return request({
		url: '/basic/basicclass/getGradeList',
		method: 'get',
	});
};

/**
 * 根据部门代码查询班级
 * @param id
 */
export const queryClassByDeptCode = (id: string | number) => {
	return request({
		url: `/basic/basicclass/queryClassByDeptCode/${id}`,
		method: 'get',
	});
};

/**
 * 根据查询条件查询班级名称和编号
 * @param query
 */
export const queryClassNameAndNoByQuery = (query: string | number) => {
	return request({
		url: `/basic/basicclass/queryClassNameAndNoByQuery/${query}`,
		method: 'get',
	});
};

/**
 * 获取列表
 */
export const list = () => {
	return request({
		url: '/basic/basicclass/list',
		method: 'get',
	});
};

/**
 * 查班级列表 - 班主任角色查自己班级
 */
export const getClassListByRole = () => {
	return request({
		url: '/basic/basicclass/listByRole',
		method: 'get',
	});
};

/**
 * 查询所有非离校班级
 */
export const queryNoLeavelClass = () => {
	return request({
		url: '/basic/basicclass/queryNoLeavelClass',
		method: 'get',
	});
};

/**
 * 查询所有班级
 */
export const queryAllClass = () => {
	return request({
		url: '/basic/basicclass/queryAllClass',
		method: 'get',
	});
};

/**
 * 获取班级流失情况
 * @param query
 */
export const getClassLose = (query?: any) => {
	return request({
		url: '/basic/basicclass/getClassLose',
		method: 'get',
		params: query,
	});
};

/**
 * 班级信息导出
 * @param query
 */
export const classExportData = (query?: any) => {
	return request({
		url: '/basic/basicclass/classExportData',
		method: 'post',
		data: query,
		responseType: 'blob'
	});
};

