2025年4月17日16:57:16
parent
2c0f9a4ab1
commit
bb723d516f
|
|
@ -0,0 +1,12 @@
|
|||
package com.zhangmeng.online.exam.controller;
|
||||
|
||||
/**
|
||||
* @author zm
|
||||
* @date 2025/4/17 16:24
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class ExamController {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import com.zhangmeng.online.exam.dto.Result;
|
|||
import com.zhangmeng.online.exam.entity.*;
|
||||
import com.zhangmeng.online.exam.entity.User;
|
||||
import com.zhangmeng.online.exam.utils.PageUtils;
|
||||
import com.zhangmeng.online.exam.utils.UserUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
|
@ -166,8 +167,10 @@ public class UserController {
|
|||
@GetMapping("/menu")
|
||||
public Result menuList() {
|
||||
List<Menu> list = new ArrayList<>();
|
||||
Long currentUserId = UserUtils.getCurrentUserId();
|
||||
|
||||
TypedQuery<User> query = entityManager.createQuery("select obj from User obj where obj.id = 1", User.class);
|
||||
TypedQuery<User> query = entityManager.createQuery("select obj from User obj where obj.id =:id", User.class);
|
||||
query.setParameter("id", currentUserId);
|
||||
User root = query.getResultList().get(0);
|
||||
Set<Role> roles = root.getRoles();
|
||||
for (Role role : roles) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package com.zhangmeng.online.exam.entity;
|
||||
|
||||
import com.zhangmeng.online.exam.entity.baseEntity.BaseEntity;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考试信息
|
||||
* @author zm
|
||||
* @date 2025/4/17 16:26
|
||||
* @version: 1.0
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@ToString(exclude = {"user","paper","examAnswers"})
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "exam")
|
||||
public class Exam extends BaseEntity<Long> {
|
||||
|
||||
@ManyToOne
|
||||
private User user;//考试人
|
||||
|
||||
@ManyToOne
|
||||
private Paper paper;//试卷
|
||||
|
||||
@OneToMany(mappedBy = "exam")
|
||||
private List<ExamAnswer> examAnswers = new ArrayList<>();//考试信息
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.zhangmeng.online.exam.entity;
|
||||
|
||||
import com.zhangmeng.online.exam.entity.baseEntity.BaseEntity;
|
||||
import lombok.*;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考试答案 (考试答案)
|
||||
* @author zm
|
||||
* @date 2025/4/17 16:31
|
||||
* @version: 1.0
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@ToString(exclude = {"exam", "question", "questionOptions"})
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "exam_answer")
|
||||
public class ExamAnswer extends BaseEntity<Long> {
|
||||
|
||||
@ManyToOne
|
||||
private Exam exam;
|
||||
|
||||
@ManyToOne
|
||||
private Question question;//问题
|
||||
|
||||
@ManyToMany(targetEntity = QuestionOption.class)
|
||||
@JoinTable(name = "exam_answer_question_option", joinColumns = @JoinColumn(name = "exam_answer_id"), inverseJoinColumns = @JoinColumn(name = "question_option_id"))
|
||||
private List<QuestionOption> questionOptions = new ArrayList<>();//答案选项
|
||||
|
||||
private String answer;//答案
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考试试卷的答案
|
||||
* 考试试卷的答案(参考答案)
|
||||
* @author zm
|
||||
* @date 2025/3/18 16:36
|
||||
* @version: 1.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue