| 项目 | 信息 |
|---|---|
| 项目名称 | 校园管理系统 - 学生信息收集批次管理 |
| API模块 | 学生信息收集批次班级权限管理 |
| 文档版本 | V1.0.0 |
| 创建时间 | 2025-01-27 |
| 基础路径 | /stuColBatchClass/stuColBatchClass |
学生信息收集批次管理系统提供完整的批次权限配置、批次查询、权限范围管理等API接口,支持按班级权限控制学生信息收集范围。
{
"id": 1, // 批次ID
"batchName": "2025年春季学期信息收集", // 批次名称
"description": "收集学生基本信息", // 批次描述
"startTime": "2025-02-01 00:00:00", // 开始时间
"endTime": "2025-02-28 23:59:59", // 结束时间
"status": "0", // 状态(0正常 1停用)
"collectionType": "1", // 收集类型(1-新学期收集 2-其他)
"remark": "备注信息", // 备注
"createBy": 1, // 创建者
"createTime": "2025-01-27 10:00:00", // 创建时间
"updateBy": 1, // 更新者
"updateTime": "2025-01-27 10:00:00" // 更新时间
}
{
"id": 1, // 主键ID
"batchId": 1, // 批次ID
"classId": 101, // 班级ID
"className": "计算机2023-1", // 班级名称
"majorId": 10, // 专业ID
"majorName": "计算机科学与技术", // 专业名称
"collegeId": 1, // 院系ID
"collegeName": "计算机学院", // 院系名称
"remark": "备注", // 备注
"deleted": 0, // 删除标志
"createBy": 1, // 创建者
"createTime": "2025-01-27 10:00:00", // 创建时间
"updateBy": 1, // 更新者
"updateTime": "2025-01-27 10:00:00" // 更新时间
}
/stuColBatchClass/stuColBatchClass/liststuColBatchClass:stuColBatchClass:list请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | pageNum | integer | 否 | 页码,默认1 | | pageSize | integer | 否 | 每页大小,默认10 | | batchId | long | 否 | 批次ID | | classId | long | 否 | 班级ID | | className | string | 否 | 班级名称(模糊查询) | | majorName | string | 否 | 专业名称(模糊查询) | | collegeName | string | 否 | 院系名称(模糊查询) |
响应数据:
{
"code": 200,
"msg": "查询成功",
"rows": [
{
"id": 1,
"batchId": 1,
"classId": 101,
"className": "计算机2023-1",
"majorId": 10,
"majorName": "计算机科学与技术",
"collegeId": 1,
"collegeName": "计算机学院"
}
],
"total": 1
}
/stuColBatchClass/stuColBatchClass/{id}stuColBatchClass:stuColBatchClass:query请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | id | long | 是 | 主键ID |
响应数据:
{
"code": 200,
"msg": "查询成功",
"data": {
"id": 1,
"batchId": 1,
"classId": 101,
"className": "计算机2023-1",
"majorId": 10,
"majorName": "计算机科学与技术",
"collegeId": 1,
"collegeName": "计算机学院",
"remark": "备注",
"deleted": 0
}
}
/stuColBatchClass/stuColBatchClassstuColBatchClass:stuColBatchClass:add请求参数:
{
"batchId": 1,
"classId": 101,
"className": "计算机2023-1",
"majorId": 10,
"majorName": "计算机科学与技术",
"collegeId": 1,
"collegeName": "计算机学院",
"remark": "备注"
}
响应数据:
{
"code": 200,
"msg": "新增成功"
}
/stuColBatchClass/stuColBatchClassstuColBatchClass:stuColBatchClass:edit请求参数:
{
"id": 1,
"batchId": 1,
"classId": 101,
"className": "计算机2023-1",
"majorId": 10,
"majorName": "计算机科学与技术",
"collegeId": 1,
"collegeName": "计算机学院",
"remark": "修改后的备注"
}
响应数据:
{
"code": 200,
"msg": "修改成功"
}
/stuColBatchClass/stuColBatchClass/{ids}stuColBatchClass:stuColBatchClass:remove请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | ids | string | 是 | 主键ID,多个用逗号分隔 |
响应数据:
{
"code": 200,
"msg": "删除成功"
}
/stuColBatchClass/stuColBatchClass/exportstuColBatchClass:stuColBatchClass:export请求参数:
{
"batchId": 1,
"classId": 101,
"className": "计算机",
"majorName": "计算机科学",
"collegeName": "计算机学院"
}
响应数据:
/stuColBatchClass/stuColBatchClass/getScope/{batchId}stuColBatchClass:stuColBatchClass:query请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | batchId | long | 是 | 批次ID |
响应数据:
{
"code": 200,
"msg": "查询成功",
"data": [101, 102, 103] // 班级ID列表
}
/stuColBatchClass/stuColBatchClass/getScopeDetail/{batchId}stuColBatchClass:stuColBatchClass:query请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | batchId | long | 是 | 批次ID |
响应数据:
{
"code": 200,
"msg": "查询成功",
"data": [
{
"id": 1,
"batchId": 1,
"classId": 101,
"className": "计算机2023-1",
"majorId": 10,
"majorName": "计算机科学与技术",
"collegeId": 1,
"collegeName": "计算机学院"
}
]
}
/stuColBatchClass/stuColBatchClass/setScopestuColBatchClass:stuColBatchClass:setScope请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | batchId | long | 是 | 批次ID | | deptIds | array | 是 | 授权的班级ID列表 |
响应数据:
{
"code": 200,
"msg": "权限设置成功,共设置 3 个班级权限"
}
/stuColBatchClass/stuColBatchClass/getStudentAvailableBatches请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | batchName | string | 否 | 批次名称(模糊查询) |
响应数据:
{
"code": 200,
"msg": "查询成功",
"data": [
{
"batchId": 1,
"batchName": "2025年春季学期信息收集",
"description": "收集学生基本信息",
"startTime": "2025-02-01 00:00:00",
"endTime": "2025-02-28 23:59:59",
"status": "0",
"collectionType": "1",
"remark": "备注信息",
"classId": 101,
"className": "计算机2023-1",
"majorId": 10,
"majorName": "计算机科学与技术",
"collegeId": 1,
"collegeName": "计算机学院"
}
]
}
/stuColBatchClass/stuColBatchClass/getTeacherRelatedBatchesstuColBatchClass:stuColBatchClass:query请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | batchName | string | 否 | 批次名称(模糊查询) |
业务逻辑:
XgStudentManagerSourceServiceImpl.getCurrentUserAuthDeptTree() 获取当前用户有权限的部门树响应数据:
{
"code": 200,
"msg": "查询成功",
"data": [
{
"id": 1,
"batchName": "2025年春季学期信息收集",
"description": "收集学生基本信息",
"startTime": "2025-02-01 00:00:00",
"endTime": "2025-02-28 23:59:59",
"status": "0",
"collectionType": "1",
"remark": "备注信息",
"createBy": 1,
"createTime": "2025-01-27 10:00:00",
"updateBy": 1,
"updateTime": "2025-01-27 10:00:00"
}
]
}
/stuColBatchClass/stuColBatchClass/getBatchAuthScope/{batchId}stuColBatchClass:stuColBatchClass:query请求参数: | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| | batchId | long | 是 | 批次ID |
业务逻辑:
XgStudentManagerSourceServiceImpl.getCurrentUserAuthDeptTree() 获取当前用户所有的组织权限信息xg_stu_col_batch_class 中获取class_id数据(过滤条件:deleted=0)核心算法:
响应数据:
{
"code": 200,
"msg": "查询成功",
"data": [
{
"id": 1,
"label": "计算机学院",
"parentId": 101,
"deptCategory": "college",
"weight": 1,
"disabled": false,
"children": [
{
"id": 10,
"label": "计算机科学与技术",
"parentId": 1,
"deptCategory": "major",
"weight": 1,
"disabled": false,
"children": [
{
"id": 101,
"label": "计算机2023-1班",
"parentId": 10,
"deptCategory": "class",
"weight": 1,
"disabled": false,
"children": []
}
]
}
]
}
]
}
异常情况:
应用场景:
xg_student_manager 表中 manager_type = '1'dept_id = 101 下所有部门数据xg_student_manager_source 表中的授权范围xg_student_manager 表中 manager_type != '1'xg_class_msg 表中 class_teacher_id 等于当前用户ID-- 1. 查询用户授权的部门ID
SELECT auth_source FROM xg_student_manager_source
WHERE manager_id IN (
SELECT id FROM xg_student_manager WHERE user_id = #{currentUserId}
) AND status = '0' AND deleted = '0'
-- 2. 查询班主任权限
SELECT id FROM xg_class_msg
WHERE class_teacher_id = #{currentUserId} AND deleted = '0'
-- 3. 查询批次信息
SELECT DISTINCT b.* FROM xg_stu_col_batch b
INNER JOIN xg_stu_col_batch_class bc ON b.id = bc.batch_id
WHERE bc.class_id IN (权限范围内的部门ID)
AND b.deleted = 0 AND b.status = '0'
// 查询老师关联的批次信息
async function getTeacherBatches(batchName = '') {
try {
const response = await request({
url: '/stuColBatchClass/stuColBatchClass/getTeacherRelatedBatches',
method: 'get',
params: {
batchName: batchName
}
});
if (response.code === 200) {
console.log('批次列表:', response.data);
return response.data;
} else {
console.error('查询失败:', response.msg);
return [];
}
} catch (error) {
console.error('请求异常:', error);
return [];
}
}
// 设置批次权限范围
async function setBatchScope(batchId, deptIds) {
try {
const response = await request({
url: '/stuColBatchClass/stuColBatchClass/setScope',
method: 'post',
data: {
batchId: batchId,
deptIds: deptIds
}
});
if (response.code === 200) {
console.log('权限设置成功:', response.msg);
return true;
} else {
console.error('设置失败:', response.msg);
return false;
}
} catch (error) {
console.error('请求异常:', error);
return false;
}
}
// 查询学生可参与的批次
async function getStudentBatches() {
try {
const response = await uni.request({
url: baseURL + '/stuColBatchClass/stuColBatchClass/getStudentAvailableBatches',
method: 'GET',
header: {
'Authorization': 'Bearer ' + getToken(),
'Content-Type': 'application/json'
}
});
if (response.data.code === 200) {
return response.data.data;
} else {
uni.showToast({
title: response.data.msg || '查询失败',
icon: 'none'
});
return [];
}
} catch (error) {
console.error('请求异常:', error);
uni.showToast({
title: '网络异常',
icon: 'none'
});
return [];
}
}
getTeacherRelatedBatches 接口XgStuColBatchVo 缺少基础字段的问题