parent
f8bb522636
commit
793e29afbb
|
|
@ -22,10 +22,14 @@ export default {
|
|||
//班级相关
|
||||
takeClassByInviteCode: (data) => request.post('/classes/takeClassByInviteCode', data), //加入班级
|
||||
|
||||
getClassStudents:(config) =>
|
||||
request.get('/classes/getClassStudents',(config) ),//获取学生所在班级人数
|
||||
|
||||
//作业题目部分
|
||||
getExamList: (config) => request.get('/problem/getExamList',config),//学生获取作业列表
|
||||
|
||||
getStudentRank:(config) => request.get('/problem/getStudentRank', config),//获取学生当前报告成绩排名
|
||||
|
||||
getClassRanks:(config) => request.get('/problem/getClassRanks', config),//获取当前报告班级排名
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,20 @@ export function formatDateTimeNoSecond(time = undefined, format = 'YYYY-MM-DD HH
|
|||
export function formatDate(date = undefined, format = 'YYYY-MM-DD') {
|
||||
return formatDateTime(date, format)
|
||||
}
|
||||
export function formatTimestamp(timestamp){
|
||||
if (timestamp) {
|
||||
const date = new Date(timestamp);
|
||||
export function formatTimestamp(timestampArray) {
|
||||
if (timestampArray && Array.isArray(timestampArray) && timestampArray.length >= 5) {
|
||||
const year = timestampArray[0];
|
||||
const month = timestampArray[1];
|
||||
const day = timestampArray[2];
|
||||
const hours = timestampArray[3];
|
||||
const minutes = timestampArray[4];
|
||||
const seconds = timestampArray.length > 5 ? timestampArray[5] : 0; // 如果有秒数则使用,否则默认为0
|
||||
|
||||
// 创建Date对象时,月份需要减1,因为JavaScript的月份是从0开始的
|
||||
const date = new Date(year, month - 1, day, hours, minutes, seconds);
|
||||
|
||||
return date.getFullYear() + '-' +
|
||||
('0' + (date.getMonth() + 1)).slice(-2) + '-' +
|
||||
('0' + (date.getMonth()+1)).slice(-2) + '-' +//这里再加回来
|
||||
('0' + date.getDate()).slice(-2) + ' ' +
|
||||
('0' + date.getHours()).slice(-2) + ':' +
|
||||
('0' + date.getMinutes()).slice(-2) + ':' +
|
||||
|
|
|
|||
|
|
@ -60,8 +60,9 @@ const onViewScore = (exam) => {//点击成绩控件的逻辑
|
|||
// }
|
||||
|
||||
const examId = exam.id
|
||||
const classId = exam.classId
|
||||
|
||||
router.push({ name: 'UserScoreAndRank', params: { examId }, query: { fromclient: false } });
|
||||
router.push({ name: 'UserScoreAndRank', params: { examId,classId }, query: { fromclient: false } });
|
||||
|
||||
// switch (trainingViewScore) {
|
||||
// case 'NewScorePage': // 直接转向成绩排名页面
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ export default {
|
|||
},
|
||||
{
|
||||
name: 'UserScoreAndRank',
|
||||
path: 'score-rank/:examId',
|
||||
path: 'score-rank/:examId/:classId',
|
||||
component: () => import('./score-rank/index.vue'),
|
||||
meta: {
|
||||
title: '作业成绩',
|
||||
|
|
|
|||
|
|
@ -1,11 +1,106 @@
|
|||
<template>
|
||||
<p>此处布置班级排名表格</p>
|
||||
<div class="page-content">
|
||||
<h2 class="title">
|
||||
班级排名
|
||||
</h2>
|
||||
|
||||
<el-table :data="tableData" stripe border style="width:65%">
|
||||
<el-table-column prop="rank" label="排名" width="190" />
|
||||
<el-table-column prop="score" label="成绩" width="190" />
|
||||
<el-table-column prop="studentNo" label="学号" />
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import api from '@/api/user'
|
||||
import {useRoute} from 'vue-router';
|
||||
const route = useRoute()
|
||||
const examId = route.params.examId;
|
||||
const classId = route.params.classId;
|
||||
const score = ref(0); // 得分
|
||||
const rank = ref(0); // 排名
|
||||
const studentId = ref(0); //学号
|
||||
const tableData = ref([]); // 初始化一个响应式变量来存储表格数据
|
||||
const paginationReactive = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
itemCount: 0,
|
||||
prefix({ itemCount }) {
|
||||
return `总共 ${itemCount} 条`
|
||||
},
|
||||
})
|
||||
|
||||
const columns = [
|
||||
{
|
||||
key: 'rank',
|
||||
title: '排名',
|
||||
width: 50,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
key: 'score',
|
||||
title: '成绩',
|
||||
width: 50,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
key: 'studentId',
|
||||
title: '学号',
|
||||
width: 50,
|
||||
align: 'center',
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
const queryStudentRanks = async (currentPage) => {
|
||||
try {
|
||||
const res = await api.getClassRanks({
|
||||
params: {
|
||||
pageNum: currentPage,
|
||||
pageSize: paginationReactive.pageSize,
|
||||
classId,
|
||||
examId
|
||||
},
|
||||
})
|
||||
|
||||
tableData.value = res.data; // 将整个列表赋值给 tableData
|
||||
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
const onChangePage = (page) => {
|
||||
paginationReactive.page = page
|
||||
if (!loading.value) {
|
||||
queryStudentRanks(page)
|
||||
}
|
||||
}
|
||||
|
||||
const rowKey = (rowData) => {
|
||||
return rowData.studentId
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
queryStudentRanks(paginationReactive.page)
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-content {
|
||||
width: 40%;
|
||||
margin-left: 15px;
|
||||
}
|
||||
.title {
|
||||
padding-left: 0px;
|
||||
font-size: 22px;
|
||||
font-weight: normal;
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
<div class="score-info">
|
||||
<p class="personal-score">个人成绩:</p>
|
||||
<p>成绩:{{ score }}</p>
|
||||
<p>排名:{{ rank }}</p>
|
||||
<p>排名:{{ rank }}/{{ totalStudents }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -17,9 +17,11 @@ import api from '@/api/user';
|
|||
import {useRoute} from 'vue-router';
|
||||
const route = useRoute()
|
||||
const examId = route.params.examId;
|
||||
const classId = route.params.classId;
|
||||
const title = ref(""); // 从API获取的作业名称
|
||||
const score = ref(0); // 个人得分
|
||||
const rank = ref(0); // 个人排名
|
||||
const totalStudents = ref(0); // 班级总人数
|
||||
|
||||
const paginationReactive = reactive({
|
||||
page: 1,
|
||||
|
|
@ -45,18 +47,25 @@ const columns = [
|
|||
// ... 列配置
|
||||
];
|
||||
|
||||
// 查询个人成绩的函数
|
||||
// 左侧查询个人成绩的函数
|
||||
const queryExamScores = async () => {
|
||||
//查询个人排名
|
||||
const res = await api.getStudentRank({
|
||||
params: { examId }
|
||||
});
|
||||
//查询班级总人数
|
||||
const res1 = await api.getClassStudents({
|
||||
params: { classId }
|
||||
});
|
||||
|
||||
title.value = res.data.title; // 更新作业名称
|
||||
score.value = res.data.score; // 更新个人得分
|
||||
rank.value = res.data.rank; // 更新个人排名
|
||||
|
||||
|
||||
console.log(res1);
|
||||
totalStudents.value = res1.data;// 更新班级总人数
|
||||
};
|
||||
|
||||
|
||||
// 行键函数
|
||||
const rowKey = (rowData) => {
|
||||
return rowData.id;
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ import ClassScore from '@/views/user/score-rank/components/class-score.vue'
|
|||
}
|
||||
|
||||
.personal-rank {
|
||||
flex: 0 0 40%; /* UserPersonalRank 占据 40% 的空间 */
|
||||
flex: 0 0 20%; /* UserPersonalRank 占据 40% 的空间 */
|
||||
/* 其他样式,例如 padding, margin 等 */
|
||||
}
|
||||
|
||||
.class-score {
|
||||
flex: 0 0 60%; /* ClassScore 占据 60% 的空间 */
|
||||
flex: 0 0 80%; /* ClassScore 占据 60% 的空间 */
|
||||
/* 其他样式,例如 padding, margin 等 */
|
||||
}
|
||||
</style>
|
||||
|
|
@ -270,4 +270,31 @@ public RespBean findStudentSubmit(@RequestBody PMStudentSubmit pmStudentSubmit){
|
|||
return RespBean.error("查询成绩排名失败!");
|
||||
}
|
||||
}
|
||||
|
||||
//获取当前作业班级排名信息
|
||||
@GetMapping("/getClassRanks")
|
||||
public RespBean getClassRanks(Integer pageNum,Integer pageSize,Integer classId,Integer examId){
|
||||
if (pageNum < 1 || pageSize < 1)
|
||||
return RespBean.error("参数错误!");
|
||||
UReportSubmitted uReportSubmitted=new UReportSubmitted();
|
||||
uReportSubmitted.setPageNum(pageNum);
|
||||
uReportSubmitted.setPageSize(pageSize);
|
||||
|
||||
List<UReportSubmitted> uReportsSubmitted=problemServiceI.findClassRankByIds(examId,classId);
|
||||
|
||||
|
||||
|
||||
// //分页处理
|
||||
// DataGrid dataGrid = problemServiceI.dataGrid(pMproblems,pMproblem);
|
||||
//
|
||||
if (uReportsSubmitted != null) {
|
||||
return RespBean.ok("获取班级排名列表成功!",uReportsSubmitted);
|
||||
} else {
|
||||
return RespBean.error("获取班级排名列表失败!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public interface ProblemDaoI extends BaseDaoI<Problem> {
|
|||
List<ReportSubmitted> findPMProblemStatusesByStudentIdAndProblemsIds(List<Integer> problemIds, Integer studentId);
|
||||
|
||||
UReportSubmitted getScoreAndRankByIds(int problemId, int userId);
|
||||
|
||||
List<UReportSubmitted> getClassRankByIds(int problemId, int classId);
|
||||
|
||||
public String findProblemByTitle(String title);
|
||||
public String findProblemByTitle(String title,Integer id);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ import com.example.aes.problem.model.Problem;
|
|||
import com.example.aes.problem.model.*;
|
||||
import com.example.aes.problem.model.ReportSubmitted;
|
||||
import com.example.aes.user.dao.BaseDaoI;
|
||||
import com.example.aes.user.dao.ClassesDaoI;
|
||||
import com.example.aes.user.dao.ClassstudentsDaoI;
|
||||
import com.example.aes.user.dao.impl.BaseDaoImpl;
|
||||
import com.example.aes.user.model.Classstudents;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import com.ibm.jvm.trace.format.api.TraceContext;
|
||||
|
|
@ -26,10 +29,16 @@ import java.util.Objects;
|
|||
|
||||
@Repository("ProblemDao")
|
||||
public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
|
||||
private ClassesDaoI classesDao;
|
||||
|
||||
@Autowired
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public void setClassesDao(ClassesDaoI classesDao) {
|
||||
this.classesDao = classesDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PMProblem> findProblemsByClassIds(List<Integer> classIds) {
|
||||
// 检查classIds是否为空或没有元素
|
||||
|
|
@ -37,7 +46,7 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
String sql = "SELECT pr.id AS Id, pp.startTime AS startTime, pp.endTime AS endTime, " +
|
||||
String sql = "SELECT pr.id AS Id, pp.startTime AS startTime, pp.endTime AS endTime, pp.classId AS classId," +
|
||||
"pr.title AS title, pr.description AS description " +
|
||||
"FROM postproblem pp " +
|
||||
"JOIN problem pr ON pp.problemId = pr.id " +
|
||||
|
|
@ -96,9 +105,9 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
|
|||
|
||||
}
|
||||
|
||||
@Override //根据作业id和学生id获取学生当前报告成绩排名
|
||||
@Override //根据作业id和学生id获取学生当前报告成绩与排名等信息
|
||||
public UReportSubmitted getScoreAndRankByIds(int problemId, int userId) {
|
||||
|
||||
//此部分获得该学生确定的个人报告成绩和报告名称信息
|
||||
String sql = "SELECT sr.*, p.title " +
|
||||
"FROM submitreport sr " +
|
||||
"JOIN problem p ON sr.problemId = p.id " +
|
||||
|
|
@ -110,8 +119,119 @@ public class ProblemDaoImpl extends BaseDaoImpl<Problem> implements ProblemDaoI{
|
|||
new BeanPropertyRowMapper<>(UReportSubmitted.class)
|
||||
);
|
||||
|
||||
// 查询假定只有唯一一条数据,返回第一条记录
|
||||
return queryResults.isEmpty() ? null : queryResults.get(0);
|
||||
//以下部分负责计算统计该报告在同班内排名信息
|
||||
|
||||
// 获取与当前用户同班级的所有同学信息
|
||||
List<Classstudents> classmates = classesDao.findClassStudentsByClassId(userId);
|
||||
|
||||
// 获取同班同学以及当前用户的报告成绩
|
||||
List<UReportSubmitted> classReports = new ArrayList<>();
|
||||
for (Classstudents classmate : classmates) {
|
||||
String classmateSql = "SELECT sr.score,sr.studentId,sr.problemId " +
|
||||
"FROM submitreport sr " +
|
||||
"WHERE sr.studentId = ? AND sr.problemId = ?";
|
||||
List<UReportSubmitted> classmateReports = jdbcTemplate.query(
|
||||
classmateSql,
|
||||
new Object[]{classmate.getUserId(), problemId},
|
||||
new BeanPropertyRowMapper<>(UReportSubmitted.class)
|
||||
);
|
||||
classReports.addAll(classmateReports);
|
||||
}
|
||||
|
||||
float temp = 0;
|
||||
// 处理默认分数为空的情况,将它们视为0分
|
||||
classReports.forEach(report -> {
|
||||
if (report.getScore() == null) {
|
||||
report.setScore(temp);
|
||||
}
|
||||
});
|
||||
|
||||
// 根据成绩进行排序
|
||||
classReports.sort((r1, r2) -> r2.getScore().compareTo(r1.getScore()));
|
||||
|
||||
// 计算排名,处理同分同排名的情况
|
||||
int rank = 1;
|
||||
Float lastScore = null; // 用于记录上一个分数
|
||||
for (UReportSubmitted report : classReports) {
|
||||
// 如果当前分数与上一个分数不同,则更新排名
|
||||
if (lastScore == null || !lastScore.equals(report.getScore())) {
|
||||
rank = classReports.indexOf(report) + 1;
|
||||
}
|
||||
// 如果找到了当前用户的报告,则设置排名并退出循环
|
||||
if (report.getStudentId() == userId) {
|
||||
report.setRank(rank);
|
||||
break;
|
||||
}
|
||||
lastScore = report.getScore(); // 更新上一个分数
|
||||
}
|
||||
|
||||
// 查询假定只有唯一一条数据,返回第一条记录,并设置排名
|
||||
UReportSubmitted userReport = queryResults.isEmpty() ? null : queryResults.get(0);
|
||||
if (userReport != null) {
|
||||
// 设置计算出的排名
|
||||
userReport.setRank(rank);
|
||||
}
|
||||
|
||||
return userReport;
|
||||
}
|
||||
|
||||
@Override //根据作业id和班级id获取当前班级作业排名信息列表
|
||||
public List<UReportSubmitted> getClassRankByIds(int problemId, int classId) {
|
||||
|
||||
// 获取与当前用户同班级的所有同学信息
|
||||
List<Classstudents> classmates = classesDao.findClassStudentsByClassId(classId);
|
||||
// 从 classmates 列表中提取出所有的 userId
|
||||
List<Integer> studentIds = classmates.stream()
|
||||
.map(Classstudents::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
// 获取所有学生的报告成绩
|
||||
List<UReportSubmitted> classReports = new ArrayList<>();
|
||||
for (Integer studentId : studentIds) {
|
||||
String sql = "SELECT sr.score, sr.studentId, sr.problemId " +
|
||||
"FROM submitreport sr " +
|
||||
"WHERE sr.studentId = ? AND sr.problemId = ?";
|
||||
List<UReportSubmitted> reports = jdbcTemplate.query(
|
||||
sql,
|
||||
new Object[]{studentId, problemId},
|
||||
new BeanPropertyRowMapper<>(UReportSubmitted.class)
|
||||
);
|
||||
classReports.addAll(reports);
|
||||
}
|
||||
|
||||
// 处理默认分数为空的情况,将它们视为0分
|
||||
classReports.forEach(report -> {
|
||||
if (report.getScore() == null) {
|
||||
report.setScore(0f);
|
||||
}
|
||||
});
|
||||
|
||||
// 根据成绩进行排序
|
||||
classReports.sort((r1, r2) -> r2.getScore().compareTo(r1.getScore()));
|
||||
|
||||
// 计算排名,处理同分同排名的情况
|
||||
int rank = 1;
|
||||
Float lastScore = null;
|
||||
for (UReportSubmitted report : classReports) {
|
||||
if (lastScore == null || !lastScore.equals(report.getScore())) {
|
||||
rank = classReports.indexOf(report) + 1;
|
||||
}
|
||||
report.setRank(rank);
|
||||
lastScore = report.getScore();
|
||||
}
|
||||
|
||||
// 查询学号
|
||||
for (UReportSubmitted report : classReports) {
|
||||
String studentNoSql = "SELECT u.studentNo FROM users u WHERE u.id = ?";
|
||||
String studentNo = jdbcTemplate.queryForObject(
|
||||
studentNoSql,
|
||||
new Object[]{report.getStudentId()},
|
||||
String.class
|
||||
);
|
||||
report.setStudentNo(studentNo);
|
||||
}
|
||||
|
||||
// 返回包含所有信息的列表
|
||||
return classReports;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,4 +10,8 @@ public class UReportSubmitted extends ReportSubmitted implements java.io.Seriali
|
|||
String StudentNo;//学号
|
||||
|
||||
int rank;//排名
|
||||
|
||||
// 排名列表分页
|
||||
private int pageNum;
|
||||
private int pageSize;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,10 @@ package com.example.aes.problem.service.Impl;
|
|||
|
||||
import com.example.aes.problem.dao.*;
|
||||
import com.example.aes.problem.model.*;
|
||||
import com.example.aes.problem.model.*;
|
||||
import com.example.aes.problem.service.ProblemServiceI;
|
||||
import com.example.aes.user.dao.AdminusersDaoI;
|
||||
import com.example.aes.user.dao.ClassesDaoI;
|
||||
import com.example.aes.user.model.DataGrid;
|
||||
import com.example.aes.user.model.Classstudents;
|
||||
import com.example.aes.user.model.Course;
|
||||
import com.example.aes.user.model.PMCourse;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -181,6 +176,12 @@ public class ProblemServiceImpl implements ProblemServiceI {
|
|||
return uReportSubmitted;
|
||||
}
|
||||
|
||||
@Override //根据作业id和班级id获取学生当前报告成绩排名
|
||||
public List<UReportSubmitted> findClassRankByIds(int problemId, int classId) {
|
||||
List<UReportSubmitted> uReportSubmitted = problemDao.getClassRankByIds(problemId, classId);
|
||||
return uReportSubmitted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScoringStandard> findStandardIdNoProblemId(){
|
||||
return scoringStandardDao.getStandardIdNoProblemIdDesc();
|
||||
|
|
@ -537,14 +538,6 @@ public class ProblemServiceImpl implements ProblemServiceI {
|
|||
pmStudentSubmit.setFinalScore((float) p[4]);
|
||||
pmStudentSubmitList.add(pmStudentSubmit);
|
||||
|
||||
PMProblem pmProblem=new PMProblem();
|
||||
pmProblem.setId(problem.getId());
|
||||
pmProblem.setCourseId(problem.getCourseId());
|
||||
pmProblem.setAdminuserId(problem.getAdminuserId());
|
||||
pmProblem.setTeacherName(adminusersDao.findTeacherNameByTeacherId(problem.getAdminuserId()));
|
||||
pmProblem.setTitle(problem.getTitle());
|
||||
pmProblem.setDescription(problem.getDescription());
|
||||
pmp.add(pmProblem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ public interface ProblemServiceI {
|
|||
|
||||
public void findStatusByStudentIdAndProblems(Integer studentId, List<PMProblem> pMproblems);
|
||||
|
||||
UReportSubmitted findScoreAndRankByIds(int ProblemId, int userId);
|
||||
public UReportSubmitted findScoreAndRankByIds(int ProblemId, int userId);
|
||||
public List<UReportSubmitted> findClassRankByIds(int problemId, int classId);
|
||||
public List<PostProblem> findPostProblem(int problemId,int classId);
|
||||
public int editPostProblem( int classId,
|
||||
int problemId,
|
||||
|
|
|
|||
|
|
@ -9,10 +9,7 @@ import com.example.aes.user.model.*;
|
|||
import com.example.aes.user.service.ClassesServiceI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
|
@ -221,4 +218,15 @@ public class ClassesController{
|
|||
else return RespBean.ok("查找班级成功", classstudentsList);
|
||||
}
|
||||
|
||||
@GetMapping("/getClassStudents")// 根据班级id查找所在班级人数
|
||||
public RespBean getClassStudents(@RequestParam("classId") int classId)
|
||||
{
|
||||
List<Classstudents> classstudentsList = classesServiceI.getClassStudentsByClassId(classId);
|
||||
int counts = classstudentsList.size();
|
||||
if (classstudentsList == null || classstudentsList.isEmpty()) { // 如果列表为空,返回错误信息
|
||||
return RespBean.error("没有找到相关班级及人数");
|
||||
}
|
||||
else return RespBean.ok("查找成功", counts);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,4 +47,7 @@ public interface ClassesDaoI extends BaseDaoI<Classes> {
|
|||
public List<Classstudents>findClassIdByStudentId(int studentId);//根据班级id查找学生id
|
||||
public List<Classes> findClassByCourseId(int courseId);
|
||||
public List<Classes> findClassById(int classId);
|
||||
|
||||
public List<Classstudents> findClassStudentsByClassId(int classId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -575,5 +575,14 @@ public class ClassesDaoImpl extends BaseDaoImpl<Classes> implements ClassesDaoI
|
|||
return this.find(hql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Classstudents> findClassStudentsByClassId(int classId) {
|
||||
// 直接根据classId查询出该班级的所有学生信息
|
||||
String hqlForClassStudents = "from Classstudents c where c.classId = :classId";
|
||||
Query qForClassStudents = this.getCurrentSession().createQuery(hqlForClassStudents);
|
||||
qForClassStudents.setParameter("classId", classId);
|
||||
return qForClassStudents.list();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DataGrid implements java.io.Serializable {
|
||||
public class DataGrid extends com.example.aes.problem.model.DataGrid implements java.io.Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1538274527426L;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,4 +29,6 @@ public interface ClassesServiceI {
|
|||
|
||||
public List<Classstudents> findClassIdByStudentId(int studentId); // 根据学生id查找班级id
|
||||
public List<Classes> findClassByCourseId(int courseId);
|
||||
|
||||
List<Classstudents> getClassStudentsByClassId(int classId);// 根据学生id查找所在班级人数
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,4 +253,9 @@ public void setclassstudentsDao(ClassstudentsDaoI classstudentsDao) {
|
|||
return classesDao.findClassByCourseId(courseId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Classstudents> getClassStudentsByClassId(int classId) {
|
||||
return classesDao.findClassStudentsByClassId(classId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ server.port=8082
|
|||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
jdbc_url=jdbc:mysql://localhost:3306/aes?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=True
|
||||
jdbc_username=root
|
||||
jdbc_password=123456
|
||||
jdbc_password=13661744518xh
|
||||
#spring.datasource.url=jdbc:mysql://localhost:3306/aes?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=True
|
||||
#spring.datasource.username=root
|
||||
#spring.datasource.password=123456
|
||||
|
|
|
|||
Loading…
Reference in New Issue