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