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

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(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token);
System.out.println("======="+ajax);
return ajax;
}
@ -88,8 +87,6 @@ public class SysLoginController
Long roleId = roleService.getRoleByUserId(user.getUserId());
roleService.checkRoleDataScope(roleId);
ajax.put("role", roleService.selectRoleById(roleId).getRoleName());
System.out.println("------------------"+ajax);
return ajax;
}

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

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

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

@ -1,158 +1,155 @@
package com.ruoyi.web.controller.test.gl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.test.domain.User;
import com.ruoyi.test.domain.Vo.UserVo;
import com.ruoyi.test.seriver.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Api(tags = "管理端用户管理")
@RestController
@RequestMapping("/gl/users")
public class UserController {
@Autowired
private IUserService iUserService;
/*
*/
@ApiOperation("学生列表")
@GetMapping("student")
public R<IPage<User>> selectList(int pagenum){
return R.ok(iUserService.selectStudentList(pagenum));
}
/*
*@param name
*/
@ApiOperation("学生用户名查询")
@GetMapping("/seleteStudentName")
public R<IPage<User>> selectStudent(int pagenum,String name){
return R.ok(iUserService.selectStudent(pagenum,name));
}
/*
*@param name
*/
@ApiOperation("学生添加用户")
@PostMapping("/insertStudent")
public R<String> inserStudent(@RequestBody UserVo userVo){
User user = new User();
user.setAge(userVo.getAge());
user.setBirthday(userVo.getBirthday());
user.setGrade(userVo.getGrade());
user.setSex(userVo.getSex());
user.setName(userVo.getName());
user.setTname(userVo.getTname());
user.setTelephone(userVo.getTelephone());
user.setRoleKey("2");
user.setState(0L);
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
user.setZhId(zhid);
List<User> list = iUserService.selectStudentByZhid(zhid);
if(list.size()==0){
if(iUserService.insertUser(user)!=0){
return R.ok("添加成功!");
}else{
return R.fail("添加失败!");
}
}
return R.fail("该账号已绑定用户了!");
}
@ApiOperation("教师列表")
@GetMapping("/teacher")
public R<IPage<User>> selectTeacher(int pagenum){
return R.ok(iUserService.selectTeacherList(pagenum));
}
/*
*@param name
*/
@ApiOperation("教师用户名查询")
@GetMapping("/seleteTeacherName")
public R<IPage<User>> selectTeacher(int pagenum,String name){
return R.ok(iUserService.selectTeacher(pagenum,name));
}
/*
*@param name
*/
@ApiOperation("老师添加用户")
@PostMapping("/insertTeacher")
public R<String> insertTeacher(@RequestBody UserVo userVo){
User user = new User();
user.setAge(userVo.getAge());
user.setBirthday(userVo.getBirthday());
user.setGrade(userVo.getGrade());
user.setSex(userVo.getSex());
user.setName(userVo.getName());
user.setTname(userVo.getTname());
user.setTelephone(userVo.getTelephone());
user.setRoleKey("3");
user.setState(0L);
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
user.setZhId(zhid);
List<User> list = iUserService.selectStudentByZhid(zhid);
if(list.size()==0){
if(iUserService.insertUser(user)!=0){
return R.ok("添加成功!");
}else{
return R.fail("添加失败!");
}
}
return R.fail("该账号已绑定用户了!");
}
@ApiOperation("管理员列表")
@GetMapping("/Gl")
public R<IPage<User>> selectGl(int pagenum){
return R.ok(iUserService.selectGlList(pagenum));
}
/*
*@param name
*/
@ApiOperation("管理员用户名查询")
@GetMapping("/seleteGlName")
public R<IPage<User>> selectGl(int pagenum,String name){
return R.ok(iUserService.selectGl(pagenum,name));
}
/*
*@param name
*/
@ApiOperation("管理员添加用户")
@PostMapping("/insertGl")
public R<String> insertGl(@RequestBody UserVo userVo){
User user = new User();
user.setAge(userVo.getAge());
user.setBirthday(userVo.getBirthday());
user.setGrade(userVo.getGrade());
user.setSex(userVo.getSex());
user.setName(userVo.getName());
user.setTname(userVo.getTname());
user.setTelephone(userVo.getTelephone());
user.setRoleKey("4");
user.setState(0L);
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
user.setZhId(zhid);
List<User> list = iUserService.selectStudentByZhid(zhid);
if(list.size()==0){
if(iUserService.insertUser(user)!=0){
return R.ok("添加成功!");
}else{
return R.fail("添加失败!");
}
}
return R.fail("该账号已绑定用户了!");
}
}
//package com.ruoyi.web.controller.test.gl;
//
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.ruoyi.common.core.domain.R;
//import com.ruoyi.common.core.domain.entity.SysUser;
//import com.ruoyi.common.utils.SecurityUtils;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//
//@Api(tags = "管理端用户管理")
//@RestController
//@RequestMapping("/gl/users")
//public class UserController {
// @Autowired
// private IUserService iUserService;
//
// /*
// 获取学生列表
// */
// @ApiOperation("学生列表")
// @GetMapping("student")
// public R<IPage<User>> selectList(int pagenum){
// return R.ok(iUserService.selectStudentList(pagenum));
// }
// /*获取学生用户名查询查询记录
// *@param name 用户名
// */
// @ApiOperation("学生用户名查询")
// @GetMapping("/seleteStudentName")
// public R<IPage<User>> selectStudent(int pagenum,String name){
// return R.ok(iUserService.selectStudent(pagenum,name));
// }
//
// /*增加学生用户信息
// *@param name 用户名
// */
// @ApiOperation("学生添加用户")
// @PostMapping("/insertStudent")
// public R<String> inserStudent(@RequestBody UserVo userVo){
// User user = new User();
// user.setAge(userVo.getAge());
// user.setBirthday(userVo.getBirthday());
// user.setGrade(userVo.getGrade());
// user.setSex(userVo.getSex());
// user.setName(userVo.getName());
// user.setTname(userVo.getTname());
// user.setTelephone(userVo.getTelephone());
// user.setRoleKey("2");
// user.setState(0L);
// SysUser sysUser = SecurityUtils.getLoginUser().getUser();
// Long zhid = sysUser.getUserId();
// user.setZhId(zhid);
// List<User> list = iUserService.selectStudentByZhid(zhid);
// if(list.size()==0){
// if(iUserService.insertUser(user)!=0){
// return R.ok("添加成功!");
// }else{
// return R.fail("添加失败!");
// }
// }
// return R.fail("该账号已绑定用户了!");
// }
//
//
//
// @ApiOperation("教师列表")
// @GetMapping("/teacher")
// public R<IPage<User>> selectTeacher(int pagenum){
// return R.ok(iUserService.selectTeacherList(pagenum));
// }
// /*获取教师用户名查询查询记录
// *@param name 用户名
// */
// @ApiOperation("教师用户名查询")
// @GetMapping("/seleteTeacherName")
// public R<IPage<User>> selectTeacher(int pagenum,String name){
// return R.ok(iUserService.selectTeacher(pagenum,name));
// }
// /*增加教师用户信息
// *@param name 用户名
// */
// @ApiOperation("老师添加用户")
// @PostMapping("/insertTeacher")
// public R<String> insertTeacher(@RequestBody UserVo userVo){
// User user = new User();
// user.setAge(userVo.getAge());
// user.setBirthday(userVo.getBirthday());
// user.setGrade(userVo.getGrade());
// user.setSex(userVo.getSex());
// user.setName(userVo.getName());
// user.setTname(userVo.getTname());
// user.setTelephone(userVo.getTelephone());
// user.setRoleKey("3");
// user.setState(0L);
// SysUser sysUser = SecurityUtils.getLoginUser().getUser();
// Long zhid = sysUser.getUserId();
// user.setZhId(zhid);
// List<User> list = iUserService.selectStudentByZhid(zhid);
// if(list.size()==0){
// if(iUserService.insertUser(user)!=0){
// return R.ok("添加成功!");
// }else{
// return R.fail("添加失败!");
// }
// }
// return R.fail("该账号已绑定用户了!");
// }
//
// @ApiOperation("管理员列表")
// @GetMapping("/Gl")
// public R<IPage<User>> selectGl(int pagenum){
// return R.ok(iUserService.selectGlList(pagenum));
// }
// /*获取管理员用户名查询查询记录
// *@param name 用户名
// */
// @ApiOperation("管理员用户名查询")
// @GetMapping("/seleteGlName")
// public R<IPage<User>> selectGl(int pagenum,String name){
// return R.ok(iUserService.selectGl(pagenum,name));
// }
// /*增加管理员用户信息
// *@param name 用户名
// */
// @ApiOperation("管理员添加用户")
// @PostMapping("/insertGl")
// public R<String> insertGl(@RequestBody UserVo userVo){
// User user = new User();
// user.setAge(userVo.getAge());
// user.setBirthday(userVo.getBirthday());
// user.setGrade(userVo.getGrade());
// user.setSex(userVo.getSex());
// user.setName(userVo.getName());
// user.setTname(userVo.getTname());
// user.setTelephone(userVo.getTelephone());
// user.setRoleKey("4");
// user.setState(0L);
// SysUser sysUser = SecurityUtils.getLoginUser().getUser();
// Long zhid = sysUser.getUserId();
// user.setZhId(zhid);
// List<User> list = iUserService.selectStudentByZhid(zhid);
// if(list.size()==0){
// if(iUserService.insertUser(user)!=0){
// return R.ok("添加成功!");
// }else{
// 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.IMarkedtestService;
import com.ruoyi.test.seriver.IQuestionbankService;
import com.ruoyi.test.seriver.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -24,9 +23,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("student/errorBook")
public class StudentErrorBookController {
@Autowired
private IUserService iUserService;
@Autowired
private IMarkedtestService iMarkedtestService;
@ -41,10 +37,8 @@ public class StudentErrorBookController {
public R<String> addErrorBook(Long qid){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
Questionbank questionbank = iQuestionbankService.selectById(qid);
Errorbook errorbook = new Errorbook();
errorbook.setSender(sender);
errorbook.setContent(questionbank.getContent());
errorbook.setChance(questionbank.getChance());
errorbook.setDifficulty(questionbank.getDifficulty());
@ -64,8 +58,7 @@ public class StudentErrorBookController {
public R<IPage<ErrorbookVo>> selectErrorBook(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
return R.ok(iErrorbookService.selectErrorBook(pagenum,sender));
return R.ok(iErrorbookService.selectErrorBook(pagenum,id));
}
@ApiOperation("查询错题(根据学科)")
@ -73,8 +66,7 @@ public class StudentErrorBookController {
public R<IPage<ErrorbookVo>> selectErrorBookBySubject(int pagenum,String subject){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
return R.ok(iErrorbookService.selectErrorBookBySubject(pagenum,sender,subject));
return R.ok(iErrorbookService.selectErrorBookBySubject(pagenum,id,subject));
}
}

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

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

@ -1,20 +1,22 @@
package com.ruoyi.web.controller.test.student;
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.entity.SysUser;
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.AnswerSheetDO;
import com.ruoyi.test.domain.DO.QuestionAnswerDO;
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.seriver.*;
import com.ruoyi.web.controller.system.SysUserController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -25,9 +27,6 @@ import java.util.List;
@RequestMapping("/student/homepage")
public class StudentHomePageController {
@Autowired
private IUserService iUserService;
@Autowired
private IAnswerService iAnswerService;
@ -43,6 +42,40 @@ public class StudentHomePageController {
@Autowired
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("试卷")
@GetMapping("task_paper")
@ -55,14 +88,12 @@ public class StudentHomePageController {
public R<String> taskAnswer(@RequestBody AnswerDO answerDO){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
List<AnswerVo> answerVos = answerDO.getList();
Gson gson = new Gson();
String answerVo = gson.toJson(answerVos);
Answer answer = new Answer();
answer.setSenderId(id);
answer.setSender(sender);
answer.setTestid(answerDO.getTestid());
answer.setIdanswer(answerVo);
answer.setTime(answerDO.getTime());
@ -78,8 +109,7 @@ public class StudentHomePageController {
public R<List<Markedtest>> taskScore(){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
return R.ok(iMarkedtestService.selectmarkedtestListBySenderAndSenderId(sender,id));
return R.ok(iMarkedtestService.selectmarkedtestListSenderId(id));
}
@ApiOperation("获取某一张的分数")
@ -95,8 +125,7 @@ public class StudentHomePageController {
public R<QuestionAnswerDO> selectQuestionanswer(Long testid) {
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id)).getTname();
return R.ok(iQuestionanswerService.selectQuestionanswer(id,sender,testid));
return R.ok(iQuestionanswerService.selectQuestionanswer(id,testid));
}
//主观题自动更改
@ -105,9 +134,8 @@ public class StudentHomePageController {
public R<String> taskAnswerDisplay(Long id) {
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id1 = sysUser.getUserId();
String sender = iUserService.user(iUserService.selectByzhid(id1)).getTname();
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);
if (iQuestionanswerService.addTest(questionAnswerDO) != 0) {
return R.ok("该学生客观题已改完!");
@ -124,12 +152,4 @@ public class StudentHomePageController {
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.seriver.IClassVedioService;
import com.ruoyi.test.seriver.IStudentClassService;
import com.ruoyi.test.seriver.IUserService;
import com.ruoyi.test.seriver.IVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -26,10 +25,6 @@ import java.util.List;
@RestController
@RequestMapping("/student/video")
public class StudentVideoController {
@Autowired
private IUserService iUserService;
@Autowired
private IStudentClassService iStudentClassService;
@ -44,8 +39,7 @@ public class StudentVideoController {
public R<IPage<Video>> vedioList(int pagenum,int pagesize){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
Long userId = iUserService.user(iUserService.selectByzhid(id)).getUserId();
StudentClass studentClass = iStudentClassService.selectById(userId);
StudentClass studentClass = iStudentClassService.selectById(id);
String grade = studentClass.getGrade();
String Class1 = studentClass.getClass1();
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){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long id = sysUser.getUserId();
Long userId = iUserService.user(iUserService.selectByzhid(id)).getUserId();
StudentClass studentClass = iStudentClassService.selectById(userId);
StudentClass studentClass = iStudentClassService.selectById(id);
String grade = studentClass.getGrade();
String Class1 = studentClass.getClass1();
List<ClassVedio> list= iClassVedioService.selectClassVideo(grade,Class1);

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

@ -22,8 +22,6 @@ import java.util.List;
@RequestMapping("/teacher/answerSheet")
public class TeacherAnswerSheetController {
@Autowired
private IUserService iUserService;
@Autowired
private IAnswerSheetDOService iAnswerSheetDOService;
@ -47,8 +45,8 @@ public class TeacherAnswerSheetController {
@ApiOperation("查看学生的考试情况(最新)")
@GetMapping("selectQuestionanswer")
public R<QuestionAnswerDO> selectQuestionanswer(Long senderId,String sender, Long testid) {
return R.ok(iQuestionanswerService.selectQuestionanswer(senderId,sender,testid));
public R<QuestionAnswerDO> selectQuestionanswer(Long senderId, Long testid) {
return R.ok(iQuestionanswerService.selectQuestionanswer(senderId,testid));
}
@ApiOperation("批改客观题")
@ -63,8 +61,8 @@ public class TeacherAnswerSheetController {
@ApiOperation("试卷批改完毕提交")
@PostMapping("addmarkedtest")
public R<String> addmarkedtest(Long senderId,String sender,Long testid){
if(iMarkedtestService.addmarkedtest(senderId,sender,testid)!=0){
public R<String> addmarkedtest(Long senderId,Long testid){
if(iMarkedtestService.addmarkedtest(senderId,testid)!=0){
return R.ok("提交完成!");
}
return R.fail("提交失败!");
@ -74,8 +72,7 @@ public class TeacherAnswerSheetController {
@GetMapping("selectmarkedtest")
public R<IPage<Markedtest>> selectmarkedtest(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
Long teacherid = sysUser.getUserId();
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){
@ -89,14 +86,12 @@ public class TeacherAnswerSheetController {
@GetMapping("selectmarkedtestBySubject")
public R<IPage<Markedtest>> selectmarkedtestBySubject(int pagenum,String subject){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
Long teacherid = sysUser.getUserId();
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){
list1.addAll(iStudentClassService.selectByGradeAndClass(teacherManageClass.getGrade(),teacherManageClass.getClass1()));
}
System.out.println(11111+" "+list1);
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.IStudentClassService;
import com.ruoyi.test.seriver.ITeacherManageClassService;
import com.ruoyi.test.seriver.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,9 +24,6 @@ import java.util.List;
@RequestMapping("teacher/class")
public class TeacherClassController {
@Autowired
private IUserService iUserService;
@Autowired
private ITeacherManageClassService iTeacherManageClassService;
@ -41,9 +37,8 @@ public class TeacherClassController {
@GetMapping("classList")
public R<IPage<Class1>> classList(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
Long id = sysUser.getUserId();
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id);
List<Class1> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){
String grade = teacherManageClass.getGrade();
@ -85,9 +80,8 @@ public class TeacherClassController {
public R<String> addclass1(String name,String grade,String Class1){
if(iClass1Service.addclass1(name,grade,Class1)!=0){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
iTeacherManageClassService.addclass1(teacherid,grade,Class1);
Long id = sysUser.getUserId();
iTeacherManageClassService.addclass1(id,grade,Class1);
return R.ok("创建成功!");
}
return R.fail("创建失败!");

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

@ -26,9 +26,6 @@ public class TeacherHomePageController {
@Autowired
private ITeacherManageClassService iTeacherManageClassService;
@Autowired
private IUserService iUserService;
@Autowired
private IStudentClassService iStudentClassService;
@ -48,8 +45,7 @@ public class TeacherHomePageController {
@GetMapping("homepagesuju")
public R<HomepageDO> homepagesuju(){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
Long teacherid = sysUser.getUserId();
HomepageDO homepageDO = new HomepageDO();
Integer total = iTeacherManageClassService.totalClass(teacherid).size();
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.StudentClass;
import com.ruoyi.test.domain.TeacherManageClass;
import com.ruoyi.test.domain.User;
import com.ruoyi.test.seriver.IStudentClassService;
import com.ruoyi.test.seriver.IClassExamPaperService;
import com.ruoyi.test.seriver.ITeacherManageClassService;
import com.ruoyi.test.seriver.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -28,9 +26,6 @@ import java.util.List;
@RequestMapping("/teacher/users")
public class TeacherUserController {
@Autowired
private IUserService iUserService;
@Autowired
private ITeacherManageClassService iTeacherManageClassService;
@ -44,9 +39,8 @@ public class TeacherUserController {
@GetMapping("studentList")
public R<IPage<StudentListDO>> studentList(int pagenum){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
Long id = sysUser.getUserId();
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id);
List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){
String grade = teacherManageClass.getGrade();
@ -60,11 +54,12 @@ public class TeacherUserController {
studentListDO.setGrade(studentClass.getGrade());
studentListDO.setClass1(studentClass.getClass1());
studentListDO.setAddtime(studentClass.getAddtime());
User user = iUserService.user(studentClass.getStudentid());
studentListDO.setName(user.getName());
studentListDO.setTname(user.getTname());
studentListDO.setSex(user.getSex());
studentListDO.setTelephone(user.getTelephone());
// User user = iUserService.user(studentClass.getStudentid());
// SysUser sysUser1 =
// studentListDO.setName(user.getName());
// studentListDO.setTname(user.getTname());
// studentListDO.setSex(user.getSex());
// studentListDO.setTelephone(user.getTelephone());
listDOS.add(studentListDO);
}
Page<StudentListDO> page = new Page<>(pagenum,10);
@ -77,9 +72,8 @@ public class TeacherUserController {
@GetMapping("studentListByName")
public R<IPage<StudentListDO>> studentListByName(int pagenum,String name){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
Long id = sysUser.getUserId();
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id);
List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){
String grade = teacherManageClass.getGrade();
@ -88,19 +82,19 @@ public class TeacherUserController {
}
List<StudentListDO> listDOS = new ArrayList<>();
for(StudentClass studentClass : list1){
User user = iUserService.user(studentClass.getStudentid());
if(!user.getName().equals(name)){
continue;
}
// User user = iUserService.user(studentClass.getStudentid());
// if(!user.getName().equals(name)){
// continue;
// }
StudentListDO studentListDO = new StudentListDO();
studentListDO.setId(studentClass.getStudentid());
studentListDO.setGrade(studentClass.getGrade());
studentListDO.setClass1(studentClass.getClass1());
studentListDO.setAddtime(studentClass.getAddtime());
studentListDO.setName(user.getName());
studentListDO.setTname(user.getTname());
studentListDO.setSex(user.getSex());
studentListDO.setTelephone(user.getTelephone());
// studentListDO.setName(user.getName());
// studentListDO.setTname(user.getTname());
// studentListDO.setSex(user.getSex());
// studentListDO.setTelephone(user.getTelephone());
listDOS.add(studentListDO);
}
Page<StudentListDO> page = new Page<>(pagenum,10);
@ -113,9 +107,8 @@ public class TeacherUserController {
@GetMapping("studentListByClass")
public R<IPage<StudentListDO>> studentListByClass(int pagenum,String Class){
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
Long zhid = sysUser.getUserId();
Long teacherid = iUserService.selectByzhid(zhid);
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(teacherid);
Long id = sysUser.getUserId();
List<TeacherManageClass> list = iTeacherManageClassService.totalClass(id);
List<StudentClass> list1 = new ArrayList<>();
for(TeacherManageClass teacherManageClass : list){
String grade = teacherManageClass.getGrade();
@ -126,16 +119,16 @@ public class TeacherUserController {
}
List<StudentListDO> listDOS = new ArrayList<>();
for(StudentClass studentClass : list1){
User user = iUserService.user(studentClass.getStudentid());
// User user = iUserService.user(studentClass.getStudentid());
StudentListDO studentListDO = new StudentListDO();
studentListDO.setId(studentClass.getStudentid());
studentListDO.setGrade(studentClass.getGrade());
studentListDO.setClass1(studentClass.getClass1());
studentListDO.setAddtime(studentClass.getAddtime());
studentListDO.setName(user.getName());
studentListDO.setTname(user.getTname());
studentListDO.setSex(user.getSex());
studentListDO.setTelephone(user.getTelephone());
// studentListDO.setName(user.getName());
// studentListDO.setTname(user.getTname());
// studentListDO.setSex(user.getSex());
// studentListDO.setTelephone(user.getTelephone());
listDOS.add(studentListDO);
}
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)
private Date loginDate;
private String studentnumber;
public String getStudentnumber() {
return studentnumber;
}
public void setStudentnumber(String studentnumber) {
this.studentnumber = studentnumber;
}
/** 部门对象 */
@Excels({
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),

@ -206,7 +206,7 @@ public class SysRoleServiceImpl implements ISysRoleService
List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
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="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="studentnumber" column="studentnumber"/>
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<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,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
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="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="studentnumber != null">studentnumber = #{studentnumber},</if>
update_time = sysdate()
</set>
where user_id = #{userId}

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

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

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

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

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

@ -6,11 +6,12 @@ import lombok.Data;
@TableName("exam_paper")
public class ExamPaper {
private long id;
private Long id;
private String grade;
private String subject;
private String createtime;
private String name;
private String type;
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 {
private Long senderId;
private String sender;
private long testid;
private double score;
private double totalscore;

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

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

@ -8,7 +8,7 @@ import lombok.Data;
@TableName("teacher_manage_class")
public class TeacherManageClass {
private long teacherid;
private Long teacherid;
private String grade;
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
public class ErrorbookVo {
private String sender;
private Long senderId;
private String content;
private List<Map<String,String>> chance;
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> {
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);
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);

@ -8,7 +8,7 @@ public interface IErrorbookService {
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 {
int addmarkedtest(Long senderId,String sender,Long testid);
int addmarkedtest(Long senderId,Long testid);
IPage<Markedtest> selectmarkedtest(int pagenum);
@ -18,11 +18,11 @@ public interface IMarkedtestService {
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);
}

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

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

@ -11,4 +11,6 @@ public interface ITeacherManageClassService {
int deleteClass(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
public Answer selectByTestId(Long senderId,String sender,Long testid) {
public Answer selectByTestId(Long senderId,Long testid) {
LambdaQueryWrapper<Answer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Answer::getTestid,testid);
queryWrapper.eq(Answer::getSender,sender);
queryWrapper.eq(Answer::getSenderId,senderId);
queryWrapper.orderByDesc(Answer::getFinishtime).last("LIMIT 1");
return answerMapper.selectOne(queryWrapper);
}
@Override
public List<Answer> selectBySender(String sender) {
return answerMapper.selectBySender(sender);
public List<Answer> selectBySenderId(Long senderId) {
return answerMapper.selectBySender(senderId);
}
@Override

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

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

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

@ -32,4 +32,12 @@ public class TeacherManageClassServiceImpl extends ServiceImpl<TeacherManageClas
public int addclass1(Long teacherid,String grade, String 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 INTO answer (
sender_id,
sender,
testid,
idanswer,
finishtime,
time
)VALUES(
#{answer.senderId},
#{answer.sender},
#{answer.testid},
#{answer.idanswer},
Now(),
@ -37,7 +35,7 @@
SELECT testid,
MIN(ABS(TIMESTAMPDIFF(SECOND, STR_TO_DATE(finishtime, '%Y-%m-%d %H:%i:%s'), NOW()))) AS min_time_diff
FROM answer
WHERE sender = #{sender}
WHERE senderId = #{senderId}
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
) 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 into questionanswer(
sender,
sender_id,
testid,
qa,
createtime
)values (
#{questionanswer.sender},
#{questionanswer.senderId},
#{questionanswer.testid},
#{questionanswer.qa},
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>
<div class="login-container">
<div class="login-box">
<h2 style="color: white">登录</h2>
<h2 style="color: white;padding-bottom: 10px">登录</h2>
<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 -->
<div class="input-group">
<i class="fas fa-user"></i>
@ -46,7 +37,7 @@ import { mapActions } from "vuex";
export default {
data() {
return {
role: 'student', // Default value, either 'teacher' or 'student'
// role: 'student', // Default value, either 'teacher' or 'student'
username: '',
password: '',
code: '', //
@ -93,20 +84,23 @@ export default {
'Content-Type': 'application/json',
}});
if(res.data.code==200){
console.log('登录成功,用户角色:', res.data);
const token = response.data.token;
this.setToken(token); // Store token using Vuex action
if (res.data.role === '超级管理员') {
//
window.location.href = res.data.role === '老师' ? 'http://localhost:8082' : 'http://localhost:8081/user/profile';
} else if (res.data.role === role) {
//
if (role === '老师') {
window.location.href = 'http://localhost:8082';
} else if (role === '学生') {
window.location.href = 'http://localhost:8081/user/profile';
}
} else {
const userId = res.data.user.userId;
console.log('userId', userId);
this.$store.dispatch('setToken', { userId, token });
if(res.data.roles[0] === 'student'){
// 使 Vue Router
this.$router.push({
path: '/user/profile',
query: { userId: userId }
});
}else if(res.data.roles[0] === 'teacher'){
this.$router.push({
path: '/teacher/correct',
query: { userId: userId }
});
// window.location.href = 'http://localhost:8081/teacher/correct';
}else{
alert('该角色无权限');
this.refreshCaptcha();
}

@ -8,19 +8,22 @@
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">
<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="/user/profile">
<i class="el-icon-house"></i>
<span>主页</span>
<!-- 动态绑定 index使用模板字符串 -->
<el-menu-item :index="`/user/profile?userId=${userId}`">
<i class="el-icon-house"></i>
<span>主页</span>
</el-menu-item>
<el-menu-item index="/student/exam">
<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">
<i class="el-icon-message"></i>
<el-menu-item :index="`/student/scoreList?userId=${userId}`">
<i class="el-icon-s-data"></i>
<span>分数查询</span>
</el-menu-item>
</el-menu>
@ -29,15 +32,20 @@
<script>
export default {
name: "Aside",
data(){
return{
data() {
return {
hasStudentMenu: false, // false submenu
}
userId: '', // userId
};
},
props: {
isCollapse: Boolean,
logoTextShow: Boolean
},
created() {
// userId
this.userId = this.$route.query.userId;
}
}
</script>

@ -32,8 +32,7 @@ export default {
justify-content: space-between;
align-items: center;
font-size: 14px;
line-height: 60px;
background-color: #f5f5f5;
line-height: 50px;
padding: 0 20px;
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);
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',
name: 'Profile',
component: () => import('../views/user/Profile.vue'),
meta: { requiresAuth: true },
},
{
path:'/student/testPaperDetail',
@ -34,7 +47,7 @@ const routes = [
{
path:'/student/exam',
component: () => import(/* webpackChunkName: "about" */ '../views/Student/Exam.vue'),
meta: {requiresAuth: true}
meta: { requiresAuth: true}
},
{
path: '/login',
@ -59,10 +72,12 @@ const router = new VueRouter({
// 路由守卫
router.beforeEach((to, from, next) => {
const userId = to.query.userId;
console.log('userId:', to);
// 判断该路由是否需要登录权限
if (to.matched.some(record => record.meta.requiresAuth)) {
// 如果未登录,跳转到登录页
if (!store.state.token) { // 使用 Vuex 中的 token 判断登录状态
if (!store.state.tokens[userId]) { // 使用 Vuex 中的 token 判断登录状态
next({ name: 'Login' });
} else {
next(); // 放行

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

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

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

@ -110,6 +110,7 @@ export default {
examId: null,
timer: null,
refreshTimer: null,
userId:"",
};
},
computed: {
@ -130,7 +131,7 @@ export default {
methods: {
async fetchQuestions() {
try {
const token = this.$store.state.token;
const token = this.$store.state.tokens[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
this.$router.push("/login");
@ -217,7 +218,7 @@ export default {
async submitExam() {
try {
const token = this.$store.state.token;
const token = this.$store.state.tokens[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
this.$router.push("/login");
@ -253,9 +254,24 @@ export default {
{ 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) {
alert("考试提交成功!");
this.$router.push("/student/exam");
this.$router.go(-1);
// this.$router.push({
// path: '/student/exam',
// query: { userId: this.userId }
// });
} else {
alert("提交失败:" + response.data.msg);
}
@ -274,6 +290,7 @@ export default {
},
},
created() {
this.userId = this.$route.query.userId;
this.subject = this.$route.query.subject;
this.name = this.$route.query.name;
this.examId = this.$route.query.id;

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

@ -84,15 +84,13 @@ export default {
methods: {
async fetchExamData() {
try {
const token = this.$store.state.token;
const token = this.$store.state.tokens[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
this.$router.push("/login");
return;
}
console.log('id', this.id);
const response = await axios.get(
"http://localhost:8080/student/homepage/selectQuestionanswer",
{
@ -100,7 +98,6 @@ export default {
headers: { Authorization: `Bearer ${token}` },
}
);
console.log('response.data', response.data);
const { sender, list, testid } = response.data.data;
this.examTitle = this.examname;
this.sender = sender;
@ -116,7 +113,7 @@ export default {
},
async getTest() {
try {
const token = this.$store.state.token;
const token = this.$store.state.tokens[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
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>
<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="app-container">
<el-row :gutter="20" justify="center">
<!-- 左侧个人信息展示 -->
<el-col :span="8" :xs="24">
<el-card class="profile-card">
<div slot="header" class="clearfix profile-header">
@ -27,11 +30,11 @@
<ul class="profile-info">
<li>
<svg-icon icon-class="user" /> 昵称
<div class="info-value">{{ user.name || "暂无数据" }}</div>
<div class="info-value">{{ user.nickName || "暂无数据" }}</div>
</li>
<li>
<svg-icon icon-class="user" /> 姓名
<div class="info-value">{{ user.tname || "暂无数据" }}</div>
<div class="info-value">{{ user.userName || "暂无数据" }}</div>
</li>
<li>
<svg-icon icon-class="id-card" /> 学号
@ -39,7 +42,7 @@
</li>
<li>
<svg-icon icon-class="phone" /> 手机号码
<div class="info-value">{{ user.telephone || "暂无数据" }}</div>
<div class="info-value">{{ user.phonenumber || "暂无数据" }}</div>
</li>
<li>
<svg-icon icon-class="email" /> 邮箱
@ -60,6 +63,66 @@
</ul>
</el-card>
</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>
</div>
</el-main>
@ -67,74 +130,158 @@
</el-container>
</template>
<script>
import Header from "@/components/Header.vue";
import Aside from "@/components/Aside.vue";
import Header from "@/components/Student/Header.vue";
import Aside from "@/components/Student/Aside.vue";
import axios from "axios";
export default {
name: "Profile",
components: {Aside, Header},
data(){
return{
components: { Aside, Header },
data() {
return {
collapseBtnClass: 'el-icon-s-fold',
isCollapse: false,
sideWidth: 200,
logoTextShow: true,
user: {
name: "",
tname:"",
nickName: "",
userName: "",
studentnumber: "",
telephone: "",
phonenumber: "",
email: "",
Class1: "",
class1: "",
grade: "",
teacherName: "",
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: {
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
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 fetchUserProfile() {
try {
const token = this.$store.state.token;
const token = this.$store.state.tokens[this.userId];
if (!token) {
alert("用户未登录,请重新登录!");
this.$router.push('/login');
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: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
});
this.user = response.data.data;
//
this.userForm = { ...this.user };
} catch (error) {
this.$message.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();
},
}
created() {
this.userId = this.$route.query.userId;
}
};
</script>
<style scoped lang="scss">
@ -204,12 +351,51 @@ export default {
border-bottom: none;
}
.profile-info li svg-icon {
margin-right: 10px;
}
.info-value {
font-weight: 600;
color: #34495e;
background: #f1f2f6;
padding: 4px 8px;
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>

Loading…
Cancel
Save