|
|
|
@ -0,0 +1,69 @@
|
|
|
|
|
import request from '@/utils/request.js'
|
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
|
|
|
|
|
export const listStudent = () => {
|
|
|
|
|
return request.get('/student')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getStudentById = (id) => {
|
|
|
|
|
return request.get(`/student/${id}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const pageStudent = (pageQueryDTO) => {
|
|
|
|
|
const params = new URLSearchParams();
|
|
|
|
|
const formattedQuery = { ...pageQueryDTO };
|
|
|
|
|
|
|
|
|
|
// 处理创建时间
|
|
|
|
|
if (formattedQuery.createTime && Array.isArray(formattedQuery.createTime) && formattedQuery.createTime.length === 2) {
|
|
|
|
|
formattedQuery.createTimeStart = dayjs(formattedQuery.createTime[0]).format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
|
formattedQuery.createTimeEnd = dayjs(formattedQuery.createTime[1]).format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
|
delete formattedQuery.createTime; // 删除原始的时间范围数组
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理更新时间
|
|
|
|
|
if (formattedQuery.updateTime && Array.isArray(formattedQuery.updateTime) && formattedQuery.updateTime.length === 2) {
|
|
|
|
|
formattedQuery.updateTimeStart = dayjs(formattedQuery.updateTime[0]).format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
|
formattedQuery.updateTimeEnd = dayjs(formattedQuery.updateTime[1]).format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
|
delete formattedQuery.updateTime; // 删除原始的时间范围数组
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 构建URLSearchParams,仅添加非空参数
|
|
|
|
|
for (let key in formattedQuery) {
|
|
|
|
|
if (formattedQuery[key] !== null && formattedQuery[key] !== undefined && formattedQuery[key] !== '') {
|
|
|
|
|
params.append(key, formattedQuery[key]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return request.get(`/student/page?${params.toString()}`);
|
|
|
|
|
};
|
|
|
|
|
export const saveStudent = (studentDTO) => {
|
|
|
|
|
return request.post('/student', studentDTO)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const upload = (file) => {
|
|
|
|
|
return request.post('/student/import', file)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const download = () => {
|
|
|
|
|
return request.get('/student/export', {
|
|
|
|
|
responseType: 'blob'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const updateStudent = (studentDTO) => {
|
|
|
|
|
return request.put('/student', studentDTO)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const deleteStudents = (ids) => {
|
|
|
|
|
const idsArray = Array.isArray(ids) ? ids : [ids];
|
|
|
|
|
const idsString = idsArray.join(',')
|
|
|
|
|
return request.delete(`/student/${idsString}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const rollCall = () => {
|
|
|
|
|
return request.get('/student/rollcall')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const updatePoints = (id, pointsChange) => {
|
|
|
|
|
return request.put(`/student/points/${id}/${pointsChange}`)
|
|
|
|
|
}
|