From ef8707272cbb7b9f6120fda1668557bd0def7dcc Mon Sep 17 00:00:00 2001
From: musteven <1009173794@qq.com>
Date: Sun, 16 Mar 2025 10:11:16 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9C=A8class=E7=B1=BB=E4=B8=AD=E7=BC=96?=
=?UTF-8?q?=E5=86=99=E4=BA=86=E6=A0=B9=E6=8D=AE=E5=AD=A6=E7=94=9Fid?=
=?UTF-8?q?=E6=9F=A5=E7=8F=AD=E7=BA=A7id=E6=8E=A5=E5=8F=A3=EF=BC=88?=
=?UTF-8?q?=E6=9A=82=E6=97=A0=E5=88=AB=E7=94=A8=EF=BC=89=EF=BC=8C=E7=9B=AE?=
=?UTF-8?q?=E5=89=8D=E7=94=A8=E4=BA=8E=E4=BD=9C=E4=B8=9A=E6=9F=A5=E8=AF=A2?=
=?UTF-8?q?=E9=83=A8=E5=88=86=E8=B0=83=E7=94=A8=E6=96=B9=E6=B3=95=EF=BC=9B?=
=?UTF-8?q?=20=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E5=89=8D=E7=AB=AF?=
=?UTF-8?q?=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=EF=BC=8C=E6=8E=92=E7=89=88?=
=?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=AD=89=EF=BC=9B=20=E5=88=9D=E6=AD=A5?=
=?UTF-8?q?=E6=9E=84=E5=BB=BA=E4=BA=86=E4=BD=9C=E4=B8=9A=E9=83=A8=E5=88=86?=
=?UTF-8?q?=E7=9A=84=E5=90=8E=E7=AB=AF=E5=A4=A7=E8=87=B4=E6=A1=86=E6=9E=B6?=
=?UTF-8?q?=EF=BC=8C=E5=B0=9D=E8=AF=95=E7=BC=96=E5=86=99=E5=AD=A6=E7=94=9F?=
=?UTF-8?q?=E7=AB=AF=E6=9F=A5=E8=AF=A2=E4=BD=9C=E4=B8=9A=E4=BF=A1=E6=81=AF?=
=?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=90=8E=E7=AB=AF=E9=80=BB=E8=BE=91?=
=?UTF-8?q?=E6=9C=AA=E5=85=A8=E9=83=A8=E5=AE=8C=E6=88=90=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
AES-front/src/api/user.js | 6 +
.../exam-list/components/exam-actions.vue | 4 +-
AES-front/src/views/user/exam-list/index.vue | 218 +++++++++++++++++-
AES-front/src/views/user/index.vue | 2 +-
AES-front/src/views/user/problem/index.vue | 13 ++
AES-front/src/views/user/take-class/index.vue | 2 +-
.../problem/controller/ProblemController.java | 72 ++++++
.../example/aes/problem/dao/ProblemDaoI.java | 20 ++
.../aes/problem/dao/impl/ProblemDaoImpl.java | 42 ++++
.../example/aes/problem/model/PMProblem.java | 39 ++++
.../example/aes/problem/model/Problem.java | 27 +++
.../service/Impl/ProblemServiceImpl.java | 23 ++
.../aes/problem/service/ProblemServiceI.java | 12 +
.../user/controller/ClassesController.java | 19 +-
.../com/example/aes/user/dao/ClassesDaoI.java | 9 +-
.../aes/user/dao/impl/ClassesDaoImpl.java | 8 +
.../aes/user/service/ClassesServiceI.java | 1 +
.../user/service/impl/ClassesServiceImpl.java | 7 +
AES/src/main/resources/application.properties | 2 +-
19 files changed, 510 insertions(+), 16 deletions(-)
create mode 100644 AES-front/src/views/user/problem/index.vue
create mode 100644 AES/src/main/java/com/example/aes/problem/controller/ProblemController.java
create mode 100644 AES/src/main/java/com/example/aes/problem/dao/ProblemDaoI.java
create mode 100644 AES/src/main/java/com/example/aes/problem/dao/impl/ProblemDaoImpl.java
create mode 100644 AES/src/main/java/com/example/aes/problem/model/PMProblem.java
create mode 100644 AES/src/main/java/com/example/aes/problem/model/Problem.java
create mode 100644 AES/src/main/java/com/example/aes/problem/service/Impl/ProblemServiceImpl.java
create mode 100644 AES/src/main/java/com/example/aes/problem/service/ProblemServiceI.java
diff --git a/AES-front/src/api/user.js b/AES-front/src/api/user.js
index 227a4dd..c32ec68 100644
--- a/AES-front/src/api/user.js
+++ b/AES-front/src/api/user.js
@@ -19,5 +19,11 @@ export default {
updateUserPwd: (data) => request.post('/user/editUserPassword', data),
signUser: (data) => request.post('/user/signUser', data, { noNeedToken: true }),
+ //°༶Ïà¹Ø
takeClassByInviteCode: (data) => request.post('/classes/takeClassByInviteCode', data), //¼ÓÈë°༶
+
+
+ //×÷ҵÌâĿ²¿·Ö
+ getExamList: (data) =>request.post('/problem/getExamList')//ѧÉú»ñȡ×÷ҵÁбí
+
}
diff --git a/AES-front/src/views/user/exam-list/components/exam-actions.vue b/AES-front/src/views/user/exam-list/components/exam-actions.vue
index 198b91a..e32c949 100644
--- a/AES-front/src/views/user/exam-list/components/exam-actions.vue
+++ b/AES-front/src/views/user/exam-list/components/exam-actions.vue
@@ -1,12 +1,12 @@
- 参加
+ 进入
成绩
diff --git a/AES-front/src/views/user/index.vue b/AES-front/src/views/user/index.vue
index f7534e3..fba6cfc 100644
--- a/AES-front/src/views/user/index.vue
+++ b/AES-front/src/views/user/index.vue
@@ -95,7 +95,7 @@ img.shadow-img {
/* 文字说明样式 */
.index-right-div {
margin-left: 35px;
- width: 400px;
+ width: 300px;
}
/* 修改文字说明样式,添加悬停效果 */
diff --git a/AES-front/src/views/user/problem/index.vue b/AES-front/src/views/user/problem/index.vue
new file mode 100644
index 0000000..4bb1816
--- /dev/null
+++ b/AES-front/src/views/user/problem/index.vue
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AES-front/src/views/user/take-class/index.vue b/AES-front/src/views/user/take-class/index.vue
index 393d9d7..8e2fb8a 100644
--- a/AES-front/src/views/user/take-class/index.vue
+++ b/AES-front/src/views/user/take-class/index.vue
@@ -63,7 +63,7 @@ const handleValidateButtonClick = ()=>{
}
.lead
{
- font-size:1.25rem;
+ font-size:1.4rem;
font-weight:300
}
.divCode{
diff --git a/AES/src/main/java/com/example/aes/problem/controller/ProblemController.java b/AES/src/main/java/com/example/aes/problem/controller/ProblemController.java
new file mode 100644
index 0000000..a194e89
--- /dev/null
+++ b/AES/src/main/java/com/example/aes/problem/controller/ProblemController.java
@@ -0,0 +1,72 @@
+package com.example.aes.problem.controller;
+
+
+import com.example.aes.global.model.DecodeToken;
+import com.example.aes.global.model.RespBean;
+import com.example.aes.problem.model.PMProblem;
+import com.example.aes.problem.service.ProblemServiceI;
+import com.example.aes.user.dao.AccountDao;
+import com.example.aes.user.model.Adminusers;
+import com.example.aes.user.model.Classstudents;
+import com.example.aes.user.model.DataGrid;
+import com.example.aes.user.model.Users;
+import com.example.aes.user.service.ClassesServiceI;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+
+@RestController
+@RequestMapping("/problem")
+public class ProblemController {
+
+ @Autowired
+ private ClassesServiceI classesServiceI;
+
+ @Autowired
+ private ProblemServiceI problemServiceI;
+
+ //获取作业列表
+ @GetMapping("/getExamList")
+ public RespBean getExamList(Integer pageNum,Integer pageSize, HttpServletRequest request) {
+ if (pageNum < 1 || pageSize < 1)
+ return RespBean.error("参数错误!");
+
+// PMProblem pMproblem = new PMProblem();
+// pMproblem.setPageNum(pageNum);
+// pMproblem.setPageSize(pageSize);
+
+ DecodeToken decodeToken = new DecodeToken(request);
+ String userId = decodeToken.getUserId();
+
+ // 根据学生id查找班级id
+ List classstudentsList = classesServiceI.findClassIdByStudentId(Integer.parseInt(userId));
+ List classIds = new ArrayList();
+ for (Classstudents classstudent : classstudentsList) {
+ //提取所有的classstudentslist中的classid并存放到新的classids表里面用作后续处理
+ classIds.add(classstudent.getClassId());
+ }
+
+ List pMproblems = problemServiceI.getProblemsByClassIds(classIds);
+
+ if (pMproblems != null) {
+ return RespBean.ok("获取作业列表成功!",pMproblems);
+ } else {
+ return RespBean.error("获取作业列表失败!");
+ }
+ }
+
+
+////////////逻辑在未完成
+}
diff --git a/AES/src/main/java/com/example/aes/problem/dao/ProblemDaoI.java b/AES/src/main/java/com/example/aes/problem/dao/ProblemDaoI.java
new file mode 100644
index 0000000..88a2397
--- /dev/null
+++ b/AES/src/main/java/com/example/aes/problem/dao/ProblemDaoI.java
@@ -0,0 +1,20 @@
+package com.example.aes.problem.dao;
+
+
+import com.example.aes.problem.model.PMProblem;
+import com.example.aes.problem.model.Problem;
+import com.example.aes.user.dao.BaseDaoI;
+import com.example.aes.user.model.Classstudents;
+
+
+import java.util.List;
+
+
+public interface ProblemDaoI extends BaseDaoI {
+
+ List findProblemsByClassIds(List classIds);
+
+
+
+
+}
diff --git a/AES/src/main/java/com/example/aes/problem/dao/impl/ProblemDaoImpl.java b/AES/src/main/java/com/example/aes/problem/dao/impl/ProblemDaoImpl.java
new file mode 100644
index 0000000..f8d8c02
--- /dev/null
+++ b/AES/src/main/java/com/example/aes/problem/dao/impl/ProblemDaoImpl.java
@@ -0,0 +1,42 @@
+package com.example.aes.problem.dao.impl;
+
+import com.example.aes.problem.dao.ProblemDaoI;
+import com.example.aes.problem.model.PMProblem;
+import com.example.aes.problem.model.Problem;
+import com.example.aes.user.dao.BaseDaoI;
+import com.example.aes.user.dao.impl.BaseDaoImpl;
+import com.example.aes.user.model.Classstudents;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Repository("ProblemDao")
+public class ProblemDaoImpl extends BaseDaoImpl implements ProblemDaoI{
+
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
+
+ @Override
+ public List findProblemsByClassIds(List classIds){
+ // SQL查询,根据classIds获取problemId, startTime, endTime
+ String sql = "SELECT p.problem_id AS problemId, pp.start_time AS startTime, pp.end_time AS endTime " +
+ "FROM postproblem pp " +
+ "JOIN problem p ON pp.problem_id = p.id " +
+ "WHERE pp.class_id IN (?)";
+
+ // 将classIds转换为逗号分隔的字符串
+ String classIdsStr = classIds.toString().replace("[", "").replace("]", "");
+
+ // 执行查询
+ List problems = jdbcTemplate.query(
+ sql,
+ new Object[]{classIdsStr},
+ new BeanPropertyRowMapper<>(PMProblem.class)
+ );
+
+ return problems;
+ }
+}
diff --git a/AES/src/main/java/com/example/aes/problem/model/PMProblem.java b/AES/src/main/java/com/example/aes/problem/model/PMProblem.java
new file mode 100644
index 0000000..71f2226
--- /dev/null
+++ b/AES/src/main/java/com/example/aes/problem/model/PMProblem.java
@@ -0,0 +1,39 @@
+package com.example.aes.problem.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PMProblem extends Problem implements java.io.Serializable{//继承Problems子类
+
+// //作业problem基本属性,继承自Problem类
+// private int Id;
+// private int courseId;
+// private int adminuserId;
+// private String title;
+// private String description;
+
+ // 作业列表分页exam
+ private int pageNum;
+ private int pageSize;
+
+
+ // (作业列表)页面上其他需要的属性
+ private Date startTime;//开始时间,来自postproblem
+ private Date endTime;//结束时间
+ private String submissonStatus;//提交状态,来自submitproblem
+ private String plagiarismStatus;//查重状态
+ private float score;//最终分数
+ private String status;//最后在页面显示的状态,取决于上面三个参数。
+
+ //(作业列表)页面需要的后台数据
+ private int studentId;//学生id
+ private int classId;//班级id
+
+
+}
diff --git a/AES/src/main/java/com/example/aes/problem/model/Problem.java b/AES/src/main/java/com/example/aes/problem/model/Problem.java
new file mode 100644
index 0000000..e5a73b2
--- /dev/null
+++ b/AES/src/main/java/com/example/aes/problem/model/Problem.java
@@ -0,0 +1,27 @@
+package com.example.aes.problem.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Table;
+import java.util.Date;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Table(name = "Problem")
+public class Problem implements java.io.Serializable{ //Problem父类
+
+ //作业problem基本属性
+ private int Id;//此处为ProblemId
+ private int courseId;
+ private int adminuserId;
+ private String title;
+ private String description;
+
+ // 作业列表分页exam
+ private int pageNum;
+ private int pageSize;
+
+}
diff --git a/AES/src/main/java/com/example/aes/problem/service/Impl/ProblemServiceImpl.java b/AES/src/main/java/com/example/aes/problem/service/Impl/ProblemServiceImpl.java
new file mode 100644
index 0000000..43da052
--- /dev/null
+++ b/AES/src/main/java/com/example/aes/problem/service/Impl/ProblemServiceImpl.java
@@ -0,0 +1,23 @@
+package com.example.aes.problem.service.Impl;
+
+import com.example.aes.problem.dao.ProblemDaoI;
+import com.example.aes.problem.model.PMProblem;
+import com.example.aes.problem.service.ProblemServiceI;
+import com.example.aes.user.dao.ClassesDaoI;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+@Service
+public class ProblemServiceImpl implements ProblemServiceI {
+
+ private ProblemDaoI problemDao;
+ @Autowired
+ public void setProblemDao(ProblemDaoI problemDao) {
+ this.problemDao = problemDao;
+ }
+
+ public List getProblemsByClassIds(List classIds){
+ return problemDao.findProblemsByClassIds(classIds);
+ }
+}
diff --git a/AES/src/main/java/com/example/aes/problem/service/ProblemServiceI.java b/AES/src/main/java/com/example/aes/problem/service/ProblemServiceI.java
new file mode 100644
index 0000000..c9c40cc
--- /dev/null
+++ b/AES/src/main/java/com/example/aes/problem/service/ProblemServiceI.java
@@ -0,0 +1,12 @@
+package com.example.aes.problem.service;
+
+
+
+import com.example.aes.problem.model.PMProblem;
+import com.example.aes.user.model.*;
+
+import java.util.List;
+
+public interface ProblemServiceI {
+ public List getProblemsByClassIds(List classIds);
+}
diff --git a/AES/src/main/java/com/example/aes/user/controller/ClassesController.java b/AES/src/main/java/com/example/aes/user/controller/ClassesController.java
index ced0b70..ccfaa2d 100644
--- a/AES/src/main/java/com/example/aes/user/controller/ClassesController.java
+++ b/AES/src/main/java/com/example/aes/user/controller/ClassesController.java
@@ -5,10 +5,7 @@ import com.example.aes.global.model.PageBean;
import com.example.aes.global.model.RespBean;
import com.example.aes.user.dao.ClassesDaoI;
import com.example.aes.user.dao.ClassstudentsDaoI;
-import com.example.aes.user.model.DataGrid;
-import com.example.aes.user.model.Json;
-import com.example.aes.user.model.PMClasses;
-import com.example.aes.user.model.UClass;
+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;
@@ -176,4 +173,18 @@ public class ClassesController{
}
+ @PostMapping("/findClassIdByStudentId")// 根据学生id查找班级id(暂时无用
+ public RespBean findClassIdByStudentId(HttpServletRequest request)
+ {
+ DecodeToken decodeToken = new DecodeToken(request);
+ String userId = decodeToken.getUserId();//获取学生id
+ int studentId = Integer.parseInt(userId);
+ List classstudentsList = classesServiceI.findClassIdByStudentId(studentId);
+
+ if (classstudentsList == null || classstudentsList.isEmpty()) { // 如果列表为空,返回错误信息
+ return RespBean.error("没有找到相关班级");
+ }
+ else return RespBean.ok("查找班级成功", classstudentsList);
+ }
+
}
diff --git a/AES/src/main/java/com/example/aes/user/dao/ClassesDaoI.java b/AES/src/main/java/com/example/aes/user/dao/ClassesDaoI.java
index ec1f94a..f1635fa 100644
--- a/AES/src/main/java/com/example/aes/user/dao/ClassesDaoI.java
+++ b/AES/src/main/java/com/example/aes/user/dao/ClassesDaoI.java
@@ -1,12 +1,7 @@
package com.example.aes.user.dao;
-import com.example.aes.user.model.Classes;
-
-import com.example.aes.user.model.PMClasses;
-
-import com.example.aes.user.model.PMUser;
-import com.example.aes.user.model.UClass;
+import com.example.aes.user.model.*;
import java.util.Date;
@@ -49,4 +44,6 @@ public interface ClassesDaoI extends BaseDaoI {
public long findClassStudentsByIdNum(int classId);
public List findClassStudentsByIdPage(int classId, int pageNum, int pageSize);
public boolean deleteClassStudentsByUserId(int classId, int userId); // 通过userId删除班级学生
+
+ public ListfindClassIdByStudentId(int studentId);//根据班级id查找学生id
}
diff --git a/AES/src/main/java/com/example/aes/user/dao/impl/ClassesDaoImpl.java b/AES/src/main/java/com/example/aes/user/dao/impl/ClassesDaoImpl.java
index 7b752ad..2572541 100644
--- a/AES/src/main/java/com/example/aes/user/dao/impl/ClassesDaoImpl.java
+++ b/AES/src/main/java/com/example/aes/user/dao/impl/ClassesDaoImpl.java
@@ -538,4 +538,12 @@ public class ClassesDaoImpl extends BaseDaoImpl implements ClassesDaoI
return this.count(totalhql).longValue();
}
+ @Override
+ public List findClassIdByStudentId(int studentId){
+ String hql = "from Classstudents c where c.userId=" + studentId;
+ Query q = this.getCurrentSession().createQuery(hql);
+ return q.list();
+ }
+
+
}
diff --git a/AES/src/main/java/com/example/aes/user/service/ClassesServiceI.java b/AES/src/main/java/com/example/aes/user/service/ClassesServiceI.java
index 2fe94f4..51e81dc 100644
--- a/AES/src/main/java/com/example/aes/user/service/ClassesServiceI.java
+++ b/AES/src/main/java/com/example/aes/user/service/ClassesServiceI.java
@@ -26,4 +26,5 @@ public interface ClassesServiceI {
public DataGrid findClassNotInCourse(UClass uClass, int pageNum, int pageSize); // 获取未参加课程的班级
public DataGrid findClassNotInCourse(int courseId, int teacherId, int pageNum, int pageSize, boolean history); // 获取未参加课程的班级
+ public List findClassIdByStudentId(int studentId); // 根据学生id查找班级id
}
diff --git a/AES/src/main/java/com/example/aes/user/service/impl/ClassesServiceImpl.java b/AES/src/main/java/com/example/aes/user/service/impl/ClassesServiceImpl.java
index 797fcc1..7cd607b 100644
--- a/AES/src/main/java/com/example/aes/user/service/impl/ClassesServiceImpl.java
+++ b/AES/src/main/java/com/example/aes/user/service/impl/ClassesServiceImpl.java
@@ -232,4 +232,11 @@ public void setclassstudentsDao(ClassstudentsDaoI classstudentsDao) {
public boolean deleteClassStudentsByUserId(int classId, int userId) {
return classesDao.deleteClassStudentsByUserId(classId, userId);
}
+
+ @Override
+ public List findClassIdByStudentId(int studentId){
+ return classesDao.findClassIdByStudentId(studentId);
+ };
+
+
}
diff --git a/AES/src/main/resources/application.properties b/AES/src/main/resources/application.properties
index 488fc4f..e82f2c8 100644
--- a/AES/src/main/resources/application.properties
+++ b/AES/src/main/resources/application.properties
@@ -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