Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
030bbba3bb
@ -51,12 +51,13 @@
|
||||
placeholder="搜索学生"
|
||||
style="width: 200px;"
|
||||
allow-clear
|
||||
@search="handleSearch"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="filteredStudents"
|
||||
:data-source="students"
|
||||
:pagination="{ pageSize: 10 }"
|
||||
row-key="id"
|
||||
@row="handleRowClick"
|
||||
@ -86,7 +87,7 @@
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-button type="link" size="small" @click.stop="showStudentDetail(record)">
|
||||
<a-button type="link" size="small" @click.stop="handleShowDetail(record)">
|
||||
查看详情
|
||||
</a-button>
|
||||
</template>
|
||||
@ -167,7 +168,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ref, computed, onMounted, watch } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { message } from 'ant-design-vue';
|
||||
import {
|
||||
@ -176,8 +177,8 @@ import {
|
||||
BookOutlined,
|
||||
ReadOutlined,
|
||||
} from '@ant-design/icons-vue';
|
||||
import { getTeacherClassStudents, getStudentRecords } from '@/api/teacher';
|
||||
import type { Student } from '@/api/school';
|
||||
import { getTeacherClassStudents } from '@/api/teacher';
|
||||
import type { Student, ClassInfo } from '@/api/school';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const router = useRouter();
|
||||
@ -203,12 +204,6 @@ const columns = [
|
||||
{ title: '操作', key: 'action', width: 100 },
|
||||
];
|
||||
|
||||
const filteredStudents = computed(() => {
|
||||
if (!searchKeyword.value) return students.value;
|
||||
const keyword = searchKeyword.value.toLowerCase();
|
||||
return students.value.filter(s => s.name.toLowerCase().includes(keyword));
|
||||
});
|
||||
|
||||
const totalReadingCount = computed(() => {
|
||||
return students.value.reduce((sum, s) => sum + (s.readingCount || 0), 0);
|
||||
});
|
||||
@ -224,9 +219,11 @@ const getScoreColor = (score: number) => {
|
||||
|
||||
const goBack = () => router.back();
|
||||
|
||||
const handleRowClick = (record: Student) => {
|
||||
showStudentDetail(record);
|
||||
};
|
||||
const handleRowClick = (record: Record<string, unknown>, _index: number) => ({
|
||||
onClick: () => showStudentDetail(record as unknown as Student),
|
||||
});
|
||||
|
||||
const handleShowDetail = (record: unknown) => showStudentDetail(record as unknown as Student);
|
||||
|
||||
const showStudentDetail = async (student: Student) => {
|
||||
selectedStudent.value = student;
|
||||
@ -241,10 +238,12 @@ const showStudentDetail = async (student: Student) => {
|
||||
}
|
||||
};
|
||||
|
||||
const loadStudents = async () => {
|
||||
const loadStudents = async (params?: { keyword?: string }) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await getTeacherClassStudents(classId.value);
|
||||
const data = await getTeacherClassStudents(classId.value, {
|
||||
keyword: params?.keyword,
|
||||
});
|
||||
classInfo.value = data.class ? {
|
||||
id: data.class.id,
|
||||
name: data.class.name,
|
||||
@ -254,7 +253,8 @@ const loadStudents = async () => {
|
||||
} as any : null;
|
||||
students.value = data.items.map((s: any) => ({
|
||||
...s,
|
||||
avgScore: Math.round(Math.random() * 40 + 60), // 临时模拟数据
|
||||
// 使用接口返回的 avgScore,若未提供则显示 0(后端需在班级学生接口中计算并返回)
|
||||
avgScore: s.avgScore ?? 0,
|
||||
}));
|
||||
} catch (error: any) {
|
||||
message.error(error.message || '加载失败');
|
||||
@ -263,6 +263,17 @@ const loadStudents = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSearch = (value?: string) => {
|
||||
const keyword = (value ?? searchKeyword.value)?.trim() || undefined;
|
||||
loadStudents({ keyword });
|
||||
};
|
||||
|
||||
watch(searchKeyword, (newVal, oldVal) => {
|
||||
if (newVal === '' && oldVal !== undefined && oldVal !== '') {
|
||||
loadStudents();
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
loadStudents();
|
||||
});
|
||||
|
||||
@ -70,12 +70,10 @@
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-else key="empty" class="empty-content">
|
||||
<div class="empty-icon">
|
||||
<BookOpen :size="80" :stroke-width="1.5" />
|
||||
</div>
|
||||
<div class="empty-text">{{ props.currentLesson?.name || '准备开始' }}</div>
|
||||
<div class="empty-hint">点击下方资源开始播放</div>
|
||||
<div v-else key="empty" class="empty-content"> <button class="play-area-btn"
|
||||
:disabled="allLessonResources.length === 0" @click.stop="playCurrentResource">
|
||||
<Play :size="120" :stroke-width="2.5" />
|
||||
</button>
|
||||
</div>
|
||||
</Transition>
|
||||
</div>
|
||||
@ -198,6 +196,7 @@ import {
|
||||
VolumeX,
|
||||
MonitorPlay,
|
||||
Lightbulb,
|
||||
Play,
|
||||
} from 'lucide-vue-next';
|
||||
import EbookViewer from './viewers/EbookViewer.vue';
|
||||
import Player from '@/views/office/player.vue';
|
||||
@ -801,6 +800,12 @@ const handleResourceByIndex = (index: number) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 播放当前选中的资源
|
||||
const playCurrentResource = () => {
|
||||
if (allLessonResources.value.length === 0) return;
|
||||
handleResourceByIndex(currentResourceIndex.value);
|
||||
};
|
||||
|
||||
// 上一个资源
|
||||
const prevResource = () => {
|
||||
if (currentResourceIndex.value > 0) {
|
||||
@ -1227,6 +1232,37 @@ onUnmounted(() => {
|
||||
opacity: 0.7;
|
||||
color: #8D6E63;
|
||||
}
|
||||
|
||||
.play-area-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 160px;
|
||||
height: 160px;
|
||||
margin-top: 32px;
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #FF9800 0%, #FF6F00 100%);
|
||||
border: 4px solid #E65100;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 8px 32px rgba(255, 111, 0, 0.45);
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
transform: scale(1.08);
|
||||
box-shadow: 0 12px 40px rgba(255, 111, 0, 0.55);
|
||||
}
|
||||
|
||||
&:active:not(:disabled) {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 底部固定导航
|
||||
@ -1511,7 +1547,8 @@ onUnmounted(() => {
|
||||
|
||||
.resources-section {
|
||||
margin-bottom: 16px;
|
||||
padding: 4px 0; /* 为动画留出上下呼吸空间,避免被父级裁剪 */
|
||||
padding: 4px 0;
|
||||
/* 为动画留出上下呼吸空间,避免被父级裁剪 */
|
||||
|
||||
.section-label {
|
||||
display: flex;
|
||||
@ -1533,7 +1570,8 @@ onUnmounted(() => {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
overflow-x: auto;
|
||||
padding: 16px 12px; /* 增加内边距,为 scale/shadow 动画留出空间 */
|
||||
padding: 16px 12px;
|
||||
/* 增加内边距,为 scale/shadow 动画留出空间 */
|
||||
flex-wrap: wrap;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
|
||||
@ -21,9 +21,12 @@ import com.reading.platform.dto.response.StudentResponse;
|
||||
import com.reading.platform.entity.Clazz;
|
||||
import com.reading.platform.entity.ClassTeacher;
|
||||
import com.reading.platform.entity.Lesson;
|
||||
import com.reading.platform.entity.ParentStudent;
|
||||
import com.reading.platform.entity.Student;
|
||||
import com.reading.platform.entity.Teacher;
|
||||
import com.reading.platform.mapper.ClassTeacherMapper;
|
||||
import com.reading.platform.mapper.ParentMapper;
|
||||
import com.reading.platform.mapper.ParentStudentMapper;
|
||||
import com.reading.platform.mapper.LessonMapper;
|
||||
import com.reading.platform.service.ClassService;
|
||||
import com.reading.platform.service.StudentService;
|
||||
@ -52,6 +55,8 @@ public class SchoolClassController {
|
||||
private final StudentMapper studentMapper;
|
||||
private final TeacherService teacherService;
|
||||
private final LessonMapper lessonMapper;
|
||||
private final ParentMapper parentMapper;
|
||||
private final ParentStudentMapper parentStudentMapper;
|
||||
|
||||
@Operation(summary = "Create class")
|
||||
@Log(module = LogModule.CLASS, type = LogOperationType.CREATE, description = "创建新班级")
|
||||
@ -205,6 +210,20 @@ public class SchoolClassController {
|
||||
classService.getClassByIdWithTenantCheck(id, tenantId);
|
||||
Page<Student> page = studentService.getStudentsByClassId(id, pageNum, pageSize, keyword);
|
||||
List<StudentResponse> voList = studentMapper.toVO(page.getRecords());
|
||||
for (StudentResponse vo : voList) {
|
||||
var parentRelation = parentStudentMapper.selectOne(
|
||||
new LambdaQueryWrapper<ParentStudent>()
|
||||
.eq(ParentStudent::getStudentId, vo.getId())
|
||||
.eq(ParentStudent::getIsPrimary, 1)
|
||||
.last("LIMIT 1"));
|
||||
if (parentRelation != null) {
|
||||
var parent = parentMapper.selectById(parentRelation.getParentId());
|
||||
if (parent != null) {
|
||||
vo.setParentName(parent.getName());
|
||||
vo.setParentPhone(parent.getPhone());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success(PageResult.of(voList, page.getTotal(), page.getCurrent(), page.getSize()));
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import com.reading.platform.common.security.SecurityUtils;
|
||||
import com.reading.platform.dto.request.StudentCreateRequest;
|
||||
import com.reading.platform.dto.request.StudentUpdateRequest;
|
||||
import com.reading.platform.dto.request.TransferStudentRequest;
|
||||
import com.reading.platform.dto.response.StudentImportTemplateResponse;
|
||||
import com.reading.platform.dto.response.StudentResponse;
|
||||
import com.reading.platform.dto.response.StudentTransferHistoryItemResponse;
|
||||
import com.reading.platform.entity.Student;
|
||||
@ -24,6 +25,7 @@ import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -137,6 +139,22 @@ public class SchoolStudentController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "Get student import template")
|
||||
@GetMapping("/import/template")
|
||||
public Result<StudentImportTemplateResponse> getImportTemplate() {
|
||||
return Result.success(new StudentImportTemplateResponse(
|
||||
Arrays.asList("姓名", "性别", "出生日期", "班级ID", "家长姓名", "家长电话"),
|
||||
Arrays.asList("张小明", "男", "2020-01-15", "1", "张三", "13800138000"),
|
||||
Arrays.asList(
|
||||
"姓名为必填项",
|
||||
"性别可选:男/女,默认为男",
|
||||
"出生日期格式:YYYY-MM-DD",
|
||||
"班级ID为必填项,可在班级管理中查看",
|
||||
"家长姓名和家长电话为选填项"
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@Operation(summary = "Get student class transfer history")
|
||||
@GetMapping("/{id}/history")
|
||||
public Result<List<StudentTransferHistoryItemResponse>> getStudentClassHistory(@PathVariable Long id) {
|
||||
|
||||
@ -19,11 +19,15 @@ import com.reading.platform.dto.response.StudentResponse;
|
||||
import com.reading.platform.dto.response.TeacherResponse;
|
||||
import com.reading.platform.entity.Clazz;
|
||||
import com.reading.platform.entity.Lesson;
|
||||
import com.reading.platform.entity.ParentStudent;
|
||||
import com.reading.platform.entity.CoursePackage;
|
||||
import com.reading.platform.entity.Student;
|
||||
import com.reading.platform.entity.Teacher;
|
||||
import com.reading.platform.entity.CourseLesson;
|
||||
import com.reading.platform.mapper.LessonMapper;
|
||||
import com.reading.platform.mapper.ParentMapper;
|
||||
import com.reading.platform.mapper.ParentStudentMapper;
|
||||
import com.reading.platform.mapper.StudentRecordMapper;
|
||||
import com.reading.platform.service.ClassService;
|
||||
import com.reading.platform.service.CourseLessonService;
|
||||
import com.reading.platform.service.CoursePackageService;
|
||||
@ -55,6 +59,9 @@ public class TeacherCourseController {
|
||||
private final StudentMapper studentMapper;
|
||||
private final TeacherMapper teacherMapper;
|
||||
private final LessonMapper lessonMapper;
|
||||
private final ParentMapper parentMapper;
|
||||
private final ParentStudentMapper parentStudentMapper;
|
||||
private final StudentRecordMapper studentRecordMapper;
|
||||
|
||||
@Operation(summary = "获取教师的班级列表")
|
||||
@GetMapping("/classes")
|
||||
@ -183,6 +190,37 @@ public class TeacherCourseController {
|
||||
Clazz clazz = classService.getClassByIdWithTenantCheck(id, tenantId);
|
||||
Page<Student> page = studentService.getStudentsByClassId(id, pageNum, pageSize, keyword);
|
||||
List<StudentResponse> voList = studentMapper.toVO(page.getRecords());
|
||||
List<Long> studentIds = voList.stream().map(StudentResponse::getId).toList();
|
||||
List<Map<String, Object>> statsList = studentIds.isEmpty()
|
||||
? List.of()
|
||||
: studentRecordMapper.selectStudentStats(studentIds);
|
||||
Map<Long, Map<String, Object>> statsMap = statsList.stream()
|
||||
.collect(Collectors.toMap(m -> ((Number) m.get("studentId")).longValue(), m -> m));
|
||||
|
||||
for (StudentResponse vo : voList) {
|
||||
var parentRelation = parentStudentMapper.selectOne(
|
||||
new LambdaQueryWrapper<ParentStudent>()
|
||||
.eq(ParentStudent::getStudentId, vo.getId())
|
||||
.eq(ParentStudent::getIsPrimary, 1)
|
||||
.last("LIMIT 1"));
|
||||
if (parentRelation != null) {
|
||||
var parent = parentMapper.selectById(parentRelation.getParentId());
|
||||
if (parent != null) {
|
||||
vo.setParentName(parent.getName());
|
||||
vo.setParentPhone(parent.getPhone());
|
||||
}
|
||||
}
|
||||
var stats = statsMap.get(vo.getId());
|
||||
if (stats != null) {
|
||||
vo.setReadingCount(((Number) stats.getOrDefault("readingCount", 0)).intValue());
|
||||
vo.setLessonCount(vo.getReadingCount());
|
||||
vo.setAvgScore(((Number) stats.getOrDefault("avgScore", 0)).intValue());
|
||||
} else {
|
||||
vo.setReadingCount(0);
|
||||
vo.setLessonCount(0);
|
||||
vo.setAvgScore(0);
|
||||
}
|
||||
}
|
||||
|
||||
int studentCount = studentService.getStudentListByClassId(id).size();
|
||||
long lessonCount = 0;
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package com.reading.platform.dto.response;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 学生导入模板响应
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "学生导入模板")
|
||||
public class StudentImportTemplateResponse {
|
||||
|
||||
@Schema(description = "表头列表")
|
||||
private List<String> headers;
|
||||
|
||||
@Schema(description = "示例行")
|
||||
private List<String> example;
|
||||
|
||||
@Schema(description = "说明事项")
|
||||
private List<String> notes;
|
||||
}
|
||||
@ -66,4 +66,13 @@ public class StudentResponse {
|
||||
|
||||
@Schema(description = "家长电话")
|
||||
private String parentPhone;
|
||||
|
||||
@Schema(description = "阅读/上课次数(student_record 条数)")
|
||||
private Integer readingCount;
|
||||
|
||||
@Schema(description = "上课次数(同 readingCount)")
|
||||
private Integer lessonCount;
|
||||
|
||||
@Schema(description = "平均得分(专注度+参与度平均后 1-5 转 0-100 百分比)")
|
||||
private Integer avgScore;
|
||||
}
|
||||
|
||||
@ -7,10 +7,27 @@ import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface StudentRecordMapper extends BaseMapper<StudentRecord> {
|
||||
|
||||
/**
|
||||
* 按学生 ID 批量统计:阅读次数、平均得分(专注度+参与度 1-5 转 0-100)
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT sr.student_id AS studentId, " +
|
||||
" COUNT(sr.id) AS readingCount, " +
|
||||
" ROUND(COALESCE(AVG((COALESCE(sr.focus,0)+COALESCE(sr.participation,0))/2.0), 0) * 20) AS avgScore " +
|
||||
"FROM student_record sr " +
|
||||
"INNER JOIN lesson l ON sr.lesson_id = l.id AND l.status = 'COMPLETED' AND l.deleted = 0 " +
|
||||
"WHERE sr.deleted = 0 AND sr.student_id IN " +
|
||||
"<foreach collection='studentIds' item='id' open='(' separator=',' close=')'>#{id}</foreach> " +
|
||||
"GROUP BY sr.student_id" +
|
||||
"</script>")
|
||||
List<Map<String, Object>> selectStudentStats(@Param("studentIds") List<Long> studentIds);
|
||||
|
||||
/**
|
||||
* 统计指定时间段内有上课记录的去重学生数
|
||||
* @param startTime 开始时间
|
||||
|
||||
@ -712,19 +712,45 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>
|
||||
wrapper.eq(Task::getStatus, status);
|
||||
}
|
||||
|
||||
// TODO: 实现更多筛选条件
|
||||
// - classIds: 班级筛选(需要关联 task_target 表)
|
||||
// - teacherIds: 教师筛选
|
||||
// - dateType/startDate/endDate: 时间筛选
|
||||
// - completionRate: 完成率筛选
|
||||
// - sortBy/sortOrder: 排序
|
||||
// 时间筛选:任务的 startDate~dueDate 与查询范围有交集的纳入结果
|
||||
// 交集条件:task.startDate <= endDate AND task.dueDate >= startDate
|
||||
if (StringUtils.hasText(startDate) && StringUtils.hasText(endDate)) {
|
||||
try {
|
||||
LocalDate rangeStart = LocalDate.parse(startDate);
|
||||
LocalDate rangeEnd = LocalDate.parse(endDate);
|
||||
// 任务开始日期 <= 查询结束日期(任务不能完全在查询范围之后)
|
||||
wrapper.le(Task::getStartDate, rangeEnd);
|
||||
// 任务截止日期 >= 查询开始日期(任务不能完全在查询范围之前)
|
||||
wrapper.and(w -> w.ge(Task::getDueDate, rangeStart).or().isNull(Task::getDueDate));
|
||||
} catch (Exception e) {
|
||||
log.warn("解析日期参数失败 startDate={}, endDate={}", startDate, endDate, e);
|
||||
}
|
||||
} else if (StringUtils.hasText(startDate)) {
|
||||
try {
|
||||
LocalDate rangeStart = LocalDate.parse(startDate);
|
||||
wrapper.ge(Task::getDueDate, rangeStart);
|
||||
} catch (Exception e) {
|
||||
log.warn("解析 startDate 参数失败: {}", startDate, e);
|
||||
}
|
||||
} else if (StringUtils.hasText(endDate)) {
|
||||
try {
|
||||
LocalDate rangeEnd = LocalDate.parse(endDate);
|
||||
wrapper.le(Task::getStartDate, rangeEnd);
|
||||
} catch (Exception e) {
|
||||
log.warn("解析 endDate 参数失败: {}", endDate, e);
|
||||
}
|
||||
}
|
||||
|
||||
// 默认排序
|
||||
if ("completionRate".equals(sortBy)) {
|
||||
// 完成率排序需要特殊处理,暂时使用创建时间
|
||||
wrapper.orderByDesc(Task::getCreatedAt);
|
||||
// TODO: classIds、teacherIds、completionRate 筛选待实现
|
||||
|
||||
// 排序
|
||||
boolean asc = "asc".equalsIgnoreCase(sortOrder);
|
||||
if ("startDate".equals(sortBy)) {
|
||||
wrapper.orderBy(true, asc, Task::getStartDate);
|
||||
} else if ("endDate".equals(sortBy) || "dueDate".equals(sortBy)) {
|
||||
wrapper.orderBy(true, asc, Task::getDueDate);
|
||||
} else {
|
||||
wrapper.orderByDesc(Task::getCreatedAt);
|
||||
wrapper.orderBy(true, asc, Task::getCreatedAt);
|
||||
}
|
||||
|
||||
Page<Task> taskPage = taskMapper.selectPage(page, wrapper);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user