重写后端部分代码,删除多余数据库,前端增加多账号同时在线机制

main
yuan 2 days ago
parent b714922b36
commit 48a4c772b4

@ -58,7 +58,6 @@ public class SysLoginController
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid()); loginBody.getUuid());
ajax.put(Constants.TOKEN, token); ajax.put(Constants.TOKEN, token);
System.out.println("======="+ajax);
return ajax; return ajax;
} }
@ -88,8 +87,6 @@ public class SysLoginController
Long roleId = roleService.getRoleByUserId(user.getUserId()); Long roleId = roleService.getRoleByUserId(user.getUserId());
roleService.checkRoleDataScope(roleId); roleService.checkRoleDataScope(roleId);
ajax.put("role", roleService.selectRoleById(roleId).getRoleName()); ajax.put("role", roleService.selectRoleById(roleId).getRoleName());
System.out.println("------------------"+ajax);
return ajax; return ajax;
} }

@ -115,6 +115,7 @@ public class SysUserController extends BaseController
ajax.put("postIds", postService.selectPostListByUserId(userId)); ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList()));
} }
System.out.println("================"+ajax);
return ajax; return ajax;
} }

@ -25,9 +25,6 @@ import java.util.Map;
@RequestMapping("/gl/answerSheet") @RequestMapping("/gl/answerSheet")
public class AnswerSheetController { public class AnswerSheetController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IAnswerSheetDOService iAnswerSheetDOService; private IAnswerSheetDOService iAnswerSheetDOService;
@ -54,14 +51,12 @@ public class AnswerSheetController {
public R<String> answer(@RequestBody AnswerDO answerDO) { public R<String> answer(@RequestBody AnswerDO answerDO) {
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
List<AnswerVo> answerVos = answerDO.getList(); List<AnswerVo> answerVos = answerDO.getList();
Gson gson = new Gson(); Gson gson = new Gson();
String answerVo = gson.toJson(answerVos); String answerVo = gson.toJson(answerVos);
Answer answer = new Answer(); Answer answer = new Answer();
answer.setSender(sender);
answer.setTestid(answerDO.getTestid()); answer.setTestid(answerDO.getTestid());
answer.setIdanswer(answerVo); answer.setIdanswer(answerVo);
answer.setTime(answerDO.getTime()); answer.setTime(answerDO.getTime());
@ -78,9 +73,8 @@ public class AnswerSheetController {
public R<String> answerDisplay( Long id) { public R<String> answerDisplay( Long id) {
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long userid = sysUser.getUserId(); Long userid = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
List<Questionbank> list = iExamCreateService.selectListByPid(id); List<Questionbank> list = iExamCreateService.selectListByPid(id);
Answer answer = iAnswerService.selectByTestId(userid,sender, id); Answer answer = iAnswerService.selectByTestId(userid, id);
QuestionAnswerDO questionAnswerDO = iQuestionanswerService.createTest(list, answer); QuestionAnswerDO questionAnswerDO = iQuestionanswerService.createTest(list, answer);
if (iQuestionanswerService.addTest(questionAnswerDO) != 0) { if (iQuestionanswerService.addTest(questionAnswerDO) != 0) {
return R.ok("该学生客观题已改完!"); return R.ok("该学生客观题已改完!");
@ -91,8 +85,8 @@ public class AnswerSheetController {
@ApiOperation("查看学生的考试情况(最新)") @ApiOperation("查看学生的考试情况(最新)")
@GetMapping("selectQuestionanswer") @GetMapping("selectQuestionanswer")
public R<QuestionAnswerDO> selectQuestionanswer(Long senderId,String sender, Long testid) { public R<QuestionAnswerDO> selectQuestionanswer(Long senderId, Long testid) {
return R.ok(iQuestionanswerService.selectQuestionanswer(senderId,sender,testid)); return R.ok(iQuestionanswerService.selectQuestionanswer(senderId,testid));
} }
@ApiOperation("批改客观题") @ApiOperation("批改客观题")
@ -107,8 +101,8 @@ public class AnswerSheetController {
@ApiOperation("试卷批改完毕提交") @ApiOperation("试卷批改完毕提交")
@PostMapping("addmarkedtest") @PostMapping("addmarkedtest")
public R<String> addmarkedtest(Long senderId,String sender,Long testid){ public R<String> addmarkedtest(Long senderId,Long testid){
if(iMarkedtestService.addmarkedtest(senderId,sender,testid)!=0){ if(iMarkedtestService.addmarkedtest(senderId,testid)!=0){
return R.ok("提交完成!"); return R.ok("提交完成!");
} }
return R.fail("提交失败!"); return R.fail("提交失败!");

@ -7,7 +7,6 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.test.domain.Task; import com.ruoyi.test.domain.Task;
import com.ruoyi.test.domain.Vo.TaskVo; import com.ruoyi.test.domain.Vo.TaskVo;
import com.ruoyi.test.seriver.ITaskService; import com.ruoyi.test.seriver.ITaskService;
import com.ruoyi.test.seriver.IUserService;
import com.ruoyi.web.controller.tool.testTool.ResultVo; import com.ruoyi.web.controller.tool.testTool.ResultVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -25,8 +24,6 @@ public class TaskController {
@Autowired @Autowired
private ITaskService iTaskService; private ITaskService iTaskService;
@Autowired
private IUserService iUserService;
@ApiOperation("任务列表") @ApiOperation("任务列表")
@GetMapping("selectList") @GetMapping("selectList")
@ -51,9 +48,8 @@ public class TaskController {
@PostMapping("addTask") @PostMapping("addTask")
public R<String> addTask(@RequestBody TaskVo taskVo){ public R<String> addTask(@RequestBody TaskVo taskVo){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long userId = sysUser.getUserId(); String sender = sysUser.getUserName();
String tname = iUserService.user(iUserService.selectByzhid(userId)).getTname(); if(iTaskService.addTask(taskVo,sender)!=0){
if(iTaskService.addTask(taskVo,tname)!=0){
return R.ok("任务添加成功!"); return R.ok("任务添加成功!");
} }
return R.fail("任务添加失败"); return R.fail("任务添加失败");

@ -1,158 +1,155 @@
package com.ruoyi.web.controller.test.gl; //package com.ruoyi.web.controller.test.gl;
//
import com.baomidou.mybatisplus.core.metadata.IPage; //import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R; //import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser; //import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils; //import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.test.domain.User; //import io.swagger.annotations.Api;
import com.ruoyi.test.domain.Vo.UserVo; //import io.swagger.annotations.ApiOperation;
import com.ruoyi.test.seriver.IUserService; //import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api; //import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.ApiOperation; //
import org.springframework.beans.factory.annotation.Autowired; //import java.util.List;
import org.springframework.web.bind.annotation.*; //
//@Api(tags = "管理端用户管理")
import java.util.List; //@RestController
//@RequestMapping("/gl/users")
@Api(tags = "管理端用户管理") //public class UserController {
@RestController // @Autowired
@RequestMapping("/gl/users") // private IUserService iUserService;
public class UserController { //
@Autowired // /*
private IUserService iUserService; // 获取学生列表
// */
/* // @ApiOperation("学生列表")
// @GetMapping("student")
*/ // public R<IPage<User>> selectList(int pagenum){
@ApiOperation("学生列表") // return R.ok(iUserService.selectStudentList(pagenum));
@GetMapping("student") // }
public R<IPage<User>> selectList(int pagenum){ // /*获取学生用户名查询查询记录
return R.ok(iUserService.selectStudentList(pagenum)); // *@param name 用户名
} // */
/* // @ApiOperation("学生用户名查询")
*@param name // @GetMapping("/seleteStudentName")
*/ // public R<IPage<User>> selectStudent(int pagenum,String name){
@ApiOperation("学生用户名查询") // return R.ok(iUserService.selectStudent(pagenum,name));
@GetMapping("/seleteStudentName") // }
public R<IPage<User>> selectStudent(int pagenum,String name){ //
return R.ok(iUserService.selectStudent(pagenum,name)); // /*增加学生用户信息
} // *@param name 用户名
// */
/* // @ApiOperation("学生添加用户")
*@param name // @PostMapping("/insertStudent")
*/ // public R<String> inserStudent(@RequestBody UserVo userVo){
@ApiOperation("学生添加用户") // User user = new User();
@PostMapping("/insertStudent") // user.setAge(userVo.getAge());
public R<String> inserStudent(@RequestBody UserVo userVo){ // user.setBirthday(userVo.getBirthday());
User user = new User(); // user.setGrade(userVo.getGrade());
user.setAge(userVo.getAge()); // user.setSex(userVo.getSex());
user.setBirthday(userVo.getBirthday()); // user.setName(userVo.getName());
user.setGrade(userVo.getGrade()); // user.setTname(userVo.getTname());
user.setSex(userVo.getSex()); // user.setTelephone(userVo.getTelephone());
user.setName(userVo.getName()); // user.setRoleKey("2");
user.setTname(userVo.getTname()); // user.setState(0L);
user.setTelephone(userVo.getTelephone()); // SysUser sysUser = SecurityUtils.getLoginUser().getUser();
user.setRoleKey("2"); // Long zhid = sysUser.getUserId();
user.setState(0L); // user.setZhId(zhid);
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); // List<User> list = iUserService.selectStudentByZhid(zhid);
Long zhid = sysUser.getUserId(); // if(list.size()==0){
user.setZhId(zhid); // if(iUserService.insertUser(user)!=0){
List<User> list = iUserService.selectStudentByZhid(zhid); // return R.ok("添加成功!");
if(list.size()==0){ // }else{
if(iUserService.insertUser(user)!=0){ // return R.fail("添加失败!");
return R.ok("添加成功!"); // }
}else{ // }
return R.fail("添加失败!"); // return R.fail("该账号已绑定用户了!");
} // }
} //
return R.fail("该账号已绑定用户了!"); //
} //
// @ApiOperation("教师列表")
// @GetMapping("/teacher")
// public R<IPage<User>> selectTeacher(int pagenum){
@ApiOperation("教师列表") // return R.ok(iUserService.selectTeacherList(pagenum));
@GetMapping("/teacher") // }
public R<IPage<User>> selectTeacher(int pagenum){ // /*获取教师用户名查询查询记录
return R.ok(iUserService.selectTeacherList(pagenum)); // *@param name 用户名
} // */
/* // @ApiOperation("教师用户名查询")
*@param name // @GetMapping("/seleteTeacherName")
*/ // public R<IPage<User>> selectTeacher(int pagenum,String name){
@ApiOperation("教师用户名查询") // return R.ok(iUserService.selectTeacher(pagenum,name));
@GetMapping("/seleteTeacherName") // }
public R<IPage<User>> selectTeacher(int pagenum,String name){ // /*增加教师用户信息
return R.ok(iUserService.selectTeacher(pagenum,name)); // *@param name 用户名
} // */
/* // @ApiOperation("老师添加用户")
*@param name // @PostMapping("/insertTeacher")
*/ // public R<String> insertTeacher(@RequestBody UserVo userVo){
@ApiOperation("老师添加用户") // User user = new User();
@PostMapping("/insertTeacher") // user.setAge(userVo.getAge());
public R<String> insertTeacher(@RequestBody UserVo userVo){ // user.setBirthday(userVo.getBirthday());
User user = new User(); // user.setGrade(userVo.getGrade());
user.setAge(userVo.getAge()); // user.setSex(userVo.getSex());
user.setBirthday(userVo.getBirthday()); // user.setName(userVo.getName());
user.setGrade(userVo.getGrade()); // user.setTname(userVo.getTname());
user.setSex(userVo.getSex()); // user.setTelephone(userVo.getTelephone());
user.setName(userVo.getName()); // user.setRoleKey("3");
user.setTname(userVo.getTname()); // user.setState(0L);
user.setTelephone(userVo.getTelephone()); // SysUser sysUser = SecurityUtils.getLoginUser().getUser();
user.setRoleKey("3"); // Long zhid = sysUser.getUserId();
user.setState(0L); // user.setZhId(zhid);
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); // List<User> list = iUserService.selectStudentByZhid(zhid);
Long zhid = sysUser.getUserId(); // if(list.size()==0){
user.setZhId(zhid); // if(iUserService.insertUser(user)!=0){
List<User> list = iUserService.selectStudentByZhid(zhid); // return R.ok("添加成功!");
if(list.size()==0){ // }else{
if(iUserService.insertUser(user)!=0){ // return R.fail("添加失败!");
return R.ok("添加成功!"); // }
}else{ // }
return R.fail("添加失败!"); // return R.fail("该账号已绑定用户了!");
} // }
} //
return R.fail("该账号已绑定用户了!"); // @ApiOperation("管理员列表")
} // @GetMapping("/Gl")
// public R<IPage<User>> selectGl(int pagenum){
@ApiOperation("管理员列表") // return R.ok(iUserService.selectGlList(pagenum));
@GetMapping("/Gl") // }
public R<IPage<User>> selectGl(int pagenum){ // /*获取管理员用户名查询查询记录
return R.ok(iUserService.selectGlList(pagenum)); // *@param name 用户名
} // */
/* // @ApiOperation("管理员用户名查询")
*@param name // @GetMapping("/seleteGlName")
*/ // public R<IPage<User>> selectGl(int pagenum,String name){
@ApiOperation("管理员用户名查询") // return R.ok(iUserService.selectGl(pagenum,name));
@GetMapping("/seleteGlName") // }
public R<IPage<User>> selectGl(int pagenum,String name){ // /*增加管理员用户信息
return R.ok(iUserService.selectGl(pagenum,name)); // *@param name 用户名
} // */
/* // @ApiOperation("管理员添加用户")
*@param name // @PostMapping("/insertGl")
*/ // public R<String> insertGl(@RequestBody UserVo userVo){
@ApiOperation("管理员添加用户") // User user = new User();
@PostMapping("/insertGl") // user.setAge(userVo.getAge());
public R<String> insertGl(@RequestBody UserVo userVo){ // user.setBirthday(userVo.getBirthday());
User user = new User(); // user.setGrade(userVo.getGrade());
user.setAge(userVo.getAge()); // user.setSex(userVo.getSex());
user.setBirthday(userVo.getBirthday()); // user.setName(userVo.getName());
user.setGrade(userVo.getGrade()); // user.setTname(userVo.getTname());
user.setSex(userVo.getSex()); // user.setTelephone(userVo.getTelephone());
user.setName(userVo.getName()); // user.setRoleKey("4");
user.setTname(userVo.getTname()); // user.setState(0L);
user.setTelephone(userVo.getTelephone()); // SysUser sysUser = SecurityUtils.getLoginUser().getUser();
user.setRoleKey("4"); // Long zhid = sysUser.getUserId();
user.setState(0L); // user.setZhId(zhid);
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); // List<User> list = iUserService.selectStudentByZhid(zhid);
Long zhid = sysUser.getUserId(); // if(list.size()==0){
user.setZhId(zhid); // if(iUserService.insertUser(user)!=0){
List<User> list = iUserService.selectStudentByZhid(zhid); // return R.ok("添加成功!");
if(list.size()==0){ // }else{
if(iUserService.insertUser(user)!=0){ // return R.fail("添加失败!");
return R.ok("添加成功!"); // }
}else{ // }
return R.fail("添加失败!"); // return R.fail("该账号已绑定用户了!");
} // }
} //}
return R.fail("该账号已绑定用户了!");
}
}

@ -10,7 +10,6 @@ import com.ruoyi.test.domain.Vo.ErrorbookVo;
import com.ruoyi.test.seriver.IErrorbookService; import com.ruoyi.test.seriver.IErrorbookService;
import com.ruoyi.test.seriver.IMarkedtestService; import com.ruoyi.test.seriver.IMarkedtestService;
import com.ruoyi.test.seriver.IQuestionbankService; import com.ruoyi.test.seriver.IQuestionbankService;
import com.ruoyi.test.seriver.IUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -24,9 +23,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("student/errorBook") @RequestMapping("student/errorBook")
public class StudentErrorBookController { public class StudentErrorBookController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IMarkedtestService iMarkedtestService; private IMarkedtestService iMarkedtestService;
@ -41,10 +37,8 @@ public class StudentErrorBookController {
public R<String> addErrorBook(Long qid){ public R<String> addErrorBook(Long qid){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
Questionbank questionbank = iQuestionbankService.selectById(qid); Questionbank questionbank = iQuestionbankService.selectById(qid);
Errorbook errorbook = new Errorbook(); Errorbook errorbook = new Errorbook();
errorbook.setSender(sender);
errorbook.setContent(questionbank.getContent()); errorbook.setContent(questionbank.getContent());
errorbook.setChance(questionbank.getChance()); errorbook.setChance(questionbank.getChance());
errorbook.setDifficulty(questionbank.getDifficulty()); errorbook.setDifficulty(questionbank.getDifficulty());
@ -64,8 +58,7 @@ public class StudentErrorBookController {
public R<IPage<ErrorbookVo>> selectErrorBook(int pagenum){ public R<IPage<ErrorbookVo>> selectErrorBook(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname(); return R.ok(iErrorbookService.selectErrorBook(pagenum,id));
return R.ok(iErrorbookService.selectErrorBook(pagenum,sender));
} }
@ApiOperation("查询错题(根据学科)") @ApiOperation("查询错题(根据学科)")
@ -73,8 +66,7 @@ public class StudentErrorBookController {
public R<IPage<ErrorbookVo>> selectErrorBookBySubject(int pagenum,String subject){ public R<IPage<ErrorbookVo>> selectErrorBookBySubject(int pagenum,String subject){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname(); return R.ok(iErrorbookService.selectErrorBookBySubject(pagenum,id,subject));
return R.ok(iErrorbookService.selectErrorBookBySubject(pagenum,sender,subject));
} }
} }

@ -23,9 +23,6 @@ import java.util.List;
@RequestMapping("/student/examPaper") @RequestMapping("/student/examPaper")
public class StudentExamPaperController { public class StudentExamPaperController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IStudentClassService iStudentClassService; private IStudentClassService iStudentClassService;
@ -46,8 +43,7 @@ public class StudentExamPaperController {
public R<StudentClass> selectByUserId(){ public R<StudentClass> selectByUserId(){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
Long userid = iUserService.selectByzhid(id); return R.ok(iStudentClassService.selectById(id));
return R.ok(iStudentClassService.selectById(userid));
} }
@ApiOperation("获取试卷") @ApiOperation("获取试卷")
@ -60,8 +56,8 @@ public class StudentExamPaperController {
@GetMapping("whetherTest") @GetMapping("whetherTest")
public Boolean whetherTest(Long testId){ public Boolean whetherTest(Long testId){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long userid = iUserService.selectByzhid(sysUser.getUserId()); Long id = sysUser.getUserId();
return iAnswerService.selectBySenderIdAndTestId(userid,testId); return iAnswerService.selectBySenderIdAndTestId(id,testId);
} }
@ -70,8 +66,7 @@ public class StudentExamPaperController {
public R<IPage<ExamPaperDO1>> examPaperByTypeAndSubject(int pagenum,int pagesize,String type,String subject){ public R<IPage<ExamPaperDO1>> examPaperByTypeAndSubject(int pagenum,int pagesize,String type,String subject){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
Long userid = iUserService.selectByzhid(id); StudentClass studentClass = iStudentClassService.selectById(id);
StudentClass studentClass = iStudentClassService.selectById(userid);
if(studentClass==null){ if(studentClass==null){
return R.fail("你还没有班级或你不是学生"); return R.fail("你还没有班级或你不是学生");
} }
@ -81,6 +76,9 @@ public class StudentExamPaperController {
List<ExamPaperDO1> list1 = new ArrayList<>(); List<ExamPaperDO1> list1 = new ArrayList<>();
for(ClassExamPaper classExamPaper : list ){ for(ClassExamPaper classExamPaper : list ){
ExamPaper examPaper = iExamPaperService.selectById(classExamPaper.getId()); ExamPaper examPaper = iExamPaperService.selectById(classExamPaper.getId());
if(examPaper.getStatus()==0){
continue;
}
if(type!=null&&!examPaper.getType().equals(type)){ if(type!=null&&!examPaper.getType().equals(type)){
continue; continue;
} }

@ -24,9 +24,6 @@ import java.util.List;
@RequestMapping("/student/examRecord") @RequestMapping("/student/examRecord")
public class StudentExamRecordController { public class StudentExamRecordController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IClassExamPaperService iClassExamPaperService; private IClassExamPaperService iClassExamPaperService;
@ -53,8 +50,7 @@ public class StudentExamRecordController {
public R<IPage<CorrectionDO>> correction(int pagenum,int pagesize){ public R<IPage<CorrectionDO>> correction(int pagenum,int pagesize){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname(); List<Answer> list = iAnswerService.selectBySenderId(id);
List<Answer> list = iAnswerService.selectBySender(sender);
List<CorrectionDO> list1 = new ArrayList<>(); List<CorrectionDO> list1 = new ArrayList<>();
for(Answer answer : list){ for(Answer answer : list){
CorrectionDO correctionDO = new CorrectionDO(); CorrectionDO correctionDO = new CorrectionDO();
@ -65,8 +61,8 @@ public class StudentExamRecordController {
correctionDO.setSubject(examPaper.getSubject()); correctionDO.setSubject(examPaper.getSubject());
correctionDO.setType(examPaper.getType()); correctionDO.setType(examPaper.getType());
correctionDO.setName(examPaper.getName()); correctionDO.setName(examPaper.getName());
if(iMarkedtestService.selectmarkedtestBySenderAndTestid(sender,testid)!=null){ if(iMarkedtestService.selectmarkedtestBySenderIdAndTestid(answer.getSenderId(),testid)!=null){
Markedtest markedtest = iMarkedtestService.selectmarkedtestBySenderAndTestid(sender,testid); Markedtest markedtest = iMarkedtestService.selectmarkedtestBySenderIdAndTestid(answer.getSenderId(),testid);
correctionDO.setTotalscore(markedtest.getTotalscore()); correctionDO.setTotalscore(markedtest.getTotalscore());
correctionDO.setScore(markedtest.getScore()); correctionDO.setScore(markedtest.getScore());
correctionDO.setTotalquestions(markedtest.getTotalquestions()); correctionDO.setTotalquestions(markedtest.getTotalquestions());
@ -97,8 +93,7 @@ public class StudentExamRecordController {
public R<IPage<CorrectionDO>> correctionBySubject(int pagenum,String subject){ public R<IPage<CorrectionDO>> correctionBySubject(int pagenum,String subject){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname(); List<Answer> list = iAnswerService.selectBySenderId(id);
List<Answer> list = iAnswerService.selectBySender(sender);
List<CorrectionDO> list1 = new ArrayList<>(); List<CorrectionDO> list1 = new ArrayList<>();
for(Answer answer : list){ for(Answer answer : list){
Long testid = answer.getTestid(); Long testid = answer.getTestid();
@ -112,8 +107,8 @@ public class StudentExamRecordController {
correctionDO.setSubject(examPaper.getSubject()); correctionDO.setSubject(examPaper.getSubject());
correctionDO.setType(examPaper.getType()); correctionDO.setType(examPaper.getType());
correctionDO.setName(examPaper.getName()); correctionDO.setName(examPaper.getName());
if(iMarkedtestService.selectmarkedtestBySenderAndTestid(sender,testid)!=null){ if(iMarkedtestService.selectmarkedtestBySenderIdAndTestid(id,testid)!=null){
Markedtest markedtest = iMarkedtestService.selectmarkedtestBySenderAndTestid(sender,testid); Markedtest markedtest = iMarkedtestService.selectmarkedtestBySenderIdAndTestid(id,testid);
correctionDO.setTotalscore(markedtest.getTotalscore()); correctionDO.setTotalscore(markedtest.getTotalscore());
correctionDO.setScore(markedtest.getScore()); correctionDO.setScore(markedtest.getScore());
correctionDO.setTotalquestions(markedtest.getTotalquestions()); correctionDO.setTotalquestions(markedtest.getTotalquestions());

@ -1,20 +1,22 @@
package com.ruoyi.web.controller.test.student; package com.ruoyi.web.controller.test.student;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.test.domain.Answer; import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.test.domain.*;
import com.ruoyi.test.domain.DO.AnswerDO; import com.ruoyi.test.domain.DO.AnswerDO;
import com.ruoyi.test.domain.DO.AnswerSheetDO; import com.ruoyi.test.domain.DO.AnswerSheetDO;
import com.ruoyi.test.domain.DO.QuestionAnswerDO; import com.ruoyi.test.domain.DO.QuestionAnswerDO;
import com.ruoyi.test.domain.DO.UserDO; import com.ruoyi.test.domain.DO.UserDO;
import com.ruoyi.test.domain.Markedtest;
import com.ruoyi.test.domain.Questionbank;
import com.ruoyi.test.domain.Vo.AnswerVo; import com.ruoyi.test.domain.Vo.AnswerVo;
import com.ruoyi.test.seriver.*; import com.ruoyi.test.seriver.*;
import com.ruoyi.web.controller.system.SysUserController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -25,9 +27,6 @@ import java.util.List;
@RequestMapping("/student/homepage") @RequestMapping("/student/homepage")
public class StudentHomePageController { public class StudentHomePageController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IAnswerService iAnswerService; private IAnswerService iAnswerService;
@ -43,6 +42,40 @@ public class StudentHomePageController {
@Autowired @Autowired
private IExamCreateService iExamCreateService; private IExamCreateService iExamCreateService;
@Autowired
private IStudentClassService iStudentClassService;
@Autowired
private ITeacherManageClassService iTeacherManageClassService;
@Autowired
private ISysUserService iSysUserService;
@Autowired
private IInstructorManageClassService iInstructorManageClassService;
@ApiOperation("获取用户信息")
@GetMapping("getUser")
public R<UserDO> getUser() {
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
SysUser sysUser2 = iSysUserService.selectUserById(id);
UserDO userDO = new UserDO();
BeanUtils.copyProperties(sysUser2, userDO);
StudentClass studentClass = iStudentClassService.selectById(id);
userDO.setGrade(studentClass.getGrade());
userDO.setClass1(studentClass.getClass1());
InstructorManageClass instructorManageClass = iInstructorManageClassService.selectByGradeAndClass1(userDO.getGrade(),userDO.getClass1());
SysUser sysUser1 = iSysUserService.selectUserById(instructorManageClass.getId());
userDO.setTeacherName(sysUser1.getUserName());
return R.ok(userDO);
}
@ApiOperation("更新用户信息")
@PostMapping("updateUser")
public R<Integer> updateUser(@RequestBody SysUser user) {
return R.ok(iSysUserService.updateUser(user));
}
@ApiOperation("试卷") @ApiOperation("试卷")
@GetMapping("task_paper") @GetMapping("task_paper")
@ -55,14 +88,12 @@ public class StudentHomePageController {
public R<String> taskAnswer(@RequestBody AnswerDO answerDO){ public R<String> taskAnswer(@RequestBody AnswerDO answerDO){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
List<AnswerVo> answerVos = answerDO.getList(); List<AnswerVo> answerVos = answerDO.getList();
Gson gson = new Gson(); Gson gson = new Gson();
String answerVo = gson.toJson(answerVos); String answerVo = gson.toJson(answerVos);
Answer answer = new Answer(); Answer answer = new Answer();
answer.setSenderId(id); answer.setSenderId(id);
answer.setSender(sender);
answer.setTestid(answerDO.getTestid()); answer.setTestid(answerDO.getTestid());
answer.setIdanswer(answerVo); answer.setIdanswer(answerVo);
answer.setTime(answerDO.getTime()); answer.setTime(answerDO.getTime());
@ -78,8 +109,7 @@ public class StudentHomePageController {
public R<List<Markedtest>> taskScore(){ public R<List<Markedtest>> taskScore(){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname(); return R.ok(iMarkedtestService.selectmarkedtestListSenderId(id));
return R.ok(iMarkedtestService.selectmarkedtestListBySenderAndSenderId(sender,id));
} }
@ApiOperation("获取某一张的分数") @ApiOperation("获取某一张的分数")
@ -95,8 +125,7 @@ public class StudentHomePageController {
public R<QuestionAnswerDO> selectQuestionanswer(Long testid) { public R<QuestionAnswerDO> selectQuestionanswer(Long testid) {
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname(); return R.ok(iQuestionanswerService.selectQuestionanswer(id,testid));
return R.ok(iQuestionanswerService.selectQuestionanswer(id,sender,testid));
} }
//主观题自动更改 //主观题自动更改
@ -105,9 +134,8 @@ public class StudentHomePageController {
public R<String> taskAnswerDisplay(Long id) { public R<String> taskAnswerDisplay(Long id) {
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id1 = sysUser.getUserId(); Long id1 = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id1)).getTname();
List<Questionbank> list = iExamCreateService.selectListByPid(id); List<Questionbank> list = iExamCreateService.selectListByPid(id);
Answer answer = iAnswerService.selectByTestId(id1,sender, id); Answer answer = iAnswerService.selectByTestId(id1, id);
QuestionAnswerDO questionAnswerDO = iQuestionanswerService.createTest(list, answer); QuestionAnswerDO questionAnswerDO = iQuestionanswerService.createTest(list, answer);
if (iQuestionanswerService.addTest(questionAnswerDO) != 0) { if (iQuestionanswerService.addTest(questionAnswerDO) != 0) {
return R.ok("该学生客观题已改完!"); return R.ok("该学生客观题已改完!");
@ -124,12 +152,4 @@ public class StudentHomePageController {
return R.fail("批改提交失败!"); return R.fail("批改提交失败!");
} }
@ApiOperation("获取user信息")
@GetMapping("getUserById")
public R<UserDO> getUserById() {
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
return R.ok(iUserService.getUserById(id));
}
} }

@ -10,7 +10,6 @@ import com.ruoyi.test.domain.StudentClass;
import com.ruoyi.test.domain.Video; import com.ruoyi.test.domain.Video;
import com.ruoyi.test.seriver.IClassVedioService; import com.ruoyi.test.seriver.IClassVedioService;
import com.ruoyi.test.seriver.IStudentClassService; import com.ruoyi.test.seriver.IStudentClassService;
import com.ruoyi.test.seriver.IUserService;
import com.ruoyi.test.seriver.IVideoService; import com.ruoyi.test.seriver.IVideoService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -26,10 +25,6 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/student/video") @RequestMapping("/student/video")
public class StudentVideoController { public class StudentVideoController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IStudentClassService iStudentClassService; private IStudentClassService iStudentClassService;
@ -44,8 +39,7 @@ public class StudentVideoController {
public R<IPage<Video>> vedioList(int pagenum,int pagesize){ public R<IPage<Video>> vedioList(int pagenum,int pagesize){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
Long userId = iUserService.user(iUserService.selectByzhid(id)).getUserId(); StudentClass studentClass = iStudentClassService.selectById(id);
StudentClass studentClass = iStudentClassService.selectById(userId);
String grade = studentClass.getGrade(); String grade = studentClass.getGrade();
String Class1 = studentClass.getClass1(); String Class1 = studentClass.getClass1();
List<ClassVedio> list= iClassVedioService.selectClassVideo(grade,Class1); List<ClassVedio> list= iClassVedioService.selectClassVideo(grade,Class1);
@ -66,8 +60,7 @@ public class StudentVideoController {
public R<IPage<Video>> vedioListBySubject(int pagenum,String subject,int pagesize){ public R<IPage<Video>> vedioListBySubject(int pagenum,String subject,int pagesize){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId(); Long id = sysUser.getUserId();
Long userId = iUserService.user(iUserService.selectByzhid(id)).getUserId(); StudentClass studentClass = iStudentClassService.selectById(id);
StudentClass studentClass = iStudentClassService.selectById(userId);
String grade = studentClass.getGrade(); String grade = studentClass.getGrade();
String Class1 = studentClass.getClass1(); String Class1 = studentClass.getClass1();
List<ClassVedio> list= iClassVedioService.selectClassVideo(grade,Class1); List<ClassVedio> list= iClassVedioService.selectClassVideo(grade,Class1);

@ -26,9 +26,6 @@ import java.util.Map;
@RequestMapping("teacher/analysis") @RequestMapping("teacher/analysis")
public class TeacherAnalysisController { public class TeacherAnalysisController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private ITeacherManageClassService iTeacherManageClassService; private ITeacherManageClassService iTeacherManageClassService;
@ -51,9 +48,8 @@ public class TeacherAnalysisController {
@GetMapping("examPaperList") @GetMapping("examPaperList")
public R<IPage<ExamPaperDO>> examPaperList(int pagenum){ public R<IPage<ExamPaperDO>> examPaperList(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long id1 = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id1);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<ExamPaperDO> list1 = new ArrayList<>(); List<ExamPaperDO> list1 = new ArrayList<>();
Map<Long,List<String>> map = new HashMap<>(); Map<Long,List<String>> map = new HashMap<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){
@ -103,11 +99,9 @@ public class TeacherAnalysisController {
Double sum = 0.0; Double sum = 0.0;
for(StudentClass studentClass : list){ for(StudentClass studentClass : list){
Long studentid = studentClass.getStudentid(); Long studentid = studentClass.getStudentid();
String tname = iUserService.user(studentid).getTname();
System.out.println(tname);
Double score = 0.0; Double score = 0.0;
if(iMarkedtestService.selectmarkedtestBySenderAndTestid(studentClass.getStudentid(),testid)!=null){ if(iMarkedtestService.selectmarkedtestBySenderIdAndTestid(studentClass.getStudentid(),testid)!=null){
score =iMarkedtestService.selectmarkedtestBySenderAndTestid(studentClass.getStudentid(),testid).getScore(); score =iMarkedtestService.selectmarkedtestBySenderIdAndTestid(studentClass.getStudentid(),testid).getScore();
} }
sum+=score; sum+=score;
} }

@ -22,8 +22,6 @@ import java.util.List;
@RequestMapping("/teacher/answerSheet") @RequestMapping("/teacher/answerSheet")
public class TeacherAnswerSheetController { public class TeacherAnswerSheetController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IAnswerSheetDOService iAnswerSheetDOService; private IAnswerSheetDOService iAnswerSheetDOService;
@ -47,8 +45,8 @@ public class TeacherAnswerSheetController {
@ApiOperation("查看学生的考试情况(最新)") @ApiOperation("查看学生的考试情况(最新)")
@GetMapping("selectQuestionanswer") @GetMapping("selectQuestionanswer")
public R<QuestionAnswerDO> selectQuestionanswer(Long senderId,String sender, Long testid) { public R<QuestionAnswerDO> selectQuestionanswer(Long senderId, Long testid) {
return R.ok(iQuestionanswerService.selectQuestionanswer(senderId,sender,testid)); return R.ok(iQuestionanswerService.selectQuestionanswer(senderId,testid));
} }
@ApiOperation("批改客观题") @ApiOperation("批改客观题")
@ -63,8 +61,8 @@ public class TeacherAnswerSheetController {
@ApiOperation("试卷批改完毕提交") @ApiOperation("试卷批改完毕提交")
@PostMapping("addmarkedtest") @PostMapping("addmarkedtest")
public R<String> addmarkedtest(Long senderId,String sender,Long testid){ public R<String> addmarkedtest(Long senderId,Long testid){
if(iMarkedtestService.addmarkedtest(senderId,sender,testid)!=0){ if(iMarkedtestService.addmarkedtest(senderId,testid)!=0){
return R.ok("提交完成!"); return R.ok("提交完成!");
} }
return R.fail("提交失败!"); return R.fail("提交失败!");
@ -74,8 +72,7 @@ public class TeacherAnswerSheetController {
@GetMapping("selectmarkedtest") @GetMapping("selectmarkedtest")
public R<IPage<Markedtest>> selectmarkedtest(int pagenum){ public R<IPage<Markedtest>> selectmarkedtest(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long teacherid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<StudentClass> list1 = new ArrayList<>(); List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){
@ -89,14 +86,12 @@ public class TeacherAnswerSheetController {
@GetMapping("selectmarkedtestBySubject") @GetMapping("selectmarkedtestBySubject")
public R<IPage<Markedtest>> selectmarkedtestBySubject(int pagenum,String subject){ public R<IPage<Markedtest>> selectmarkedtestBySubject(int pagenum,String subject){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long teacherid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<StudentClass> list1 = new ArrayList<>(); List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){
list1.addAll(iStudentClassService.selectByGradeAndClass(teacherManageClass.getGrade(),teacherManageClass.getClass1())); list1.addAll(iStudentClassService.selectByGradeAndClass(teacherManageClass.getGrade(),teacherManageClass.getClass1()));
} }
System.out.println(11111+" "+list1);
return R.ok(iMarkedtestService.selectmarkedtestBySubject(pagenum,list1,subject)); return R.ok(iMarkedtestService.selectmarkedtestBySubject(pagenum,list1,subject));
} }
} }

@ -11,7 +11,6 @@ import com.ruoyi.test.domain.TeacherManageClass;
import com.ruoyi.test.seriver.IClass1Service; import com.ruoyi.test.seriver.IClass1Service;
import com.ruoyi.test.seriver.IStudentClassService; import com.ruoyi.test.seriver.IStudentClassService;
import com.ruoyi.test.seriver.ITeacherManageClassService; import com.ruoyi.test.seriver.ITeacherManageClassService;
import com.ruoyi.test.seriver.IUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -25,9 +24,6 @@ import java.util.List;
@RequestMapping("teacher/class") @RequestMapping("teacher/class")
public class TeacherClassController { public class TeacherClassController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private ITeacherManageClassService iTeacherManageClassService; private ITeacherManageClassService iTeacherManageClassService;
@ -41,9 +37,8 @@ public class TeacherClassController {
@GetMapping("classList") @GetMapping("classList")
public R<IPage<Class1>> classList(int pagenum){ public R<IPage<Class1>> classList(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long id = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<Class1> list1 = new ArrayList<>(); List<Class1> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){
String grade = teacherManageClass.getGrade(); String grade = teacherManageClass.getGrade();
@ -85,9 +80,8 @@ public class TeacherClassController {
public R<String> addclass1(String name,String grade,String Class1){ public R<String> addclass1(String name,String grade,String Class1){
if(iClass1Service.addclass1(name,grade,Class1)!=0){ if(iClass1Service.addclass1(name,grade,Class1)!=0){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long id = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid); iTeacherManageClassService.addclass1(id,grade,Class1);
iTeacherManageClassService.addclass1(teacherid,grade,Class1);
return R.ok("创建成功!"); return R.ok("创建成功!");
} }
return R.fail("创建失败!"); return R.fail("创建失败!");

@ -26,9 +26,6 @@ import java.util.Map;
@RequestMapping("/teacher/examPaper") @RequestMapping("/teacher/examPaper")
public class TeacherExamPaperController { public class TeacherExamPaperController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IExamPaperService iExamPaperService; private IExamPaperService iExamPaperService;
@ -51,9 +48,8 @@ public class TeacherExamPaperController {
@GetMapping("examPaperList") @GetMapping("examPaperList")
public R<IPage<ClassExamPaperDO>> examPaperList(int pagenum){ public R<IPage<ClassExamPaperDO>> examPaperList(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long id1 = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id1);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<ClassExamPaperDO> list1 = new ArrayList<>(); List<ClassExamPaperDO> list1 = new ArrayList<>();
Map<Long,List<String>> map = new HashMap<>(); Map<Long,List<String>> map = new HashMap<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){
@ -97,8 +93,7 @@ public class TeacherExamPaperController {
@GetMapping("examPaperListById") @GetMapping("examPaperListById")
public R<ClassExamPaperDO> examPaperListById(int pagenum,Long id){ public R<ClassExamPaperDO> examPaperListById(int pagenum,Long id){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long teacherid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
ClassExamPaperDO classExamPaperDO = new ClassExamPaperDO(); ClassExamPaperDO classExamPaperDO = new ClassExamPaperDO();
classExamPaperDO.setId(id); classExamPaperDO.setId(id);
@ -128,8 +123,7 @@ public class TeacherExamPaperController {
@GetMapping("examPaperListByStuject") @GetMapping("examPaperListByStuject")
public R<IPage<ClassExamPaperDO>> examPaperListById(int pagenum,String subject){ public R<IPage<ClassExamPaperDO>> examPaperListById(int pagenum,String subject){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long teacherid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<ExamPaper> list3 = iExamPaperService.selectBySubject(subject); List<ExamPaper> list3 = iExamPaperService.selectBySubject(subject);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<ClassExamPaperDO> list1 = new ArrayList<>(); List<ClassExamPaperDO> list1 = new ArrayList<>();
@ -177,8 +171,7 @@ public class TeacherExamPaperController {
@PostMapping("Class") @PostMapping("Class")
public R<List<Class1>> Class(){ public R<List<Class1>> Class(){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long teacherid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<Class1> list1 = new ArrayList<>(); List<Class1> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){

@ -26,9 +26,6 @@ public class TeacherHomePageController {
@Autowired @Autowired
private ITeacherManageClassService iTeacherManageClassService; private ITeacherManageClassService iTeacherManageClassService;
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private IStudentClassService iStudentClassService; private IStudentClassService iStudentClassService;
@ -48,8 +45,7 @@ public class TeacherHomePageController {
@GetMapping("homepagesuju") @GetMapping("homepagesuju")
public R<HomepageDO> homepagesuju(){ public R<HomepageDO> homepagesuju(){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long teacherid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
HomepageDO homepageDO = new HomepageDO(); HomepageDO homepageDO = new HomepageDO();
Integer total = iTeacherManageClassService.totalClass(teacherid).size(); Integer total = iTeacherManageClassService.totalClass(teacherid).size();
homepageDO.setSumclass(total); homepageDO.setSumclass(total);

@ -8,11 +8,9 @@ import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.test.domain.DO.StudentListDO; import com.ruoyi.test.domain.DO.StudentListDO;
import com.ruoyi.test.domain.StudentClass; import com.ruoyi.test.domain.StudentClass;
import com.ruoyi.test.domain.TeacherManageClass; import com.ruoyi.test.domain.TeacherManageClass;
import com.ruoyi.test.domain.User;
import com.ruoyi.test.seriver.IStudentClassService; import com.ruoyi.test.seriver.IStudentClassService;
import com.ruoyi.test.seriver.IClassExamPaperService; import com.ruoyi.test.seriver.IClassExamPaperService;
import com.ruoyi.test.seriver.ITeacherManageClassService; import com.ruoyi.test.seriver.ITeacherManageClassService;
import com.ruoyi.test.seriver.IUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -28,9 +26,6 @@ import java.util.List;
@RequestMapping("/teacher/users") @RequestMapping("/teacher/users")
public class TeacherUserController { public class TeacherUserController {
@Autowired
private IUserService iUserService;
@Autowired @Autowired
private ITeacherManageClassService iTeacherManageClassService; private ITeacherManageClassService iTeacherManageClassService;
@ -44,9 +39,8 @@ public class TeacherUserController {
@GetMapping("studentList") @GetMapping("studentList")
public R<IPage<StudentListDO>> studentList(int pagenum){ public R<IPage<StudentListDO>> studentList(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long id = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<StudentClass> list1 = new ArrayList<>(); List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){
String grade = teacherManageClass.getGrade(); String grade = teacherManageClass.getGrade();
@ -60,11 +54,12 @@ public class TeacherUserController {
studentListDO.setGrade(studentClass.getGrade()); studentListDO.setGrade(studentClass.getGrade());
studentListDO.setClass1(studentClass.getClass1()); studentListDO.setClass1(studentClass.getClass1());
studentListDO.setAddtime(studentClass.getAddtime()); studentListDO.setAddtime(studentClass.getAddtime());
User user = iUserService.user(studentClass.getStudentid()); // User user = iUserService.user(studentClass.getStudentid());
studentListDO.setName(user.getName()); // SysUser sysUser1 =
studentListDO.setTname(user.getTname()); // studentListDO.setName(user.getName());
studentListDO.setSex(user.getSex()); // studentListDO.setTname(user.getTname());
studentListDO.setTelephone(user.getTelephone()); // studentListDO.setSex(user.getSex());
// studentListDO.setTelephone(user.getTelephone());
listDOS.add(studentListDO); listDOS.add(studentListDO);
} }
Page<StudentListDO> page = new Page<>(pagenum,10); Page<StudentListDO> page = new Page<>(pagenum,10);
@ -77,9 +72,8 @@ public class TeacherUserController {
@GetMapping("studentListByName") @GetMapping("studentListByName")
public R<IPage<StudentListDO>> studentListByName(int pagenum,String name){ public R<IPage<StudentListDO>> studentListByName(int pagenum,String name){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long id = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<StudentClass> list1 = new ArrayList<>(); List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){
String grade = teacherManageClass.getGrade(); String grade = teacherManageClass.getGrade();
@ -88,19 +82,19 @@ public class TeacherUserController {
} }
List<StudentListDO> listDOS = new ArrayList<>(); List<StudentListDO> listDOS = new ArrayList<>();
for(StudentClass studentClass : list1){ for(StudentClass studentClass : list1){
User user = iUserService.user(studentClass.getStudentid()); // User user = iUserService.user(studentClass.getStudentid());
if(!user.getName().equals(name)){ // if(!user.getName().equals(name)){
continue; // continue;
} // }
StudentListDO studentListDO = new StudentListDO(); StudentListDO studentListDO = new StudentListDO();
studentListDO.setId(studentClass.getStudentid()); studentListDO.setId(studentClass.getStudentid());
studentListDO.setGrade(studentClass.getGrade()); studentListDO.setGrade(studentClass.getGrade());
studentListDO.setClass1(studentClass.getClass1()); studentListDO.setClass1(studentClass.getClass1());
studentListDO.setAddtime(studentClass.getAddtime()); studentListDO.setAddtime(studentClass.getAddtime());
studentListDO.setName(user.getName()); // studentListDO.setName(user.getName());
studentListDO.setTname(user.getTname()); // studentListDO.setTname(user.getTname());
studentListDO.setSex(user.getSex()); // studentListDO.setSex(user.getSex());
studentListDO.setTelephone(user.getTelephone()); // studentListDO.setTelephone(user.getTelephone());
listDOS.add(studentListDO); listDOS.add(studentListDO);
} }
Page<StudentListDO> page = new Page<>(pagenum,10); Page<StudentListDO> page = new Page<>(pagenum,10);
@ -113,9 +107,8 @@ public class TeacherUserController {
@GetMapping("studentListByClass") @GetMapping("studentListByClass")
public R<IPage<StudentListDO>> studentListByClass(int pagenum,String Class){ public R<IPage<StudentListDO>> studentListByClass(int pagenum,String Class){
SysUser sysUser = SecurityUtils.getLoginUser().getUser(); SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId(); Long id = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid); List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<StudentClass> list1 = new ArrayList<>(); List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){ for(TeacherManageClass teacherManageClass : list){
String grade = teacherManageClass.getGrade(); String grade = teacherManageClass.getGrade();
@ -126,16 +119,16 @@ public class TeacherUserController {
} }
List<StudentListDO> listDOS = new ArrayList<>(); List<StudentListDO> listDOS = new ArrayList<>();
for(StudentClass studentClass : list1){ for(StudentClass studentClass : list1){
User user = iUserService.user(studentClass.getStudentid()); // User user = iUserService.user(studentClass.getStudentid());
StudentListDO studentListDO = new StudentListDO(); StudentListDO studentListDO = new StudentListDO();
studentListDO.setId(studentClass.getStudentid()); studentListDO.setId(studentClass.getStudentid());
studentListDO.setGrade(studentClass.getGrade()); studentListDO.setGrade(studentClass.getGrade());
studentListDO.setClass1(studentClass.getClass1()); studentListDO.setClass1(studentClass.getClass1());
studentListDO.setAddtime(studentClass.getAddtime()); studentListDO.setAddtime(studentClass.getAddtime());
studentListDO.setName(user.getName()); // studentListDO.setName(user.getName());
studentListDO.setTname(user.getTname()); // studentListDO.setTname(user.getTname());
studentListDO.setSex(user.getSex()); // studentListDO.setSex(user.getSex());
studentListDO.setTelephone(user.getTelephone()); // studentListDO.setTelephone(user.getTelephone());
listDOS.add(studentListDO); listDOS.add(studentListDO);
} }
Page<StudentListDO> page = new Page<>(pagenum,10); Page<StudentListDO> page = new Page<>(pagenum,10);

@ -70,6 +70,16 @@ public class SysUser extends BaseEntity
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
private Date loginDate; private Date loginDate;
private String studentnumber;
public String getStudentnumber() {
return studentnumber;
}
public void setStudentnumber(String studentnumber) {
this.studentnumber = studentnumber;
}
/** 部门对象 */ /** 部门对象 */
@Excels({ @Excels({
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),

@ -206,7 +206,7 @@ public class SysRoleServiceImpl implements ISysRoleService
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role); List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
if (StringUtils.isEmpty(roles)) if (StringUtils.isEmpty(roles))
{ {
throw new ServiceException("没有权限访问角色数据!"); // throw new ServiceException("没有权限访问角色数据!");
} }
} }
} }

@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="studentnumber" column="studentnumber"/>
<association property="dept" javaType="SysDept" resultMap="deptResult" /> <association property="dept" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" /> <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap> </resultMap>
@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectUserVo"> <sql id="selectUserVo">
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.studentnumber,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u from sys_user u
@ -190,6 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="loginDate != null">login_date = #{loginDate},</if> <if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="studentnumber != null">studentnumber = #{studentnumber},</if>
update_time = sysdate() update_time = sysdate()
</set> </set>
where user_id = #{userId} where user_id = #{userId}

@ -9,7 +9,6 @@ import lombok.Data;
public class Answer { public class Answer {
private Long senderId; private Long senderId;
private String sender;
private Long testid; private Long testid;
private String idanswer; private String idanswer;
private String finishtime; private String finishtime;

@ -12,5 +12,6 @@ public class ExamPaperDO {
private String grade; private String grade;
private String name; private String name;
private String createtime; private String createtime;
private Long status;
} }

@ -7,8 +7,7 @@ import java.util.List;
@Data @Data
public class QuestionAnswerDO { public class QuestionAnswerDO {
private Long senderId;
private String sender;
private long testid; private long testid;
private List<QuestionanswerVo> list; private List<QuestionanswerVo> list;

@ -5,12 +5,12 @@ import lombok.Data;
@Data @Data
public class UserDO { public class UserDO {
private Long userId; private Long userId;
private String name; private String userName;
private String tname; private String nickName;
private Long age; private Long age;
private String sex; private String sex;
private String birthday; private String birthday;
private String telephone; private String phonenumber;
private String grade; private String grade;
private String Class1; private String Class1;
private String teacherName; private String teacherName;

@ -7,7 +7,7 @@ import lombok.Data;
@TableName("errorbook") @TableName("errorbook")
public class Errorbook { public class Errorbook {
private String sender; private Long senderId;
private String content; private String content;
private String chance; private String chance;
private String answer; private String answer;

@ -6,11 +6,12 @@ import lombok.Data;
@TableName("exam_paper") @TableName("exam_paper")
public class ExamPaper { public class ExamPaper {
private long id; private Long id;
private String grade; private String grade;
private String subject; private String subject;
private String createtime; private String createtime;
private String name; private String name;
private String type; private String type;
private Integer time; private Integer time;
private Integer status;
} }

@ -0,0 +1,12 @@
package com.ruoyi.test.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("instructor_manage_class")
public class InstructorManageClass {
private Long id;
private String grade;
private String Class1;
}

@ -8,7 +8,6 @@ import lombok.Data;
public class Markedtest { public class Markedtest {
private Long senderId; private Long senderId;
private String sender;
private long testid; private long testid;
private double score; private double score;
private double totalscore; private double totalscore;

@ -6,9 +6,7 @@ import lombok.Data;
@Data @Data
@TableName("questionanswer") @TableName("questionanswer")
public class Questionanswer { public class Questionanswer {
private Long senderId; private Long senderId;
private String sender;
private long testid; private long testid;
private String qa; private String qa;
private String createtime; private String createtime;

@ -11,7 +11,6 @@ public class StudentClass {
private Long studentid; private Long studentid;
private String grade; private String grade;
private String Class1; private String Class1;
private String addtime; private String addtime;
} }

@ -8,7 +8,7 @@ import lombok.Data;
@TableName("teacher_manage_class") @TableName("teacher_manage_class")
public class TeacherManageClass { public class TeacherManageClass {
private long teacherid; private Long teacherid;
private String grade; private String grade;
private String Class1; private String Class1;

@ -1,133 +0,0 @@
package com.ruoyi.test.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("user")
public class User {
private long userId;
private String name;
private String tname;
private long age;
private String sex;
private String birthday;
private String telephone;
private String grade;
private String createtime;
private long state;
private String roleKey;
private long zhId;
private String email;
private String studentnumber;
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTname() {
return tname;
}
public void setTname(String tname) {
this.tname = tname;
}
public long getAge() {
return age;
}
public void setAge(long age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public long getState() {
return state;
}
public void setState(long state) {
this.state = state;
}
public String getRoleKey() {
return roleKey;
}
public void setRoleKey(String roleKey) {
this.roleKey = roleKey;
}
public long getZhId() {
return zhId;
}
public void setZhId(long zhId) {
this.zhId = zhId;
}
}

@ -8,7 +8,7 @@ import java.util.Map;
@Data @Data
public class ErrorbookVo { public class ErrorbookVo {
private String sender; private Long senderId;
private String content; private String content;
private List<Map<String,String>> chance; private List<Map<String,String>> chance;
private String answer; private String answer;

@ -1,23 +0,0 @@
package com.ruoyi.test.domain.Vo;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.util.Date;
@Data
public class UserVo {
@TableId(value = "user_id")
private Long userId;
private String name;
private String tname;
private long age;
private String sex;
private String birthday;
private String telephone;
private String grade;
private long state;
private String email;
private String studentnumber;
}

@ -12,5 +12,5 @@ import java.util.List;
public interface AnswerMapper extends BaseMapper<Answer> { public interface AnswerMapper extends BaseMapper<Answer> {
int answer(@Param("answer") Answer answer); int answer(@Param("answer") Answer answer);
List<Answer> selectBySender(@Param("sender") String sender); List<Answer> selectBySender(@Param("sender") Long senderId);
} }

@ -0,0 +1,9 @@
package com.ruoyi.test.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.test.domain.InstructorManageClass;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface InstructorManageClassMapper extends BaseMapper<InstructorManageClass> {
}

@ -1,15 +0,0 @@
package com.ruoyi.test.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.test.domain.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UserMapper extends BaseMapper<User> {
// List<User> seleteUser(String name);
int insertUser(User user);
}

@ -9,9 +9,9 @@ public interface IAnswerService {
int answer(Answer answer); int answer(Answer answer);
Answer selectByTestId(Long senderId,String sender,Long testid); Answer selectByTestId(Long senderId,Long testid);
List<Answer> selectBySender(String sender); List<Answer> selectBySenderId(Long senderId);
Boolean selectBySenderIdAndTestId(Long senderId,Long testid); Boolean selectBySenderIdAndTestId(Long senderId,Long testid);

@ -8,7 +8,7 @@ public interface IErrorbookService {
int addErrorBook(Errorbook errorbook); int addErrorBook(Errorbook errorbook);
IPage<ErrorbookVo> selectErrorBook(int pagenum,String sender); IPage<ErrorbookVo> selectErrorBook(int pagenum,Long senderId);
IPage<ErrorbookVo> selectErrorBookBySubject(int pagenum,String sender,String subject); IPage<ErrorbookVo> selectErrorBookBySubject(int pagenum,Long senderId,String subject);
} }

@ -0,0 +1,8 @@
package com.ruoyi.test.seriver;
import com.ruoyi.test.domain.InstructorManageClass;
public interface IInstructorManageClassService {
InstructorManageClass selectByGradeAndClass1(String grade ,String Class1);
}

@ -8,7 +8,7 @@ import java.util.List;
public interface IMarkedtestService { public interface IMarkedtestService {
int addmarkedtest(Long senderId,String sender,Long testid); int addmarkedtest(Long senderId,Long testid);
IPage<Markedtest> selectmarkedtest(int pagenum); IPage<Markedtest> selectmarkedtest(int pagenum);
@ -18,11 +18,11 @@ public interface IMarkedtestService {
IPage<Markedtest> selectmarkedtestBySubject(int pagenum,List<StudentClass> list,String subject); IPage<Markedtest> selectmarkedtestBySubject(int pagenum,List<StudentClass> list,String subject);
List<Markedtest> selectmarkedtestListBySenderAndSenderId(String sender,Long senderId); List<Markedtest> selectmarkedtestListSenderId(Long senderId);
Markedtest selectmarkedtestBySenderAndTestid(String sender,Long senderId); Markedtest selectmarkedtestBySenderId(Long senderId);
Markedtest selectmarkedtestBySenderAndTestid(Long senderId,Long testId); Markedtest selectmarkedtestBySenderIdAndTestid(Long senderId,Long testId);
Markedtest selectmarkedtestByTestid(Long id,Long testId); Markedtest selectmarkedtestByTestid(Long id,Long testId);
} }

@ -17,7 +17,7 @@ public interface IQuestionanswerService {
int addTest(QuestionAnswerDO questionAnswerDO); int addTest(QuestionAnswerDO questionAnswerDO);
QuestionAnswerDO selectQuestionanswer(Long senderId,String sender,Long id); QuestionAnswerDO selectQuestionanswer(Long senderId,Long id);
int markObjectiveQuestions(QuestionAnswerDO questionAnswerDO); int markObjectiveQuestions(QuestionAnswerDO questionAnswerDO);

@ -12,7 +12,7 @@ public interface ITaskService {
IPage<Task> selectListByGrade(String grade,int pagenum); IPage<Task> selectListByGrade(String grade,int pagenum);
int addTask(TaskVo taskVo,String username); int addTask(TaskVo taskVo,String sender);
int deleteTask(Long id); int deleteTask(Long id);

@ -11,4 +11,6 @@ public interface ITeacherManageClassService {
int deleteClass(String grade,String Class1); int deleteClass(String grade,String Class1);
int addclass1(Long teacherid,String grade,String Class1); int addclass1(Long teacherid,String grade,String Class1);
TeacherManageClass selectByGradeAndClass(String grade,String Class1);
} }

@ -1,36 +0,0 @@
package com.ruoyi.test.seriver;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.test.domain.DO.UserDO;
import com.ruoyi.test.domain.User;
import com.ruoyi.test.domain.Vo.UserVo;
import java.util.List;
public interface IUserService {
//获取学生列表
IPage<User> selectStudentList(int pagenum);
//根据用户名查询学生用户
IPage<User> selectStudent(int pagenum,String name);
//绑定学生/老师/管理员用户信息
int insertUser(User user);
//
List<User> selectStudentByZhid(Long zhid);
//获取教师列表
IPage<User> selectTeacherList(int pagenum);
//根据用户名查询教师用户
IPage<User> selectTeacher(int pagenum,String name);
IPage<User> selectGlList(int pagenum);
//根据用户名查询学生用户
IPage<User> selectGl(int pagenum,String name);
//通过账号查询用户id
Long selectByzhid(Long zhid);
User user(Long id);
UserDO getUserById(Long id);
}

@ -24,18 +24,17 @@ public class AnswerServiceImpl extends ServiceImpl<AnswerMapper, Answer> impleme
} }
@Override @Override
public Answer selectByTestId(Long senderId,String sender,Long testid) { public Answer selectByTestId(Long senderId,Long testid) {
LambdaQueryWrapper<Answer> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Answer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Answer::getTestid,testid); queryWrapper.eq(Answer::getTestid,testid);
queryWrapper.eq(Answer::getSender,sender);
queryWrapper.eq(Answer::getSenderId,senderId); queryWrapper.eq(Answer::getSenderId,senderId);
queryWrapper.orderByDesc(Answer::getFinishtime).last("LIMIT 1"); queryWrapper.orderByDesc(Answer::getFinishtime).last("LIMIT 1");
return answerMapper.selectOne(queryWrapper); return answerMapper.selectOne(queryWrapper);
} }
@Override @Override
public List<Answer> selectBySender(String sender) { public List<Answer> selectBySenderId(Long senderId) {
return answerMapper.selectBySender(sender); return answerMapper.selectBySender(senderId);
} }
@Override @Override

@ -32,14 +32,14 @@ public class ErrorbookServiceImpl extends ServiceImpl<ErrorbookMapper, Errorbook
} }
@Override @Override
public IPage<ErrorbookVo> selectErrorBook(int pagenum, String sender) { public IPage<ErrorbookVo> selectErrorBook(int pagenum,Long senderId) {
LambdaQueryWrapper<Errorbook> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Errorbook> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Errorbook::getSender,sender); queryWrapper.eq(Errorbook::getSenderId,senderId);
List<Errorbook> list = errorbookMapper.selectList(queryWrapper); List<Errorbook> list = errorbookMapper.selectList(queryWrapper);
List<ErrorbookVo> list1 = new ArrayList<>(); List<ErrorbookVo> list1 = new ArrayList<>();
for(Errorbook errorbook : list){ for(Errorbook errorbook : list){
ErrorbookVo errorbookVo = new ErrorbookVo(); ErrorbookVo errorbookVo = new ErrorbookVo();
errorbookVo.setSender(sender); errorbookVo.setSenderId(senderId);
errorbookVo.setContent(errorbook.getContent()); errorbookVo.setContent(errorbook.getContent());
errorbookVo.setDifficulty(errorbook.getDifficulty()); errorbookVo.setDifficulty(errorbook.getDifficulty());
errorbookVo.setAnswer(errorbook.getAnswer()); errorbookVo.setAnswer(errorbook.getAnswer());
@ -63,15 +63,15 @@ public class ErrorbookServiceImpl extends ServiceImpl<ErrorbookMapper, Errorbook
} }
@Override @Override
public IPage<ErrorbookVo> selectErrorBookBySubject(int pagenum, String sender, String subject) { public IPage<ErrorbookVo> selectErrorBookBySubject(int pagenum, Long senderId, String subject) {
LambdaQueryWrapper<Errorbook> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Errorbook> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Errorbook::getSender,sender) queryWrapper.eq(Errorbook::getSenderId,senderId)
.eq(Errorbook::getSubject,subject); .eq(Errorbook::getSubject,subject);
List<Errorbook> list = errorbookMapper.selectList(queryWrapper); List<Errorbook> list = errorbookMapper.selectList(queryWrapper);
List<ErrorbookVo> list1 = new ArrayList<>(); List<ErrorbookVo> list1 = new ArrayList<>();
for(Errorbook errorbook : list){ for(Errorbook errorbook : list){
ErrorbookVo errorbookVo = new ErrorbookVo(); ErrorbookVo errorbookVo = new ErrorbookVo();
errorbookVo.setSender(sender); errorbookVo.setSenderId(senderId);
errorbookVo.setContent(errorbook.getContent()); errorbookVo.setContent(errorbook.getContent());
errorbookVo.setDifficulty(errorbook.getDifficulty()); errorbookVo.setDifficulty(errorbook.getDifficulty());
errorbookVo.setAnswer(errorbook.getAnswer()); errorbookVo.setAnswer(errorbook.getAnswer());

@ -0,0 +1,24 @@
package com.ruoyi.test.seriver.Impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.test.domain.InstructorManageClass;
import com.ruoyi.test.mapper.InstructorManageClassMapper;
import com.ruoyi.test.seriver.IInstructorManageClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class InstructorManageClassServiceImpl extends ServiceImpl<InstructorManageClassMapper, InstructorManageClass> implements IInstructorManageClassService {
@Autowired
private InstructorManageClassMapper instructorManageClassMapper;
@Override
public InstructorManageClass selectByGradeAndClass1(String grade, String Class1) {
LambdaQueryWrapper<InstructorManageClass> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InstructorManageClass::getGrade,grade)
.eq(InstructorManageClass::getClass1,Class1);
return instructorManageClassMapper.selectOne(queryWrapper);
}
}

@ -44,12 +44,10 @@ public class MarkedtestServiceImpl extends ServiceImpl<MarkedtestMapper, Markedt
@Autowired @Autowired
private IExamPaperService iExamPaperService; private IExamPaperService iExamPaperService;
@Autowired
private IUserService iUserService;
@Override @Override
public int addmarkedtest(Long senderId,String sender,Long testid) { public int addmarkedtest(Long senderId,Long testid) {
QuestionAnswerDO questionAnswerDO = iQuestionanswerService.selectQuestionanswer(senderId,sender,testid); QuestionAnswerDO questionAnswerDO = iQuestionanswerService.selectQuestionanswer(senderId,testid);
int totalscore = 0; int totalscore = 0;
int score = 0; int score = 0;
@ -68,11 +66,10 @@ public class MarkedtestServiceImpl extends ServiceImpl<MarkedtestMapper, Markedt
totalquestions++; totalquestions++;
} }
Answer answer = iAnswerService.selectByTestId(senderId,sender, testid); Answer answer = iAnswerService.selectByTestId(senderId, testid);
Markedtest markedtest = new Markedtest(); Markedtest markedtest = new Markedtest();
markedtest.setSenderId(senderId); markedtest.setSenderId(senderId);
markedtest.setSender(sender);
markedtest.setTestid(testid); markedtest.setTestid(testid);
markedtest.setScore(score); markedtest.setScore(score);
markedtest.setTotalscore(totalscore); markedtest.setTotalscore(totalscore);
@ -115,9 +112,7 @@ public class MarkedtestServiceImpl extends ServiceImpl<MarkedtestMapper, Markedt
public IPage<Markedtest> selectmarkedtest(int pagenum, List<StudentClass> list1) { public IPage<Markedtest> selectmarkedtest(int pagenum, List<StudentClass> list1) {
List<Markedtest> list = new ArrayList<>(); List<Markedtest> list = new ArrayList<>();
for(StudentClass studentClass : list1){ for(StudentClass studentClass : list1){
String tname = iUserService.user(studentClass.getStudentid()).getTname();
LambdaQueryWrapper<Markedtest> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Markedtest> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Markedtest::getSender,tname);
list.addAll(markedtestMapper.selectList(queryWrapper)); list.addAll(markedtestMapper.selectList(queryWrapper));
} }
Page<Markedtest> page = new Page<>(pagenum,10); Page<Markedtest> page = new Page<>(pagenum,10);
@ -137,9 +132,7 @@ public class MarkedtestServiceImpl extends ServiceImpl<MarkedtestMapper, Markedt
} }
List<Markedtest> list3 = new ArrayList<>(); List<Markedtest> list3 = new ArrayList<>();
for(StudentClass studentClass : list){ for(StudentClass studentClass : list){
String tname = iUserService.user(studentClass.getStudentid()).getTname();
LambdaQueryWrapper<Markedtest> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Markedtest> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(Markedtest::getSender,tname);
List<Markedtest> list4 = markedtestMapper.selectList(queryWrapper1); List<Markedtest> list4 = markedtestMapper.selectList(queryWrapper1);
for(Markedtest markedtest : list4){ for(Markedtest markedtest : list4){
if(list2.contains(markedtest.getTestid())){ if(list2.contains(markedtest.getTestid())){
@ -154,23 +147,21 @@ public class MarkedtestServiceImpl extends ServiceImpl<MarkedtestMapper, Markedt
} }
@Override @Override
public List<Markedtest> selectmarkedtestListBySenderAndSenderId(String sender, Long senderId) { public List<Markedtest> selectmarkedtestListSenderId(Long senderId) {
LambdaQueryWrapper<Markedtest> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Markedtest> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Markedtest::getSender,sender) queryWrapper.eq(Markedtest::getSenderId,senderId);
.eq(Markedtest::getSenderId,senderId);
return markedtestMapper.selectList(queryWrapper); return markedtestMapper.selectList(queryWrapper);
} }
@Override @Override
public Markedtest selectmarkedtestBySenderAndTestid(String sender,Long senderId) { public Markedtest selectmarkedtestBySenderId(Long senderId) {
LambdaQueryWrapper<Markedtest> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Markedtest> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Markedtest::getSender,sender) queryWrapper.eq(Markedtest::getSenderId,senderId);
.eq(Markedtest::getSenderId,senderId);
return markedtestMapper.selectOne(queryWrapper); return markedtestMapper.selectOne(queryWrapper);
} }
@Override @Override
public Markedtest selectmarkedtestBySenderAndTestid(Long senderId, Long testId) { public Markedtest selectmarkedtestBySenderIdAndTestid(Long senderId, Long testId) {
LambdaQueryWrapper<Markedtest> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Markedtest> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Markedtest::getTestid,testId) queryWrapper.eq(Markedtest::getTestid,testId)
.eq(Markedtest::getSenderId,senderId); .eq(Markedtest::getSenderId,senderId);

@ -28,8 +28,8 @@ public class QuestionanswerServiceImpl extends ServiceImpl<QuestionanswerMapper,
public QuestionAnswerDO createTest(List<Questionbank> list, Answer answer) { public QuestionAnswerDO createTest(List<Questionbank> list, Answer answer) {
QuestionAnswerDO questionAnswerDO = new QuestionAnswerDO(); QuestionAnswerDO questionAnswerDO = new QuestionAnswerDO();
// System.out.println(answer.getTestid()); // System.out.println(answer.getTestid());
questionAnswerDO.setSender(answer.getSender());
questionAnswerDO.setTestid(answer.getTestid()); questionAnswerDO.setTestid(answer.getTestid());
questionAnswerDO.setSenderId(answer.getSenderId());
String idanswer = answer.getIdanswer(); String idanswer = answer.getIdanswer();
Gson gson = new Gson(); Gson gson = new Gson();
Type listType = new TypeToken<List<AnswerVo>>(){}.getType(); Type listType = new TypeToken<List<AnswerVo>>(){}.getType();
@ -81,7 +81,7 @@ public class QuestionanswerServiceImpl extends ServiceImpl<QuestionanswerMapper,
@Override @Override
public int addTest(QuestionAnswerDO questionAnswerDO) { public int addTest(QuestionAnswerDO questionAnswerDO) {
Questionanswer questionanswer = new Questionanswer(); Questionanswer questionanswer = new Questionanswer();
questionanswer.setSender(questionAnswerDO.getSender()); questionanswer.setSenderId(questionAnswerDO.getSenderId());
questionanswer.setTestid(questionAnswerDO.getTestid()); questionanswer.setTestid(questionAnswerDO.getTestid());
List<QuestionanswerVo> list = questionAnswerDO.getList(); List<QuestionanswerVo> list = questionAnswerDO.getList();
Gson gson = new Gson(); Gson gson = new Gson();
@ -91,11 +91,9 @@ public class QuestionanswerServiceImpl extends ServiceImpl<QuestionanswerMapper,
} }
@Override @Override
public QuestionAnswerDO selectQuestionanswer(Long senderId,String sender, Long id) { public QuestionAnswerDO selectQuestionanswer(Long senderId, Long id) {
System.out.println("-----------"+senderId+" "+sender+" "+id);
LambdaQueryWrapper<Questionanswer> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Questionanswer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Questionanswer::getSenderId,senderId); queryWrapper.eq(Questionanswer::getSenderId,senderId);
queryWrapper.eq(Questionanswer::getSender,sender);
queryWrapper.eq(Questionanswer::getTestid,id); queryWrapper.eq(Questionanswer::getTestid,id);
queryWrapper.orderByDesc(Questionanswer::getCreatetime).last("LIMIT 1"); queryWrapper.orderByDesc(Questionanswer::getCreatetime).last("LIMIT 1");
Questionanswer questionanswer = questionanswerMapper.selectOne(queryWrapper); Questionanswer questionanswer = questionanswerMapper.selectOne(queryWrapper);
@ -105,7 +103,6 @@ public class QuestionanswerServiceImpl extends ServiceImpl<QuestionanswerMapper,
Gson gson = new Gson(); Gson gson = new Gson();
List<QuestionanswerVo> dataList = gson.fromJson(qa,List.class); List<QuestionanswerVo> dataList = gson.fromJson(qa,List.class);
QuestionAnswerDO questionAnswerDO = new QuestionAnswerDO(); QuestionAnswerDO questionAnswerDO = new QuestionAnswerDO();
questionAnswerDO.setSender(questionanswer.getSender());
questionAnswerDO.setTestid(questionanswer.getTestid()); questionAnswerDO.setTestid(questionanswer.getTestid());
questionAnswerDO.setList(dataList); questionAnswerDO.setList(dataList);
// System.out.println(questionAnswerDO); // System.out.println(questionAnswerDO);
@ -115,7 +112,6 @@ public class QuestionanswerServiceImpl extends ServiceImpl<QuestionanswerMapper,
@Override @Override
public int markObjectiveQuestions(QuestionAnswerDO questionAnswerDO) { public int markObjectiveQuestions(QuestionAnswerDO questionAnswerDO) {
Questionanswer questionanswer = new Questionanswer(); Questionanswer questionanswer = new Questionanswer();
questionanswer.setSender(questionAnswerDO.getSender());
questionanswer.setTestid(questionAnswerDO.getTestid()); questionanswer.setTestid(questionAnswerDO.getTestid());
List<QuestionanswerVo> list = questionAnswerDO.getList(); List<QuestionanswerVo> list = questionAnswerDO.getList();
Gson gson = new Gson(); Gson gson = new Gson();

@ -38,8 +38,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements IT
} }
@Override @Override
public int addTask(TaskVo taskVo,String username) { public int addTask(TaskVo taskVo,String sender) {
return taskMapper.addTask(taskVo,username); return taskMapper.addTask(taskVo,sender);
} }
@Override @Override

@ -32,4 +32,12 @@ public class TeacherManageClassServiceImpl extends ServiceImpl<TeacherManageClas
public int addclass1(Long teacherid,String grade, String Class1) { public int addclass1(Long teacherid,String grade, String Class1) {
return teacherManageClassMapper.addclass1(teacherid,grade,Class1); return teacherManageClassMapper.addclass1(teacherid,grade,Class1);
} }
@Override
public TeacherManageClass selectByGradeAndClass(String grade, String Class1) {
LambdaQueryWrapper<TeacherManageClass> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TeacherManageClass::getGrade,grade)
.eq(TeacherManageClass::getClass1,Class1);
return teacherManageClassMapper.selectOne(queryWrapper);
}
} }

@ -1,169 +0,0 @@
package com.ruoyi.test.seriver.Impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.test.domain.DO.UserDO;
import com.ruoyi.test.domain.StudentClass;
import com.ruoyi.test.domain.TeacherManageClass;
import com.ruoyi.test.domain.User;
import com.ruoyi.test.domain.Vo.UserVo;
import com.ruoyi.test.mapper.StudentClassMapper;
import com.ruoyi.test.mapper.TeacherManageClassMapper;
import com.ruoyi.test.mapper.UserMapper;
import com.ruoyi.test.seriver.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@Resource
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements IUserService {
@Autowired
private UserMapper userMapper;
@Autowired
private StudentClassMapper studentClassMapper;
@Autowired
private TeacherManageClassMapper teacherManageClassMapper;
@Override
public IPage<User> selectStudentList(int pagenum) {
Page<User> page = new Page<>(pagenum,10);
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(User::getUserId,User::getName,User::getTname,User::getAge,User::getSex,User::getBirthday
,User::getTelephone,User::getGrade,User::getState);
queryWrapper.eq(User::getRoleKey,2L);
IPage<User> iPage = userMapper.selectPage(page,queryWrapper);
return iPage;
}
@Override
public IPage<User> selectStudent(int pagenum,String name) {
Page<User> page = new Page<>(pagenum,10);
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(User::getUserId,User::getName,User::getTname,User::getAge,User::getSex,User::getBirthday
,User::getTelephone,User::getGrade,User::getState);
queryWrapper.eq(User::getName,name);
queryWrapper.eq(User::getRoleKey,2L);
IPage<User> iPage = userMapper.selectPage(page,queryWrapper);
return iPage;
}
@Override
public int insertUser(User user) {
return userMapper.insertUser(user);
}
@Override
public List<User> selectStudentByZhid(Long zhid) {
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(User::getZhId,zhid);
return userMapper.selectList(queryWrapper);
}
@Override
public IPage<User> selectTeacherList(int pagenum) {
Page<User> page = new Page<>(pagenum,10);
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(User::getUserId,User::getName,User::getTname,User::getAge,User::getSex,User::getBirthday
,User::getTelephone,User::getGrade,User::getState);
queryWrapper.eq(User::getRoleKey,3L);
IPage<User> iPage = userMapper.selectPage(page,queryWrapper);
return iPage;
}
@Override
public IPage<User> selectTeacher(int pagenum,String name) {
Page<User> page = new Page<>(pagenum,10);
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(User::getUserId,User::getName,User::getTname,User::getAge,User::getSex,User::getBirthday
,User::getTelephone,User::getGrade,User::getState);
queryWrapper.eq(User::getName,name);
queryWrapper.eq(User::getRoleKey,3L);
IPage<User> iPage = userMapper.selectPage(page,queryWrapper);
return iPage;
}
@Override
public IPage<User> selectGlList(int pagenum) {
Page<User> page = new Page<>(pagenum,10);
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(User::getUserId,User::getName,User::getTname,User::getAge,User::getSex,User::getBirthday
,User::getTelephone,User::getGrade,User::getState);
queryWrapper.eq(User::getRoleKey,4L);
IPage<User> iPage = userMapper.selectPage(page,queryWrapper);
return iPage;
}
@Override
public IPage<User> selectGl(int pagenum,String name) {
Page<User> page = new Page<>(pagenum,10);
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(User::getUserId,User::getName,User::getTname,User::getAge,User::getSex,User::getBirthday
,User::getTelephone,User::getGrade,User::getState);
queryWrapper.eq(User::getName,name);
queryWrapper.eq(User::getRoleKey,4L);
IPage<User> iPage = userMapper.selectPage(page,queryWrapper);
return iPage;
}
@Override
public Long selectByzhid(Long zhid) {
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(User::getZhId,zhid);
return userMapper.selectOne(queryWrapper).getUserId();
}
@Override
public User user(Long id) {
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(User::getUserId,id);
return userMapper.selectOne(queryWrapper);
}
@Override
public UserDO getUserById(Long id) {
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(User::getUserId,id);
User user = userMapper.selectOne(queryWrapper);
UserDO userDO = new UserDO();
BeanUtils.copyProperties(user,userDO);
StudentClass studentClass = studentClassMapper.selectOne(new LambdaQueryWrapper<StudentClass>().eq(StudentClass::getStudentid, id));
userDO.setClass1(studentClass.getClass1());
TeacherManageClass teacherManageClass = teacherManageClassMapper.selectOne(
new LambdaQueryWrapper<TeacherManageClass>()
.eq(TeacherManageClass::getClass1, studentClass.getClass1())
.eq(TeacherManageClass::getGrade, studentClass.getGrade()));
User user1 = userMapper.selectOne(
new LambdaQueryWrapper<User>()
.eq(User::getUserId, teacherManageClass.getTeacherid()));
userDO.setTeacherName(user1.getTname());
return userDO;
}
public List<UserVo> up(List<User> list){
List<UserVo> list1 = new ArrayList<>();
for(User user:list){
UserVo userVo = new UserVo();
userVo.setUserId(user.getUserId());
userVo.setName(user.getName());
userVo.setTname(user.getTname());
userVo.setAge(user.getAge());
userVo.setGrade(user.getGrade());
userVo.setSex(user.getSex());
userVo.setBirthday(user.getBirthday());
userVo.setTelephone(user.getTelephone());
list1.add(userVo);
}
return list1;
}
}

@ -9,14 +9,12 @@
<insert id="answer" parameterType="Answer"> <insert id="answer" parameterType="Answer">
INSERT INTO answer ( INSERT INTO answer (
sender_id, sender_id,
sender,
testid, testid,
idanswer, idanswer,
finishtime, finishtime,
time time
)VALUES( )VALUES(
#{answer.senderId}, #{answer.senderId},
#{answer.sender},
#{answer.testid}, #{answer.testid},
#{answer.idanswer}, #{answer.idanswer},
Now(), Now(),
@ -37,7 +35,7 @@
SELECT testid, SELECT testid,
MIN(ABS(TIMESTAMPDIFF(SECOND, STR_TO_DATE(finishtime, '%Y-%m-%d %H:%i:%s'), NOW()))) AS min_time_diff MIN(ABS(TIMESTAMPDIFF(SECOND, STR_TO_DATE(finishtime, '%Y-%m-%d %H:%i:%s'), NOW()))) AS min_time_diff
FROM answer FROM answer
WHERE sender = #{sender} WHERE senderId = #{senderId}
GROUP BY testid GROUP BY testid
) b ON a.testid = b.testid AND ABS(TIMESTAMPDIFF(SECOND, STR_TO_DATE(a.finishtime, '%Y-%m-%d %H:%i:%s'), NOW())) = b.min_time_diff ) b ON a.testid = b.testid AND ABS(TIMESTAMPDIFF(SECOND, STR_TO_DATE(a.finishtime, '%Y-%m-%d %H:%i:%s'), NOW())) = b.min_time_diff
) AS t; ) AS t;

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--mybatis-3-mapper.dtd:约束文件的名称限制和检查在当前文件中出现的标签和属性符合mybatis的要求-->
<!--namespace命名空间要有唯一的值要求使用dao接口的权限定名称一个dao接口对应一个mappernamespace指明对应哪个dao接口-->
<mapper namespace="com.ruoyi.test.mapper.InstructorManageClassMapper">
<!-- 所有的数据库操作都要写在mapper标签中可以使用特定的标签表示数据库中的特定操作 -->
</mapper>

@ -7,12 +7,12 @@
<insert id="addQuestionanswer" parameterType="Questionanswer"> <insert id="addQuestionanswer" parameterType="Questionanswer">
insert into questionanswer( insert into questionanswer(
sender, sender_id,
testid, testid,
qa, qa,
createtime createtime
)values ( )values (
#{questionanswer.sender}, #{questionanswer.senderId},
#{questionanswer.testid}, #{questionanswer.testid},
#{questionanswer.qa}, #{questionanswer.qa},
Now() Now()

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--mybatis-3-mapper.dtd:约束文件的名称限制和检查在当前文件中出现的标签和属性符合mybatis的要求-->
<!--namespace命名空间要有唯一的值要求使用dao接口的权限定名称一个dao接口对应一个mappernamespace指明对应哪个dao接口-->
<mapper namespace="com.ruoyi.test.mapper.UserMapper">
<!-- 所有的数据库操作都要写在mapper标签中可以使用特定的标签表示数据库中的特定操作 -->
<insert id="insertUser" parameterType="User">
insert into user(
-- <if test="userId != null and userId != ''">user_id,</if>
<if test="name != null and name != ''">name,</if>
<if test="tname != null and tname != ''">tname,</if>
<if test="age != null and age != 0">age,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="birthday != null and birthday != ''">birthday,</if>
<if test="telephone != null and telephone != ''">telephone,</if>
<if test="grade != null and grade != ''">grade,</if>
<if test="state != null">state,</if>
<if test="roleKey != null and roleKey != ''">role_key,</if>
<if test="zhId != null and zhId != ''">zh_id</if>,
createtime
) values (
-- <if test="userId != null and userId != ''">#{userId},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="tname != null and tname != ''">#{tname},</if>
<if test="age != null and age != 0">#{age},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="birthday != null and birthday != ''">#{birthday},</if>
<if test="telephone != null and telephone != ''">#{telephone},</if>
<if test="grade != null and grade != ''">#{grade},</if>
<if test="state != null">#{state},</if>
<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
<if test="zhId != null and zhId != ''">#{zhId}</if>,
NOW() -- 或者使用数据库的当前时间函数
)
</insert>
</mapper>

@ -1,17 +1,8 @@
<template> <template>
<div class="login-container"> <div class="login-container">
<div class="login-box"> <div class="login-box">
<h2 style="color: white">登录</h2> <h2 style="color: white;padding-bottom: 10px">登录</h2>
<form @submit.prevent="login"> <form @submit.prevent="login">
<!-- Dropdown for User Role -->
<div class="input-group">
<i class="fas fa-users"></i>
<select v-model="role" required>
<option value="teacher">老师</option>
<option value="student">学生</option>
</select>
</div>
<!-- Username Field --> <!-- Username Field -->
<div class="input-group"> <div class="input-group">
<i class="fas fa-user"></i> <i class="fas fa-user"></i>
@ -46,7 +37,7 @@ import { mapActions } from "vuex";
export default { export default {
data() { data() {
return { return {
role: 'student', // Default value, either 'teacher' or 'student' // role: 'student', // Default value, either 'teacher' or 'student'
username: '', username: '',
password: '', password: '',
code: '', // code: '', //
@ -93,20 +84,23 @@ export default {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}}); }});
if(res.data.code==200){ if(res.data.code==200){
console.log('登录成功,用户角色:', res.data);
const token = response.data.token; const token = response.data.token;
this.setToken(token); // Store token using Vuex action const userId = res.data.user.userId;
if (res.data.role === '超级管理员') { console.log('userId', userId);
// this.$store.dispatch('setToken', { userId, token });
window.location.href = res.data.role === '老师' ? 'http://localhost:8082' : 'http://localhost:8081/user/profile'; if(res.data.roles[0] === 'student'){
} else if (res.data.role === role) { // 使 Vue Router
// this.$router.push({
if (role === '老师') { path: '/user/profile',
window.location.href = 'http://localhost:8082'; query: { userId: userId }
} else if (role === '学生') { });
window.location.href = 'http://localhost:8081/user/profile'; }else if(res.data.roles[0] === 'teacher'){
} this.$router.push({
} else { path: '/teacher/correct',
query: { userId: userId }
});
// window.location.href = 'http://localhost:8081/teacher/correct';
}else{
alert('该角色无权限'); alert('该角色无权限');
this.refreshCaptcha(); this.refreshCaptcha();
} }

@ -8,19 +8,22 @@
router router
> >
<div style="height: 60px;line-height: 60px;text-align: center"> <div style="height: 60px;line-height: 60px;text-align: center">
<img src="../assets/logo.png" alt="" style="width: 20px;position: relative;top: 5px;margin-right: 5px"> <img src="../../assets/logo.png" alt="" style="width: 20px;position: relative;top: 5px;margin-right: 5px">
<b style="color: white" v-show="logoTextShow">线</b> <b style="color: white" v-show="logoTextShow">线</b>
</div> </div>
<el-menu-item index="/user/profile"> <!-- 动态绑定 index使用模板字符串 -->
<i class="el-icon-house"></i> <el-menu-item :index="`/user/profile?userId=${userId}`">
<span>主页</span> <i class="el-icon-house"></i>
<span>主页</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/student/exam">
<el-menu-item :index="`/student/exam?userId=${userId}`">
<i class="el-icon-message"></i> <i class="el-icon-message"></i>
<span>试卷中心</span> <span>试卷中心</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/student/scoreList">
<i class="el-icon-message"></i> <el-menu-item :index="`/student/scoreList?userId=${userId}`">
<i class="el-icon-s-data"></i>
<span>分数查询</span> <span>分数查询</span>
</el-menu-item> </el-menu-item>
</el-menu> </el-menu>
@ -29,15 +32,20 @@
<script> <script>
export default { export default {
name: "Aside", name: "Aside",
data(){ data() {
return{ return {
hasStudentMenu: false, // false submenu hasStudentMenu: false, // false submenu
} userId: '', // userId
};
}, },
props: { props: {
isCollapse: Boolean, isCollapse: Boolean,
logoTextShow: Boolean logoTextShow: Boolean
}, },
created() {
// userId
this.userId = this.$route.query.userId;
}
} }
</script> </script>

@ -32,8 +32,7 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
font-size: 14px; font-size: 14px;
line-height: 60px; line-height: 50px;
background-color: #f5f5f5;
padding: 0 20px; padding: 0 20px;
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
} }

@ -0,0 +1,55 @@
<template>
<el-menu :default-openeds="['1', '3']" style="min-height: 100%; overflow-x: hidden"
background-color="rgb(48,65,86)"
text-color="#fff"
active-text-color="#ffd04b"
:collapse-transition="false"
:collapse="isCollapse"
router
>
<div style="height: 60px;line-height: 60px;text-align: center">
<img src="../../assets/logo.png" alt="" style="width: 20px;position: relative;top: 5px;margin-right: 5px">
<b style="color: white" v-show="logoTextShow">线</b>
</div>
<el-menu-item :index="`/teacher/homePage?userId=${userId}`">
<i class="el-icon-house"></i>
<span>主页</span>
</el-menu-item>
<el-menu-item :index="`/student/exam?userId=${userId}`">
<i class="el-icon-message"></i>
<span>试卷中心</span>
</el-menu-item>
<el-menu-item :index="`/student/scoreList?userId=${userId}`">
<i class="el-icon-s-data"></i>
<span>分数查询</span>
</el-menu-item>
<el-menu-item :index="`/student/scoreList?userId=${userId}`">
<i class="el-icon-edit"></i>
<span>批改中心</span>
</el-menu-item>
</el-menu>
</template>
<script>
export default {
name: "Aside",
data(){
return{
hasStudentMenu: false, // false submenu
userId:"",
}
},
props: {
isCollapse: Boolean,
logoTextShow: Boolean
},
created() {
// userId
this.userId = this.$route.query.userId;
}
}
</script>
<style scoped lang="scss">
</style>

@ -0,0 +1,67 @@
<template>
<div class="header-container">
<div class="left-section">
<span :class="collapseBtnClass" class="collapse-icon" @click="collapse"></span>
</div>
<div class="logout-container">
<span class="logout-btn" @click="logout">退</span>
</div>
</div>
</template>
<script>
export default {
name: "Header",
props: {
collapseBtnClass: String,
collapse: Boolean,
},
methods: {
logout() {
//
this.$store.dispatch("logout"); // Vuex
this.$router.push("/login"); //
},
}
}
</script>
<style scoped lang="scss">
.header-container {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 14px;
line-height: 50px;
padding: 0 20px;
border-bottom: 1px solid #ddd;
}
.left-section {
flex: 1;
}
.collapse-icon {
cursor: pointer;
font-size: 20px;
}
.logout-container {
display: flex;
align-items: center;
}
.logout-btn {
cursor: pointer;
font-size: 16px;
color: #409EFF;
padding: 5px 10px;
border-radius: 4px;
transition: background-color 0.3s ease, color 0.3s ease;
}
.logout-btn:hover {
background-color: #409EFF;
color: #fff;
}
</style>

@ -8,10 +8,23 @@ import store from '../store'; // 引入 Vuex store
Vue.use(VueRouter); Vue.use(VueRouter);
const routes = [ const routes = [
{
path: '/teacher/homePage',
name: 'HomePage',
component: () => import('../views/Teacher/HomePage.vue'),
meta: { requiresAuth: true }
},
{
path: '/teacher/correct',
name: 'Correct',
component: () => import('../views/Teacher/Correct.vue'),
meta: { requiresAuth: true }
},
{ {
path: '/user/profile', path: '/user/profile',
name: 'Profile', name: 'Profile',
component: () => import('../views/user/Profile.vue'), component: () => import('../views/user/Profile.vue'),
meta: { requiresAuth: true },
}, },
{ {
path:'/student/testPaperDetail', path:'/student/testPaperDetail',
@ -34,7 +47,7 @@ const routes = [
{ {
path:'/student/exam', path:'/student/exam',
component: () => import(/* webpackChunkName: "about" */ '../views/Student/Exam.vue'), component: () => import(/* webpackChunkName: "about" */ '../views/Student/Exam.vue'),
meta: {requiresAuth: true} meta: { requiresAuth: true}
}, },
{ {
path: '/login', path: '/login',
@ -59,10 +72,12 @@ const router = new VueRouter({
// 路由守卫 // 路由守卫
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const userId = to.query.userId;
console.log('userId:', to);
// 判断该路由是否需要登录权限 // 判断该路由是否需要登录权限
if (to.matched.some(record => record.meta.requiresAuth)) { if (to.matched.some(record => record.meta.requiresAuth)) {
// 如果未登录,跳转到登录页 // 如果未登录,跳转到登录页
if (!store.state.token) { // 使用 Vuex 中的 token 判断登录状态 if (!store.state.tokens[userId]) { // 使用 Vuex 中的 token 判断登录状态
next({ name: 'Login' }); next({ name: 'Login' });
} else { } else {
next(); // 放行 next(); // 放行

@ -5,31 +5,38 @@ Vue.use(Vuex);
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
token: localStorage.getItem('Authorization') || '', // 初始化 token // 初始化 tokens存储为以 userId 为键的对象
tokens: JSON.parse(localStorage.getItem('tokens')) || {}, // 从 localStorage 获取 tokens
}, },
mutations: { mutations: {
logout(state) { // 设置指定 userId 的 token
state.user = null; // 清空用户信息 setToken(state, { userId, token }) {
state.token = null; Vue.set(state.tokens, userId, token); // 使用 Vue.set 保证响应式更新
localStorage.setItem('tokens', JSON.stringify(state.tokens)); // 更新 localStorage
}, },
setToken(state, token) { // 清除指定 userId 的 token
state.token = token; clearToken(state, userId) {
localStorage.setItem('Authorization', token); Vue.delete(state.tokens, userId); // 删除指定 userId 的 token
localStorage.setItem('tokens', JSON.stringify(state.tokens)); // 更新 localStorage
}, },
clearToken(state) { // 清除所有用户的 token
state.token = ''; logout(state) {
localStorage.removeItem('Authorization'); state.tokens = {}; // 清空所有 tokens
localStorage.removeItem('tokens'); // 清除 localStorage 中的 tokens
}, },
}, },
actions: { actions: {
setToken({ commit }, token) { // 设置指定 userId 的 token
commit('setToken', token); setToken({ commit }, { userId, token }) {
commit('setToken', { userId, token });
}, },
clearToken({ commit }) { // 清除指定 userId 的 token
commit('clearToken'); clearToken({ commit }, userId) {
commit('clearToken', userId);
}, },
// 退出登录,清除所有 token
logout({ commit }) { logout({ commit }) {
commit('logout'); // 提交 mutation 清空所有数据 commit('logout'); // 清空所有 tokens
}, },
}, },
}); });

@ -56,8 +56,8 @@
<script> <script>
import Aside from "@/components/Aside.vue"; import Aside from "@/components/Student/Aside.vue";
import Header from "@/components/Header.vue"; import Header from "@/components/Student/Header.vue";
export default { export default {
name: 'HomeView', name: 'HomeView',

@ -74,8 +74,8 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import { mapActions } from "vuex"; import { mapActions } from "vuex";
import Aside from "@/components/Aside.vue"; import Aside from "@/components/Student/Aside.vue";
import Header from "@/components/Header.vue"; import Header from "@/components/Student/Header.vue";
export default { export default {
name: 'Exam', name: 'Exam',
@ -106,6 +106,7 @@ export default {
}, },
}, },
created() { created() {
this.userId = this.$route.query.userId;
this.fetchPapers(); // this.fetchPapers(); //
}, },
watch: { watch: {
@ -132,7 +133,7 @@ export default {
} }
}, },
startExam(id,name,subject,time) { startExam(id,name,subject,time) {
this.$router.push({ name: "ExamPaper", query: { id:id ,name: name, subject: subject ,time:time} }); this.$router.push({ name: "ExamPaper", query: { userId: this.userId ,id:id ,name: name, subject: subject ,time:time} });
}, },
handleTypeChange(type) { handleTypeChange(type) {
this.selectedType = type; // this.selectedType = type; //
@ -141,14 +142,13 @@ export default {
this.selectedSubject = subject; // this.selectedSubject = subject; //
}, },
async checkExamStatus(testId) { async checkExamStatus(testId) {
const token = this.$store.state.token; const token = this.$store.state.tokens[this.userId];
console.log('token',token);
if (!token) { if (!token) {
alert("用户未登录,请重新登录!"); alert("用户未登录,请重新登录!");
this.$router.push('/login'); this.$router.push('/login');
return false; return false;
} }
try { try {
const response = await axios.get(`http://localhost:8080/student/examPaper/whetherTest`, { const response = await axios.get(`http://localhost:8080/student/examPaper/whetherTest`, {
params: { testId }, params: { testId },
@ -169,8 +169,7 @@ export default {
} }
}, },
async fetchPapers(page = 1, size = 10) { async fetchPapers(page = 1, size = 10) {
const token = this.$store.state.token; // token const token = this.$store.state.tokens[this.userId];
console.log("token:",token);
if (!token) { if (!token) {
alert("用户未登录,请重新登录!"); alert("用户未登录,请重新登录!");
this.$router.push('/login'); // this.$router.push('/login'); //
@ -183,18 +182,22 @@ export default {
const pageNumber = page || 1; // 使 1 const pageNumber = page || 1; // 使 1
const pageSize = size || 10; // 使 10 const pageSize = size || 10; // 使 10
const response = await axios.get("http://localhost:8080/student/examPaper/examPaperByTypeAndSubject", { const response = await axios.get(
params: { `http://localhost:8080/student/examPaper/examPaperByTypeAndSubject`,
pagenum: pageNumber, {
pagesize: pageSize, // pagesize params: {
type: this.selectedType, // pagenum: pageNumber,
subject: this.selectedSubject, // pagesize: pageSize, // pagesize
}, type: this.selectedType, //
headers: { subject: this.selectedSubject, //
Authorization: `Bearer ${token}`, // 使 Vuex token },
'Content-Type': 'application/json', headers: {
}, Authorization: `Bearer ${token}`,
}); 'Content-Type': 'application/json',
},
}
);
console.log("responser",response);
if (response.data.code === 200) { if (response.data.code === 200) {
const { records } = response.data.data; const { records } = response.data.data;
@ -219,7 +222,7 @@ export default {
console.log("更新后的试卷数据:", updatedRecords); console.log("更新后的试卷数据:", updatedRecords);
} else { } else {
alert("数据加载失败:" + response.data.msg); alert("数据加载失败:" + response.data.msg);
this.$router.push('/login'); // // this.$router.push('/login'); //
} }
} catch (error) { } catch (error) {
console.error("获取试卷数据失败:", error); console.error("获取试卷数据失败:", error);
@ -229,7 +232,6 @@ export default {
} }
} }
}, },
}; };
</script> </script>

@ -110,6 +110,7 @@ export default {
examId: null, examId: null,
timer: null, timer: null,
refreshTimer: null, refreshTimer: null,
userId:"",
}; };
}, },
computed: { computed: {
@ -130,7 +131,7 @@ export default {
methods: { methods: {
async fetchQuestions() { async fetchQuestions() {
try { try {
const token = this.$store.state.token; const token = this.$store.state.tokens[this.userId];
if (!token) { if (!token) {
alert("用户未登录,请重新登录!"); alert("用户未登录,请重新登录!");
this.$router.push("/login"); this.$router.push("/login");
@ -217,7 +218,7 @@ export default {
async submitExam() { async submitExam() {
try { try {
const token = this.$store.state.token; const token = this.$store.state.tokens[this.userId];
if (!token) { if (!token) {
alert("用户未登录,请重新登录!"); alert("用户未登录,请重新登录!");
this.$router.push("/login"); this.$router.push("/login");
@ -253,9 +254,24 @@ export default {
{ headers: { Authorization: `Bearer ${token}` } } { headers: { Authorization: `Bearer ${token}` } }
); );
const res = await axios.get(
`http://localhost:8080/student/homepage/task_answerDisplay`,{
params:{id:this.examId},
headers: { Authorization: `Bearer ${token}` }
}
);
if(res.data.code === 200){
console.log('客观题已批改');
}else{
alert("批改系统异常");
}
if (response.data.code === 200) { if (response.data.code === 200) {
alert("考试提交成功!"); alert("考试提交成功!");
this.$router.push("/student/exam"); this.$router.go(-1);
// this.$router.push({
// path: '/student/exam',
// query: { userId: this.userId }
// });
} else { } else {
alert("提交失败:" + response.data.msg); alert("提交失败:" + response.data.msg);
} }
@ -274,6 +290,7 @@ export default {
}, },
}, },
created() { created() {
this.userId = this.$route.query.userId;
this.subject = this.$route.query.subject; this.subject = this.$route.query.subject;
this.name = this.$route.query.name; this.name = this.$route.query.name;
this.examId = this.$route.query.id; this.examId = this.$route.query.id;

@ -58,8 +58,8 @@
</template> </template>
<script> <script>
import Header from "@/components/Header.vue"; import Header from "@/components/Student/Header.vue";
import Aside from "@/components/Aside.vue"; import Aside from "@/components/Student/Aside.vue";
import axios from "axios"; import axios from "axios";
export default { export default {
@ -95,7 +95,8 @@ export default {
async fetchScores() { async fetchScores() {
this.loading = true; this.loading = true;
try { try {
const token = this.$store.state.token; // Vuex token const token = this.$store.state.tokens[this.userId];
console.log('token',token);
if (!token) { if (!token) {
alert("用户未登录,请重新登录!"); alert("用户未登录,请重新登录!");
this.$router.push("/login"); // this.$router.push("/login"); //
@ -139,13 +140,19 @@ export default {
// //
async fetchTestInfo(testid) { async fetchTestInfo(testid) {
try { try {
const token = this.$store.state.tokens[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
this.$router.push("/login"); //
return;
}
// //
const response = await axios.get( const response = await axios.get(
`http://localhost:8080/student/examPaper/examPaperById`, `http://localhost:8080/student/examPaper/examPaperById`,
{ {
params: {id: testid}, params: {id: testid},
headers: { headers: {
Authorization: `Bearer ${this.$store.state.token}`, Authorization: `Bearer ${token}`,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
} }
@ -180,12 +187,13 @@ export default {
// 使 Vue Router // 使 Vue Router
this.$router.push({ this.$router.push({
name: 'TestPaperDetail', name: 'TestPaperDetail',
query: { id: testid ,name: name} // ID query: { userId: this.userId,id: testid ,name: name} // ID
}); });
}, },
}, },
created() { created() {
this.userId = this.$route.query.userId;
this.fetchScores(); // this.fetchScores(); //
}, },
}; };

@ -84,15 +84,13 @@ export default {
methods: { methods: {
async fetchExamData() { async fetchExamData() {
try { try {
const token = this.$store.state.token; const token = this.$store.state.tokens[this.userId];
if (!token) { if (!token) {
alert("用户未登录,请重新登录!"); alert("用户未登录,请重新登录!");
this.$router.push("/login"); this.$router.push("/login");
return; return;
} }
console.log('id', this.id);
const response = await axios.get( const response = await axios.get(
"http://localhost:8080/student/homepage/selectQuestionanswer", "http://localhost:8080/student/homepage/selectQuestionanswer",
{ {
@ -100,7 +98,6 @@ export default {
headers: { Authorization: `Bearer ${token}` }, headers: { Authorization: `Bearer ${token}` },
} }
); );
console.log('response.data', response.data);
const { sender, list, testid } = response.data.data; const { sender, list, testid } = response.data.data;
this.examTitle = this.examname; this.examTitle = this.examname;
this.sender = sender; this.sender = sender;
@ -116,7 +113,7 @@ export default {
}, },
async getTest() { async getTest() {
try { try {
const token = this.$store.state.token; const token = this.$store.state.tokens[this.userId];
if (!token) { if (!token) {
alert("用户未登录,请重新登录!"); alert("用户未登录,请重新登录!");
this.$router.push("/login"); this.$router.push("/login");

@ -0,0 +1,112 @@
<template>
<el-container style="min-height: 100vh">
<!-- 左侧导航 -->
<el-aside :width="sideWidth + 'px'" style="background-color: rgb(238, 241, 246); box-shadow: 2px 0 6px rgb(0 21 41 / 35%)">
<Aside :isCollapse="isCollapse" :logoTextShow="logoTextShow" />
</el-aside>
<!-- 右侧内容 -->
<el-container>
<!-- 顶部导航 -->
<el-header style="border-bottom:1px solid #ccc;">
<Header :collapseBtnClass="collapseBtnClass" :collapse="collapse" />
</el-header>
<!-- 主内容 -->
<el-main>
<el-card>
<el-table :data="examPapers" border stripe style="width: 100%">
<el-table-column prop="id" label="试卷ID" width="120" />
<el-table-column prop="title" label="试卷名称" />
<el-table-column prop="submitter" label="提交人" width="150" />
<el-table-column prop="status" label="批改状态" width="120">
<template #default="{ row }">
<el-tag :type="row.status === '未批改' ? 'info' : 'success'">{{ row.status }}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="180">
<template #default="{ row }">
<el-button size="small" type="primary" @click="viewPaper(row)"></el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 弹窗 -->
<el-dialog v-model="dialogVisible" title="试卷详情" width="60%">
<div v-if="selectedPaper">
<p><strong>试卷名称</strong>{{ selectedPaper.title }}</p>
<p><strong>提交人</strong>{{ selectedPaper.submitter }}</p>
<p><strong>答题内容</strong></p>
<el-input type="textarea" v-model="selectedPaper.answers" rows="10" readonly />
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">关闭</el-button>
<el-button type="success" @click="submitCorrection"></el-button>
</div>
</el-dialog>
</el-main>
</el-container>
</el-container>
</template>
<script>
import Header from "@/components/Teacher/Header.vue";
import Aside from "@/components/Teacher/Aside.vue";
export default {
name: "CorrectPapers",
components: { Aside, Header },
data() {
return {
collapseBtnClass: "el-icon-s-fold",
isCollapse: false,
sideWidth: 200,
logoTextShow: true,
examPapers: [], //
dialogVisible: false, //
selectedPaper: null, //
};
},
methods: {
collapse() {
this.isCollapse = !this.isCollapse;
if (this.isCollapse) {
this.sideWidth = 64;
this.collapseBtnClass = "el-icon-s-unfold";
this.logoTextShow = false;
} else {
this.sideWidth = 200;
this.collapseBtnClass = "el-icon-s-fold";
this.logoTextShow = true;
}
},
fetchExamPapers() {
//
this.examPapers = [
{id: 1, title: "试卷一", submitter: "张三", status: "未批改", answers: "答案内容1"},
{id: 2, title: "试卷二", submitter: "李四", status: "已批改", answers: "答案内容2"},
];
},
viewPaper(paper) {
this.selectedPaper = paper;
this.dialogVisible = true;
},
submitCorrection() {
this.dialogVisible = false;
this.$message.success("批改提交成功!");
//
this.selectedPaper.status = "已批改";
},
},
mounted() {
this.fetchExamPapers();
},
};
</script>
<style scoped>
.el-table {
margin-top: 20px;
}
</style>

@ -0,0 +1,190 @@
<template>
<el-container style="min-height: 100vh">
<!-- 左侧导航 -->
<el-aside :width="sideWidth + 'px'" style="background-color: rgb(238, 241, 246); box-shadow: 2px 0 6px rgb(0 21 41 / 35%)">
<Aside :isCollapse="isCollapse" :logoTextShow="logoTextShow" />
</el-aside>
<!-- 右侧内容 -->
<el-container>
<!-- 顶部导航 -->
<el-header style="border-bottom:1px solid #ccc;">
<Header :collapseBtnClass="collapseBtnClass" :collapse="collapse" />
</el-header>
<!-- 主内容 -->
<el-main>
<div class="dashboard">
<!-- 统计卡片 -->
<el-row :gutter="20">
<el-col :span="6" v-for="(item, index) in summaryData" :key="index">
<el-card class="card-box">
<div slot="header" class="card-header">
<i :class="item.icon" class="card-icon"></i> <!-- 图标 -->
{{ item.title }}
</div>
<div class="card-content">{{ item.value }}</div>
</el-card>
</el-col>
</el-row>
<!-- 图表展示 -->
<el-row :gutter="20" style="margin-top: 20px;">
<el-col :span="12">
<div class="chart-card">
<h3>班级人数分布</h3>
<div ref="genderPieChart" class="chart-container"></div>
</div>
</el-col>
<el-col :span="12">
<div class="chart-card">
<h3>班级试卷分布</h3>
<div ref="songTypeBarChart" class="chart-container"></div>
</div>
</el-col>
</el-row>
</div>
</el-main>
</el-container>
</el-container>
</template>
<script>
import Header from "@/components/Teacher/Header.vue";
import Aside from "@/components/Teacher/Aside.vue";
import axios from 'axios'; // axios
export default {
name: "HomePage",
components: { Aside, Header },
data() {
return {
userId:"",
collapseBtnClass: "el-icon-s-fold",
isCollapse: false,
sideWidth: 200,
logoTextShow: true,
// value
summaryData: [
{ title: "班级总数", icon: "el-icon-user", value: "" }, //
{ title: "班级总人数", icon: "el-icon-s-custom", value: "" },
{ title: "试卷总数", icon: "el-icon-folder-checked", value: "" },
{ title: "题目总数", icon: "el-icon-tickets", value: "" }
]
};
},
mounted() {
// API
this.fetchSummaryData();
//
this.initCharts();
},
created() {
this.userId = this.$route.query.userId;
},
methods: {
collapse() {
this.isCollapse = !this.isCollapse;
if (this.isCollapse) {
this.sideWidth = 64;
this.collapseBtnClass = "el-icon-s-unfold";
this.logoTextShow = false;
} else {
this.sideWidth = 200;
this.collapseBtnClass = "el-icon-s-fold";
this.logoTextShow = true;
}
},
//
async fetchSummaryData() {
try {
const token = this.$store.state.tokens[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
this.$router.push("/login"); //
return;
}
const response = await axios.get('http://localhost:8080/teacher/homepage/homepagesuju',{
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
}
}); // API
// `value`
const data = response.data;
console.log('data',data);
// summaryData value
this.summaryData = this.summaryData.map(item => {
return {...item, value: data[item.title] || "0"}; // title
});
} catch (error) {
console.error('获取数据失败', error);
}
},
initCharts() {
//
// genderPieChart
// new ChartLibrary(this.$refs.genderPieChart, options);
}
}
}
</script>
<style scoped>
.dashboard {
padding: 20px;
}
.card-box {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
display: flex;
flex-direction: column;
align-items: center; /* 垂直居中 */
justify-content: center; /* 水平居中 */
text-align: center; /* 保证文字居中 */
}
.card-header {
font-size: 18px;
font-weight: bold;
color: #409EFF;
display: flex;
align-items: center;
justify-content: center; /* 水平居中 */
}
.card-icon {
margin-right: 10px; /* 图标与文字之间的间距 */
font-size: 24px; /* 图标大小 */
}
.card-content {
font-size: 24px;
margin-top: 10px;
}
/* 卡片悬停效果 */
.card-box:hover {
transform: scale(1.05);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
.chart-card {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.chart-card:hover {
transform: scale(1.05);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
.chart-container {
height: 300px;
}
</style>

@ -1,16 +1,19 @@
<template> <template>
<el-container style="min-height: 100vh"> <el-container style="min-height: 100vh">
<!-- 左侧导航 -->
<el-aside :width="sideWidth+'px'" style="background-color: rgb(238, 241, 246); box-shadow: 2px 0 6px rgb(0 21 41 / 35%)"> <el-aside :width="sideWidth+'px'" style="background-color: rgb(238, 241, 246); box-shadow: 2px 0 6px rgb(0 21 41 / 35%)">
<Aside :isCollapse="isCollapse" :logoTextShow="logoTextShow"/> <Aside :isCollapse="isCollapse" :logoTextShow="logoTextShow"/>
</el-aside> </el-aside>
<el-container> <el-container>
<!-- 顶部导航 -->
<el-header style="border-bottom:1px solid #ccc;"> <el-header style="border-bottom:1px solid #ccc;">
<Header :collapseBtnClass="collapseBtnClass" :collapse="collapse"/> <Header :collapseBtnClass="collapseBtnClass" :collapse="collapse"/>
</el-header> </el-header>
<el-main> <el-main>
<div class="app-container"> <div class="app-container">
<el-row :gutter="20" justify="center"> <el-row :gutter="20" justify="center">
<!-- 左侧个人信息展示 -->
<el-col :span="8" :xs="24"> <el-col :span="8" :xs="24">
<el-card class="profile-card"> <el-card class="profile-card">
<div slot="header" class="clearfix profile-header"> <div slot="header" class="clearfix profile-header">
@ -27,11 +30,11 @@
<ul class="profile-info"> <ul class="profile-info">
<li> <li>
<svg-icon icon-class="user" /> 昵称 <svg-icon icon-class="user" /> 昵称
<div class="info-value">{{ user.name || "暂无数据" }}</div> <div class="info-value">{{ user.nickName || "暂无数据" }}</div>
</li> </li>
<li> <li>
<svg-icon icon-class="user" /> 姓名 <svg-icon icon-class="user" /> 姓名
<div class="info-value">{{ user.tname || "暂无数据" }}</div> <div class="info-value">{{ user.userName || "暂无数据" }}</div>
</li> </li>
<li> <li>
<svg-icon icon-class="id-card" /> 学号 <svg-icon icon-class="id-card" /> 学号
@ -39,7 +42,7 @@
</li> </li>
<li> <li>
<svg-icon icon-class="phone" /> 手机号码 <svg-icon icon-class="phone" /> 手机号码
<div class="info-value">{{ user.telephone || "暂无数据" }}</div> <div class="info-value">{{ user.phonenumber || "暂无数据" }}</div>
</li> </li>
<li> <li>
<svg-icon icon-class="email" /> 邮箱 <svg-icon icon-class="email" /> 邮箱
@ -60,6 +63,66 @@
</ul> </ul>
</el-card> </el-card>
</el-col> </el-col>
<!-- 右侧更新个人信息和修改密码 -->
<el-col :span="8" :xs="24">
<el-card class="profile-card1">
<div slot="header" class="clearfix profile-header">
<span>账户设置</span>
</div>
<!-- 基本资料和修改密码标签 -->
<el-tabs v-model="activeTab" type="card">
<el-tab-pane label="基本资料" name="profile">
<el-form :model="userForm" ref="userForm" label-width="100px">
<el-form-item label="昵称">
<el-input v-model="userForm.nickName" placeholder="请输入昵称"></el-input>
</el-form-item>
<el-form-item label="姓名">
<el-input v-model="userForm.userName" placeholder="请输入姓名"></el-input>
</el-form-item>
<el-form-item label="学号">
<el-input v-model="userForm.studentnumber" placeholder="请输入学号"></el-input>
</el-form-item>
<el-form-item label="手机号码">
<el-input v-model="userForm.phonenumber" placeholder="请输入手机号码"></el-input>
</el-form-item>
<el-form-item label="邮箱">
<el-input v-model="userForm.email" placeholder="请输入邮箱"></el-input>
</el-form-item>
<el-form-item label="年级">
<el-input v-model="userForm.grade" placeholder="请输入年级" :disabled="true"></el-input>
</el-form-item>
<el-form-item label="班级">
<el-input v-model="userForm.class1" placeholder="请输入班级" :disabled="true"></el-input>
</el-form-item>
<el-form-item label="辅导员">
<el-input v-model="userForm.teacherName" placeholder="请输入辅导员" :disabled="true"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="saveUserProfile"></el-button>
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="修改密码" name="password">
<el-form :model="passwordForm" ref="passwordForm" label-width="100px">
<el-form-item label="旧密码">
<el-input type="password" v-model="passwordForm.oldPassword" placeholder="请输入旧密码"></el-input>
</el-form-item>
<el-form-item label="新密码">
<el-input type="password" v-model="passwordForm.newPassword" placeholder="请输入新密码"></el-input>
</el-form-item>
<el-form-item label="确认密码">
<el-input type="password" v-model="passwordForm.confirmPassword" placeholder="确认新密码"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="updatePassword"></el-button>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
</el-card>
</el-col>
</el-row> </el-row>
</div> </div>
</el-main> </el-main>
@ -67,74 +130,158 @@
</el-container> </el-container>
</template> </template>
<script> <script>
import Header from "@/components/Header.vue"; import Header from "@/components/Student/Header.vue";
import Aside from "@/components/Aside.vue"; import Aside from "@/components/Student/Aside.vue";
import axios from "axios"; import axios from "axios";
export default { export default {
name: "Profile", name: "Profile",
components: {Aside, Header}, components: { Aside, Header },
data(){ data() {
return{ return {
collapseBtnClass: 'el-icon-s-fold', collapseBtnClass: 'el-icon-s-fold',
isCollapse: false, isCollapse: false,
sideWidth: 200, sideWidth: 200,
logoTextShow: true, logoTextShow: true,
user: { user: {
name: "", nickName: "",
tname:"", userName: "",
studentnumber: "", studentnumber: "",
telephone: "", phonenumber: "",
email: "", email: "",
Class1: "", class1: "",
grade: "", grade: "",
teacherName: "", teacherName: "",
avatar: "" avatar: ""
}, },
defaultAvatar: "https://via.placeholder.com/150" userForm: {
} nickName: "",
userName: "",
studentnumber: "",
phonenumber: "",
email: "",
class1: "",
grade: "",
teacherName: ""
},
defaultAvatar: "https://via.placeholder.com/150",
passwordForm: {
oldPassword: '',
newPassword: '',
confirmPassword: ''
},
activeTab: 'profile', // ""
};
}, },
methods: { methods: {
collapse(){ collapse() {
// this.isCollapse = !this.isCollapse;
this.isCollapse = !this.isCollapse if (this.isCollapse) {
if(this.isCollapse){ this.sideWidth = 64;
this.sideWidth = 64 this.collapseBtnClass = 'el-icon-s-unfold';
this.collapseBtnClass = 'el-icon-s-unfold' this.logoTextShow = false;
this.logoTextShow = false } else {
}else{ this.sideWidth = 200;
this.sideWidth = 200 this.collapseBtnClass = 'el-icon-s-fold';
this.collapseBtnClass = 'el-icon-s-fold' this.logoTextShow = true;
this.logoTextShow = true
} }
}, },
async fetchUserProfile() { async fetchUserProfile() {
try { try {
const token = this.$store.state.token; const token = this.$store.state.tokens[this.userId];
if (!token) { if (!token) {
alert("用户未登录,请重新登录!"); alert("用户未登录,请重新登录!");
this.$router.push('/login'); this.$router.push('/login');
return false; return false;
} }
const response = await axios.get(`http://localhost:8080/student/homepage/getUserById`, { const response = await axios.get(`http://localhost:8080/student/homepage/getUser`, {
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
}); });
this.user = response.data.data; this.user = response.data.data;
//
this.userForm = { ...this.user };
} catch (error) { } catch (error) {
this.$message.error("获取个人信息失败"); this.$message.error("获取个人信息失败");
console.error(error); console.error(error);
} }
} },
saveUserProfile() {
const token = this.$store.state.token[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
this.$router.push('/login');
return false;
}
//
console.log("保存用户资料:", this.userForm);
axios.put('http://localhost:8080/system/user/profile', this.userForm,{
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
})
.then(response => {
console.log(response.data);
if (response.data.code==200) {
this.$message.success("更新成功");
//
this.user = { ...this.userForm };
} else {
this.$message.error("更新失败");
}
})
.catch(error => {
this.$message.error("请求失败");
console.error(error);
});
},
updatePassword() {
const token = this.$store.state.token[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
this.$router.push('/login');
return false;
}
if (this.passwordForm.newPassword !== this.passwordForm.confirmPassword) {
this.$message.error("新密码和确认密码不一致");
return;
}
//
// console.log(":", this.passwordForm);
axios.put('http://localhost:8080/system/user/profile/updatePwd', this.passwordForm,{
params:{oldPassword:this.passwordForm.oldPassword,
newPassword: this.passwordForm.newPassword,},
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
})
.then(response => {
if (response.data.code==200) {
this.$message.success("密码更新成功,请重新登录");
this.$store.dispatch("logout"); // Vuex
this.$router.push("/login"); //
} else {
this.$message.error("密码更新失败");
}
})
.catch(error => {
this.$message.error("请求失败");
console.error(error);
});
},
}, },
created() { mounted() {
this.fetchUserProfile(); this.fetchUserProfile();
}, },
} created() {
this.userId = this.$route.query.userId;
}
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@ -204,12 +351,51 @@ export default {
border-bottom: none; border-bottom: none;
} }
.profile-info li svg-icon {
margin-right: 10px;
}
.info-value { .info-value {
font-weight: 600; font-weight: 600;
color: #34495e; color: #34495e;
background: #f1f2f6; background: #f1f2f6;
padding: 4px 8px; padding: 4px 8px;
border-radius: 4px; border-radius: 4px;
text-align: right;
width: 50%;
} }
.update-container {
display: flex;
flex-direction: column;
}
.sub-card {
background: #fff;
border: 1px solid #dfe4ea;
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
border-radius: 12px;
margin-bottom: 20px;
}
.sub-card:hover {
transform: translateY(-8px);
box-shadow: 0px 6px 16px rgba(0, 0, 0, 0.15);
}
.profile-card1 {
width: 800px;
height: 622.66px;
background: linear-gradient(135deg, #ffffff, #f6f9fc);
border: 1px solid #dfe4ea;
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
border-radius: 12px;
overflow: hidden;
transition: all 0.3s ease-in-out;
}
.profile-card1:hover {
transform: translateY(-8px);
box-shadow: 0px 6px 16px rgba(0, 0, 0, 0.15);
}
</style> </style>

Loading…
Cancel
Save