班级相关
This commit is contained in:
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ClassEntity;
|
||||
import com.peanut.modules.common.entity.ClassModel;
|
||||
import com.peanut.modules.common.entity.ClassTask;
|
||||
import com.peanut.modules.common.entity.ClassTaskAndQuesReply;
|
||||
import com.peanut.modules.common.service.ClassEntityService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -59,8 +61,7 @@ public class ClassController {
|
||||
//获取主任下的班级
|
||||
@RequestMapping("/getClassByDirectorid")
|
||||
public R getClassByDirectorid(@RequestBody Map<String,Object> params){
|
||||
List<ClassEntity> classEntityList = classEntityService.getClassByDirectorid(params);
|
||||
return R.ok().put("classEntityList",classEntityList);
|
||||
return R.ok().put("classEntityList",classEntityService.getClassByDirectorid(params));
|
||||
}
|
||||
|
||||
//获取班级列表
|
||||
@@ -72,12 +73,14 @@ public class ClassController {
|
||||
|
||||
//新增班级
|
||||
@RequestMapping("/addClass")
|
||||
public R addClass(@RequestBody Map<String,Object> params){
|
||||
if (classEntityService.addClass(params)){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("保存出错");
|
||||
}
|
||||
public R addClass(@RequestBody ClassEntity classEntity){
|
||||
return classEntityService.addClass(classEntity);
|
||||
}
|
||||
|
||||
//修改班级状态
|
||||
@RequestMapping("/updateClassState")
|
||||
public R updateClassState(@RequestBody Map<String,Object> params){
|
||||
return classEntityService.updateClassState(params);
|
||||
}
|
||||
|
||||
//修改班级
|
||||
@@ -86,28 +89,32 @@ public class ClassController {
|
||||
if (classEntityService.editClass(params)){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("编辑出错");
|
||||
return R.error("修改出错");
|
||||
}
|
||||
}
|
||||
|
||||
//设置班委
|
||||
@RequestMapping("/setUserRole")
|
||||
public R setUserRole(@RequestBody Map<String,Object> params){
|
||||
if (classEntityService.setUserRole(params)){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("设置出错");
|
||||
}
|
||||
return classEntityService.setUserRole(params);
|
||||
}
|
||||
|
||||
//设删除班级
|
||||
//获取用户在班级中角色
|
||||
@RequestMapping("/getUserRole")
|
||||
public R getUserRole(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getUserRole(params));
|
||||
}
|
||||
|
||||
//获取用户拥有角色类型
|
||||
@RequestMapping("/getRoleType")
|
||||
public R getRoleType(){
|
||||
return R.ok().put("result",classEntityService.getRoleType());
|
||||
}
|
||||
|
||||
//删除班级
|
||||
@RequestMapping("/delClass")
|
||||
public R delClass(@RequestBody Map<String,Object> params){
|
||||
if (classEntityService.removeById((Integer)params.get("classId"))){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("删除出错");
|
||||
}
|
||||
return classEntityService.delClass(params);
|
||||
}
|
||||
|
||||
//获取班级详情
|
||||
@@ -125,11 +132,7 @@ public class ClassController {
|
||||
//加入小班
|
||||
@RequestMapping("/joinClass")
|
||||
public R joinClass(@RequestBody Map<String,Object> params){
|
||||
if (classEntityService.joinClass(params)){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("人员已满");
|
||||
}
|
||||
return classEntityService.joinClass(params);
|
||||
}
|
||||
|
||||
//退出小班
|
||||
@@ -145,4 +148,120 @@ public class ClassController {
|
||||
return R.ok().put("result",classEntityService.MyClassList(params));
|
||||
}
|
||||
|
||||
//新增班级任务医案心得
|
||||
@RequestMapping("/addClassTask")
|
||||
public R addClassTask(@RequestBody ClassTask classTask){
|
||||
classEntityService.addClassTask(classTask);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//获取班级任务列表
|
||||
@RequestMapping("/getClassTaskList")
|
||||
public R getClassTaskList(@RequestBody Map<String,Object> params){
|
||||
Page classTaskList = classEntityService.getClassTaskList(params);
|
||||
return R.ok().put("page",classTaskList);
|
||||
}
|
||||
|
||||
//获取班级任务列表(学员)
|
||||
@RequestMapping("/getClassTaskListStudent")
|
||||
public R getClassTaskListStudent(@RequestBody Map<String,Object> params){
|
||||
Page classTaskList = classEntityService.getClassTaskListStudent(params);
|
||||
return R.ok().put("page",classTaskList);
|
||||
}
|
||||
|
||||
//编辑班级任务医案心得
|
||||
@RequestMapping("/editClassTask")
|
||||
public R editClassTask(@RequestBody ClassTask classTask){
|
||||
classEntityService.editClassTask(classTask);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//获取任务详情
|
||||
@RequestMapping("/getClassTaskInfo")
|
||||
public R getClassTaskInfo(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getClassTaskInfo(params));
|
||||
}
|
||||
|
||||
//获取任务详情学员
|
||||
@RequestMapping("/getClassTaskInfoStudent")
|
||||
public R getClassTaskInfoStudent(@RequestBody Map<String,Object> params){
|
||||
ClassTask classTask = classEntityService.getClassTaskInfoStudent(params);
|
||||
return R.ok().put("classTask",classTask);
|
||||
}
|
||||
|
||||
//新增作业
|
||||
@RequestMapping("/addClassTaskAndQuesReply")
|
||||
public R addClassTaskAndQuesReply(@RequestBody ClassTaskAndQuesReply classTaskAndQuesReply){
|
||||
classEntityService.addClassTaskAndQuesReply(classTaskAndQuesReply);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//通过任务获取作业列表
|
||||
@RequestMapping("/getReplyListByTaskId")
|
||||
public R getReplyListByTaskId(@RequestBody Map<String,Object> params){
|
||||
Page classTaskAndQuesReplyList = classEntityService.getReplyListByTaskId(params);
|
||||
return R.ok().put("page",classTaskAndQuesReplyList);
|
||||
}
|
||||
|
||||
//通过任务获取作业列表(学员)
|
||||
@RequestMapping("/getReplyListByTaskIdStudent")
|
||||
public R getReplyListByTaskIdStudent(@RequestBody Map<String,Object> params){
|
||||
Page classTaskAndQuesReplyList = classEntityService.getReplyListByTaskIdStudent(params);
|
||||
return R.ok().put("page",classTaskAndQuesReplyList);
|
||||
}
|
||||
|
||||
//心得评分
|
||||
@RequestMapping("/editTaskScore")
|
||||
public R editTaskScore(@RequestBody Map<String,Object> params){
|
||||
classEntityService.editTaskScore(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//打分
|
||||
@RequestMapping("/editScore")
|
||||
public R editScore(@RequestBody Map<String,Object> params){
|
||||
classEntityService.editScore(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//生成成绩
|
||||
@RequestMapping("/generateScore")
|
||||
public R generateScore(@RequestBody Map<String,Object> params){
|
||||
classEntityService.generateScore(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//编辑作业
|
||||
@RequestMapping("/editClassTaskAndQuesReply")
|
||||
public R editClassTaskAndQuesReply(@RequestBody ClassTaskAndQuesReply classTaskAndQuesReply){
|
||||
classEntityService.editClassTaskAndQuesReply(classTaskAndQuesReply);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
//作业详情
|
||||
@RequestMapping("/getClassTaskAndQuesReplyInfo")
|
||||
public R getClassTaskAndQuesReplyInfo(@RequestBody Map<String,Object> params){
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classEntityService.getClassTaskAndQuesReplyInfo(params);
|
||||
return R.ok().put("classTaskAndQuesReply", classTaskAndQuesReply);
|
||||
}
|
||||
|
||||
//课后题详情
|
||||
@RequestMapping("/getQuesReplyInfo")
|
||||
public R getQuesReplyInfo(@RequestBody Map<String,Object> params){
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classEntityService.getQuesReplyInfo(params);
|
||||
return R.ok().put("classTaskAndQuesReply", classTaskAndQuesReply);
|
||||
}
|
||||
|
||||
//思考题列表
|
||||
@RequestMapping("/getThinkQuestionList")
|
||||
public R getThinkQuestionList(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("thinkQuestionList",classEntityService.getThinkQuestionList(params));
|
||||
}
|
||||
|
||||
//学员成绩
|
||||
@RequestMapping("/getUserScore")
|
||||
public R getUserScore(@RequestBody Map<String,Object> params){
|
||||
return R.ok().put("result",classEntityService.getUserScore(params));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.ClassExamOption;
|
||||
import com.peanut.modules.common.entity.ClassExamSubject;
|
||||
import com.peanut.modules.common.service.ClassExamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonClassExam")
|
||||
@RequestMapping("common/classExam")
|
||||
public class ClassExamController {
|
||||
|
||||
@Autowired
|
||||
private ClassExamService classExamService;
|
||||
|
||||
//导入考试题
|
||||
@RequestMapping("/importSubject")
|
||||
public R importSubject(@RequestParam("file") MultipartFile file, @RequestParam("courseId") String courseId) {
|
||||
String res = classExamService.importSubject(file,courseId);
|
||||
if (res==null){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error(res);
|
||||
}
|
||||
}
|
||||
|
||||
//考试题目列表
|
||||
@RequestMapping("/getClassExamSubjectList")
|
||||
public R getClassExamSubjectList(@RequestBody Map<String,Object> params){
|
||||
Page classExamSubjectList = classExamService.getClassExamSubjectList(params);
|
||||
return R.ok().put("page",classExamSubjectList);
|
||||
}
|
||||
|
||||
//考试题目列表
|
||||
@RequestMapping("/generateExamPaper")
|
||||
public R generateExamPaper(@RequestBody Map<String,Object> params){
|
||||
Object examPaper = classExamService.generateExamPaper(params);
|
||||
return R.ok().put("examPaper",examPaper);
|
||||
}
|
||||
|
||||
//提交考卷
|
||||
@RequestMapping("/submitExamPaper")
|
||||
public R submitExamPaper(@RequestBody Map<String,Object> params){
|
||||
Object examPaper = classExamService.submitExamPaper(params);
|
||||
return R.ok().put("examPaper",examPaper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//添加题目
|
||||
@RequestMapping("/addClassExamSubject")
|
||||
public R addClassExamSubject(@RequestBody ClassExamSubject classExamSubject){
|
||||
if (classExamService.addClassExamSubject(classExamSubject)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
}
|
||||
|
||||
//添加选项
|
||||
@RequestMapping("/addClassExamOption")
|
||||
public R addClassExamOption(@RequestBody ClassExamOption classExamOption){
|
||||
if (classExamService.addClassExamOption(classExamOption)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
}
|
||||
|
||||
//修改题目
|
||||
@RequestMapping("/updateClassExamSubject")
|
||||
public R updateClassExamSubject(@RequestBody ClassExamSubject classExamSubject){
|
||||
if (classExamService.updateClassExamSubject(classExamSubject)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
}
|
||||
|
||||
//修改选项
|
||||
@RequestMapping("/updateClassExamOption")
|
||||
public R updateClassExamOption(@RequestBody ClassExamOption classExamOption){
|
||||
if (classExamService.updateClassExamOption(classExamOption)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
}
|
||||
|
||||
//删除题目
|
||||
@RequestMapping("/delClassExamSubject")
|
||||
public R delClassExamSubject(@RequestBody Map<String,Object> params){
|
||||
if (classExamService.delClassExamSubject(params)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
}
|
||||
|
||||
//删除选项
|
||||
@RequestMapping("/delClassExamOption")
|
||||
public R delClassExamOption(@RequestBody Map<String,Object> params){
|
||||
if (classExamService.delClassExamOption(params)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,8 +42,6 @@ public class UserController {
|
||||
private SysUserTokenService sysUserTokenService;
|
||||
@Autowired
|
||||
private UserVipService userVipService;
|
||||
@Autowired
|
||||
private ClassEntityService classEntityService;
|
||||
|
||||
/**
|
||||
* 常规注册 发短信验证码
|
||||
@@ -121,10 +119,7 @@ public class UserController {
|
||||
userEntity.setUserVip(userVips.get(0));
|
||||
}
|
||||
}
|
||||
//查询用户是否有小班角色
|
||||
boolean isDirector = classEntityService.isDirector(userEntity);
|
||||
boolean isMonitor = classEntityService.isMonitor(userEntity);
|
||||
return R.ok().put("result",userEntity).put("isDirector",isDirector).put("isMonitor",isMonitor);
|
||||
return R.ok().put("result",userEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,9 @@ public class ClassEntity {
|
||||
|
||||
private String icon;
|
||||
|
||||
//群二维码
|
||||
private String qrcode;
|
||||
|
||||
private String content;
|
||||
|
||||
private Integer number; //成员数量
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("class_exam")
|
||||
public class ClassExam {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer classId;
|
||||
|
||||
private String title;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("class_exam_option")
|
||||
public class ClassExamOption {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer subjectId;
|
||||
|
||||
private Integer rightWrong;
|
||||
|
||||
private String content;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("class_exam_subject")
|
||||
public class ClassExamSubject {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer courseId;
|
||||
|
||||
private Integer type;//类型 0单选题1多选题
|
||||
|
||||
private String content;
|
||||
|
||||
private String chapter; //所属章节
|
||||
|
||||
private String media;//音视频序号
|
||||
|
||||
private String mediaTime;//音视频时间
|
||||
|
||||
private String createUser;//出题人
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<ClassExamOption> options;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("class_exam_user")
|
||||
public class ClassExamUser {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer examId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private Integer score;//分数
|
||||
|
||||
private String scoreSuccess;//是否完成
|
||||
|
||||
private String subject;
|
||||
|
||||
private String answer;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -23,6 +23,8 @@ public class ClassModel {
|
||||
|
||||
private String type;//班类型 0小班 1联合班 2精英班
|
||||
|
||||
private Integer days;//教学天数
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("class_task")
|
||||
public class ClassTask {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer classId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private String type;//类型 0班内任务1医案2心得
|
||||
|
||||
private String display;//是否展示 0否1是
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
|
||||
private String img;
|
||||
|
||||
private String scoreSuccess;//是否已评分 0否1是
|
||||
|
||||
private double score;//分数
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Object createUser;
|
||||
@TableField(exist = false)
|
||||
private boolean isReply;
|
||||
@TableField(exist = false)
|
||||
private Object otherInfo;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("class_taskandques_reply")
|
||||
public class ClassTaskAndQuesReply {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer relationId;
|
||||
|
||||
private String type;//类型0任务1课后题
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private String display;//是否展示 0否1是
|
||||
|
||||
private String content;
|
||||
|
||||
private String img;
|
||||
|
||||
private String scoreInfo;//打分情况
|
||||
|
||||
private String scoreSuccess;//是否已评分 0否1是
|
||||
|
||||
private double score;//分数
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Object createUser;
|
||||
}
|
||||
@@ -24,4 +24,10 @@ public class ClassUser {
|
||||
|
||||
@TableField(exist = false)
|
||||
private MyUserEntity user;
|
||||
@TableField(exist = false)
|
||||
private boolean isReply;
|
||||
@TableField(exist = false)
|
||||
private boolean isReplySuccess;
|
||||
@TableField(exist = false)
|
||||
private double score;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public class CourseCatalogueChapterEntity {
|
||||
|
||||
private String content;
|
||||
|
||||
private String questions;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ClassEntity;
|
||||
import com.peanut.modules.common.entity.ClassModel;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -18,28 +18,66 @@ public interface ClassEntityService extends IService<ClassEntity> {
|
||||
|
||||
List<ClassModel> getClassModelByUserid(Map<String ,Object> params);
|
||||
|
||||
List<ClassEntity> getClassByDirectorid(Map<String,Object> params);
|
||||
List<Map<String, Object>> getClassByDirectorid(Map<String,Object> params);
|
||||
|
||||
Page getClassList(Map<String ,Object> params);
|
||||
|
||||
boolean addClass(Map<String ,Object> params);
|
||||
R addClass(ClassEntity classEntity);
|
||||
|
||||
R updateClassState(Map<String,Object> params);
|
||||
|
||||
boolean editClass(Map<String ,Object> params);
|
||||
|
||||
boolean setUserRole(Map<String ,Object> params);
|
||||
R setUserRole(Map<String ,Object> params);
|
||||
|
||||
boolean isDirector(MyUserEntity userEntity);
|
||||
List<String> getUserRole(Map<String, Object> params);
|
||||
|
||||
boolean isMonitor(MyUserEntity userEntity);
|
||||
Map<String,Object> getRoleType();
|
||||
|
||||
R delClass(Map<String,Object> params);
|
||||
|
||||
Object getClassInfo(Map<String ,Object> params);
|
||||
|
||||
List<ClassEntity> getClassByCourseIdNoUser(Map<String ,Object> params);
|
||||
|
||||
boolean joinClass(Map<String ,Object> params);
|
||||
R joinClass(Map<String ,Object> params);
|
||||
|
||||
void quitClass(Map<String ,Object> params);
|
||||
|
||||
List<ClassEntity> MyClassList(Map<String ,Object> params);
|
||||
List<Map<String,Object>> MyClassList(Map<String ,Object> params);
|
||||
|
||||
void addClassTask(ClassTask classTask);
|
||||
|
||||
Page getClassTaskList(Map<String ,Object> params);
|
||||
|
||||
Page getClassTaskListStudent(Map<String ,Object> params);
|
||||
|
||||
void editClassTask(ClassTask classTask);
|
||||
|
||||
Map<String,Object> getClassTaskInfo(Map<String ,Object> params);
|
||||
|
||||
ClassTask getClassTaskInfoStudent(Map<String ,Object> params);
|
||||
|
||||
void addClassTaskAndQuesReply(ClassTaskAndQuesReply classTaskAndQuesReply);
|
||||
|
||||
Page getReplyListByTaskId(Map<String ,Object> params);
|
||||
|
||||
Page getReplyListByTaskIdStudent(Map<String ,Object> params);
|
||||
|
||||
void editTaskScore(Map<String,Object> params);
|
||||
|
||||
void editScore(Map<String,Object> params);
|
||||
|
||||
void generateScore(Map<String,Object> params);
|
||||
|
||||
void editClassTaskAndQuesReply(ClassTaskAndQuesReply classTaskAndQuesReply);
|
||||
|
||||
ClassTaskAndQuesReply getClassTaskAndQuesReplyInfo(Map<String ,Object> params);
|
||||
|
||||
ClassTaskAndQuesReply getQuesReplyInfo(Map<String ,Object> params);
|
||||
|
||||
List getThinkQuestionList(Map<String,Object> params);
|
||||
|
||||
Map<String,Object> getUserScore(Map<String,Object> params);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.peanut.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.ClassExam;
|
||||
import com.peanut.modules.common.entity.ClassExamOption;
|
||||
import com.peanut.modules.common.entity.ClassExamSubject;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ClassExamService extends IService<ClassExam> {
|
||||
|
||||
String importSubject(MultipartFile file, String courseId);
|
||||
|
||||
int addClassExamSubject(ClassExamSubject classExamSubject);
|
||||
|
||||
int addClassExamOption(ClassExamOption classExamOption);
|
||||
|
||||
int updateClassExamSubject(ClassExamSubject classExamSubject);
|
||||
|
||||
int updateClassExamOption(ClassExamOption classExamOption);
|
||||
|
||||
int delClassExamSubject(Map<String,Object> params);
|
||||
|
||||
int delClassExamOption(Map<String,Object> params);
|
||||
|
||||
Page getClassExamSubjectList(Map<String,Object> params);
|
||||
|
||||
Object generateExamPaper(Map<String,Object> params);
|
||||
|
||||
Object submitExamPaper(Map<String,Object> params);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.dao.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
@@ -15,13 +19,12 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterClassEntityService")
|
||||
@Service("commonClassEntityService")
|
||||
public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEntity> implements ClassEntityService {
|
||||
|
||||
@Autowired
|
||||
@@ -31,9 +34,19 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
@Autowired
|
||||
private ClassUserDao classUserDao;
|
||||
@Autowired
|
||||
private ClassTaskDao classTaskDao;
|
||||
@Autowired
|
||||
private ClassTaskAndQuesReplyDao classTaskAndQuesReplyDao;
|
||||
@Autowired
|
||||
private MyUserDao myUserDao;
|
||||
@Autowired
|
||||
private SysUserDao sysUserDao;
|
||||
@Autowired
|
||||
private UserCourseBuyDao userCourseBuyDao;
|
||||
@Autowired
|
||||
private CourseDao courseDao;
|
||||
@Autowired
|
||||
private CourseCatalogueChapterDao courseCatalogueChapterDao;
|
||||
|
||||
@Override
|
||||
public Page getClassModelList(Map<String, Object> params) {
|
||||
@@ -98,7 +111,9 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
LambdaQueryWrapper<ClassModel> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.and(t->t.eq(ClassModel::getDirectorId,params.get("userId"))
|
||||
.or().eq(ClassModel::getDdirectorId,params.get("userId")));
|
||||
wrapper.eq(ClassModel::getType,params.get("type"));
|
||||
if (StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.eq(ClassModel::getType,params.get("type"));
|
||||
}
|
||||
List<ClassModel> classModelList = classModelDao.selectList(wrapper);
|
||||
if (classModelList.size() > 0){
|
||||
for (ClassModel classModel : classModelList) {
|
||||
@@ -110,15 +125,19 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClassEntity> getClassByDirectorid(Map<String, Object> params) {
|
||||
public List<Map<String, Object>> getClassByDirectorid(Map<String, Object> params) {
|
||||
MPJLambdaWrapper<ClassEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(ClassEntity.class);
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassEntity::getModelId);
|
||||
wrapper.and(t->t.eq(ClassModel::getDirectorId,ShiroUtils.getUId())
|
||||
.or().eq(ClassModel::getDdirectorId,ShiroUtils.getUId()));
|
||||
wrapper.eq(ClassModel::getType,params.get("type"));
|
||||
wrapper.eq(ClassModel::getId,params.get("modelId"));
|
||||
if (StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.eq(ClassModel::getType,params.get("type"));
|
||||
}
|
||||
wrapper.eq(ClassEntity::getState,params.get("state"));
|
||||
return this.getBaseMapper().selectList(wrapper);
|
||||
wrapper.select(ClassEntity::getId,ClassEntity::getTitle,ClassEntity::getNumber,ClassEntity::getIcon);
|
||||
wrapper.select(ClassModel::getType);
|
||||
wrapper.selectAs(ClassModel::getDirectorId,"directorId");
|
||||
wrapper.selectAs(ClassModel::getDdirectorId,"ddirectorId");
|
||||
return this.getBaseMapper().selectMaps(wrapper);
|
||||
}
|
||||
|
||||
//设置主任和课程
|
||||
@@ -171,20 +190,67 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addClass(Map<String, Object> params) {
|
||||
ClassEntity c = new ClassEntity();
|
||||
c.setModelId((Integer)params.get("modelId"));
|
||||
c.setTitle(params.get("title").toString());
|
||||
c.setIcon(params.get("icon").toString());
|
||||
c.setContent(params.get("content").toString());
|
||||
c.setNumber((Integer)params.get("number"));
|
||||
try {
|
||||
c.setCreateUserid(ShiroUtils.getUId());
|
||||
}catch (Exception e) {
|
||||
c.setCreateUserid(ShiroUtils.getUserId().intValue());
|
||||
public R addClass(ClassEntity classEntity) {
|
||||
ClassEntity existClass = this.getBaseMapper().selectOne(
|
||||
new LambdaQueryWrapper<ClassEntity>()
|
||||
.eq(ClassEntity::getModelId,classEntity.getModelId())
|
||||
.eq(ClassEntity::getState,"0"));
|
||||
if (existClass==null){
|
||||
try {
|
||||
classEntity.setCreateUserid(ShiroUtils.getUId());
|
||||
}catch (Exception e) {
|
||||
classEntity.setCreateUserid(ShiroUtils.getUserId().intValue());
|
||||
}
|
||||
this.getBaseMapper().insert(classEntity);
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("已存在待开状态班级");
|
||||
}
|
||||
this.getBaseMapper().insert(c);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R updateClassState(Map<String, Object> params) {
|
||||
String state = params.get("state").toString();
|
||||
ClassEntity classEntity = this.getBaseMapper().selectById(params.get("classId").toString());
|
||||
if ("1".equals(state)){
|
||||
//开班校验
|
||||
int monitorCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"1"));
|
||||
if (monitorCount<1){
|
||||
return R.error("请先设置班长");
|
||||
}
|
||||
int dmonitorCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"2"));
|
||||
if (dmonitorCount<1){
|
||||
return R.error("请先设置副班长");
|
||||
}
|
||||
int studyCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"3"));
|
||||
if (studyCount<1){
|
||||
return R.error("请先设置学习委员");
|
||||
}
|
||||
int commentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"4"));
|
||||
if (commentCount<3){
|
||||
return R.error("请先设置3位评分员");
|
||||
}
|
||||
int taskCount = classTaskDao.selectCount(new LambdaQueryWrapper<ClassTask>()
|
||||
.eq(ClassTask::getClassId,classEntity.getId()).eq(ClassTask::getType,"0"));
|
||||
ClassModel classModel = classModelDao.selectById(classEntity.getModelId());
|
||||
if (taskCount<(classModel.getDays()/7)){
|
||||
return R.error("请至少发布"+Math.ceil(classModel.getDays()/7)+"个任务。");
|
||||
}
|
||||
int studentCount = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId()).eq(ClassUser::getRole,"0"));
|
||||
if (studentCount<classEntity.getNumber()){
|
||||
return R.error("学生人数未满");
|
||||
}
|
||||
classEntity.setState("1");
|
||||
}else {
|
||||
classEntity.setState("2");
|
||||
}
|
||||
this.getBaseMapper().updateById(classEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,8 +258,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
ClassEntity c = new ClassEntity();
|
||||
c.setId((Integer)params.get("id"));
|
||||
c.setTitle(params.get("title").toString());
|
||||
c.setState(params.get("state").toString());
|
||||
c.setIcon(params.get("icon").toString());
|
||||
c.setQrcode(params.get("qrcode").toString());
|
||||
c.setContent(params.get("content").toString());
|
||||
c.setNumber((Integer)params.get("number"));
|
||||
this.getBaseMapper().updateById(c);
|
||||
@@ -201,34 +267,63 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setUserRole(Map<String, Object> params) {
|
||||
LambdaQueryWrapper<ClassUser> userWrap = new LambdaQueryWrapper<>();
|
||||
userWrap.eq(ClassUser::getClassId,params.get("classId"));
|
||||
userWrap.in(ClassUser::getRole,"1","2","3","4","5");
|
||||
classUserDao.delete(userWrap);
|
||||
public R setUserRole(Map<String, Object> params) {
|
||||
int classId = Integer.parseInt(params.get("classId").toString());
|
||||
if (StringUtils.isNotEmpty(params.get("monitor").toString())){
|
||||
addClassUser(classId,Integer.parseInt(params.get("monitor").toString()),"1");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("dmonitor").toString())){
|
||||
addClassUser(classId,Integer.parseInt(params.get("dmonitor").toString()),"2");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("learner").toString())){
|
||||
addClassUser(classId,Integer.parseInt(params.get("learner").toString()),"3");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("scorer").toString())){
|
||||
String[] scorers = params.get("scorer").toString().split(",");
|
||||
for (String scorer : scorers) {
|
||||
addClassUser(classId,Integer.parseInt(scorer),"4");
|
||||
String monitor = params.get("monitor").toString();
|
||||
String dmonitor = params.get("dmonitor").toString();
|
||||
String learner = params.get("learner").toString();
|
||||
String scorer = params.get("scorer").toString();
|
||||
String counter = params.get("counter").toString();
|
||||
Set<String> list = new HashSet<>();
|
||||
boolean flag = false;
|
||||
list.add(monitor);
|
||||
if (StringUtils.isNotEmpty(dmonitor)){
|
||||
if (!list.add(dmonitor)){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("counter").toString())){
|
||||
String[] scorers = params.get("counter").toString().split(",");
|
||||
for (String scorer : scorers) {
|
||||
addClassUser(classId,Integer.parseInt(scorer),"5");
|
||||
if (StringUtils.isNotEmpty(learner)){
|
||||
if (!list.add(learner)){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (StringUtils.isNotEmpty(scorer)){
|
||||
if (!list.addAll(Arrays.asList(scorer.split(",")))){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(counter)){
|
||||
if (!list.addAll(Arrays.asList(counter.split(",")))){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (flag){
|
||||
return R.error("同一人不能拥有多职务");
|
||||
}
|
||||
classUserDao.delete(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classId).in(ClassUser::getRole,"1","2","3","4","5"));
|
||||
if (StringUtils.isNotEmpty(monitor)){
|
||||
addClassUser(classId,Integer.parseInt(monitor),"1");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dmonitor)){
|
||||
addClassUser(classId,Integer.parseInt(dmonitor),"2");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(learner)){
|
||||
addClassUser(classId,Integer.parseInt(learner),"3");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(scorer)){
|
||||
String[] scorers = scorer.split(",");
|
||||
for (String s : scorers) {
|
||||
addClassUser(classId,Integer.parseInt(s),"4");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(counter)){
|
||||
String[] scorers = counter.split(",");
|
||||
for (String s : scorers) {
|
||||
addClassUser(classId,Integer.parseInt(s),"5");
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
public int addClassUser(int classId,int userId,String role) {
|
||||
@@ -239,28 +334,94 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
return classUserDao.insert(classUser);
|
||||
}
|
||||
|
||||
//是否主任
|
||||
@Override
|
||||
public boolean isDirector(MyUserEntity userEntity) {
|
||||
LambdaQueryWrapper<ClassModel> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.and(t->t.eq(ClassModel::getDirectorId,userEntity.getId())
|
||||
.or().eq(ClassModel::getDdirectorId,userEntity.getId()));
|
||||
return classModelDao.selectCount(wrapper)>0;
|
||||
public List<String> getUserRole(Map<String, Object> params) {
|
||||
List<String> list = new ArrayList<>();
|
||||
LambdaQueryWrapper<ClassUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClassUser::getClassId,params.get("classId"));
|
||||
wrapper.eq(ClassUser::getUserId,ShiroUtils.getUId());
|
||||
List<ClassUser> users = classUserDao.selectList(wrapper);
|
||||
if (users.size()>0){
|
||||
for (ClassUser u:users) {
|
||||
list.add(u.getRole());
|
||||
}
|
||||
}
|
||||
ClassEntity classEntity = this.getBaseMapper().selectById(params.get("classId").toString());
|
||||
ClassModel model = classModelDao.selectById(classEntity.getModelId());
|
||||
if (ShiroUtils.getUId().toString().equals(model.getDirectorId().toString())){
|
||||
list.add("主任");
|
||||
}
|
||||
if (ShiroUtils.getUId().toString().equals(model.getDdirectorId().toString())){
|
||||
list.add("副主任");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
//是否班干部
|
||||
@Override
|
||||
public boolean isMonitor(MyUserEntity userEntity) {
|
||||
LambdaQueryWrapper<ClassUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
wrapper.in(ClassUser::getRole,"1","2","3","4","5");
|
||||
return classUserDao.selectCount(wrapper)>0;
|
||||
public Map<String, Object> getRoleType() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
MyUserEntity userEntity = ShiroUtils.getUser();
|
||||
//是否主任
|
||||
LambdaQueryWrapper<ClassModel> directorWrapper = new LambdaQueryWrapper<>();
|
||||
directorWrapper.and(t->t.eq(ClassModel::getDirectorId,userEntity.getId())
|
||||
.or().eq(ClassModel::getDdirectorId,userEntity.getId()));
|
||||
result.put("isDirector",classModelDao.selectCount(directorWrapper)>0);
|
||||
//是否班委
|
||||
LambdaQueryWrapper<ClassUser> committeeWrapper = new LambdaQueryWrapper<>();
|
||||
committeeWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
committeeWrapper.in(ClassUser::getRole,"1","2","3","4","5");
|
||||
result.put("isCommittee",classUserDao.selectCount(committeeWrapper)>0);
|
||||
//是否班长
|
||||
LambdaQueryWrapper<ClassUser> monitorWrapper = new LambdaQueryWrapper<>();
|
||||
monitorWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
monitorWrapper.in(ClassUser::getRole,"1");
|
||||
result.put("isMonitor",classUserDao.selectCount(monitorWrapper)>0);
|
||||
//是否班长
|
||||
LambdaQueryWrapper<ClassUser> dmonitorWrapper = new LambdaQueryWrapper<>();
|
||||
dmonitorWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
dmonitorWrapper.in(ClassUser::getRole,"2");
|
||||
result.put("isdMonitor",classUserDao.selectCount(dmonitorWrapper)>0);
|
||||
//是否学习委员
|
||||
LambdaQueryWrapper<ClassUser> learnWrapper = new LambdaQueryWrapper<>();
|
||||
learnWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
learnWrapper.in(ClassUser::getRole,"3");
|
||||
result.put("isLearn",classUserDao.selectCount(learnWrapper)>0);
|
||||
//是否计、评分员
|
||||
LambdaQueryWrapper<ClassUser> countWrapper = new LambdaQueryWrapper<>();
|
||||
countWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
countWrapper.in(ClassUser::getRole,"4");
|
||||
result.put("isCount",classUserDao.selectCount(countWrapper)>0);
|
||||
LambdaQueryWrapper<ClassUser> commentWrapper = new LambdaQueryWrapper<>();
|
||||
commentWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
commentWrapper.in(ClassUser::getRole,"5");
|
||||
result.put("isComment",classUserDao.selectCount(commentWrapper)>0);
|
||||
//是学员
|
||||
LambdaQueryWrapper<ClassUser> studentWrapper = new LambdaQueryWrapper<>();
|
||||
studentWrapper.eq(ClassUser::getUserId,userEntity.getId());
|
||||
studentWrapper.in(ClassUser::getRole,"0");
|
||||
result.put("isStudent",classUserDao.selectCount(studentWrapper)>0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R delClass(Map<String, Object> params) {
|
||||
ClassEntity classEntity = this.getBaseMapper().selectById(params.get("classId").toString());
|
||||
int count = classUserDao.selectCount(
|
||||
new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId())
|
||||
.eq(ClassUser::getRole,0));
|
||||
if (count > 0){
|
||||
return R.error("还有学员存在,删除失败。");
|
||||
}else {
|
||||
this.getBaseMapper().deleteById(classEntity.getId());
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClassInfo(Map<String, Object> params) {
|
||||
ClassEntity classEntity = this.getBaseMapper().selectById(params.get("classId").toString());
|
||||
|
||||
ClassModel classModel = classModelDao.selectOne(new LambdaQueryWrapper<ClassModel>().eq(ClassModel::getId,classEntity.getModelId()));
|
||||
|
||||
//相关课程
|
||||
@@ -283,12 +444,39 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
//学员
|
||||
List<Map<String,Object>> studentRes = new ArrayList<>();
|
||||
MPJLambdaWrapper<ClassUser> studentWrapper = new MPJLambdaWrapper<>();
|
||||
studentWrapper.leftJoin(MyUserEntity.class,MyUserEntity::getId,ClassUser::getUserId);
|
||||
studentWrapper.eq(ClassUser::getClassId,classEntity.getId());
|
||||
studentWrapper.eq(ClassUser::getRole,"0");
|
||||
studentWrapper.selectAll(MyUserEntity.class);
|
||||
List<MyUserEntity> students = classUserDao.selectJoinList(MyUserEntity.class,studentWrapper);
|
||||
if (students.size() > 0){
|
||||
//展示买课状态
|
||||
for (MyUserEntity user:students){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("student",user);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if ("1".equals(user.getVip())||"2".equals(user.getVip())){
|
||||
sb.append("会员 ");
|
||||
}else {
|
||||
if (courses.size() > 0){
|
||||
for (CourseEntity course : courses) {
|
||||
int count = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
.eq(UserCourseBuyEntity::getUserId,user.getId())
|
||||
.eq(UserCourseBuyEntity::getCourseId,course.getId()));
|
||||
if (count > 0){
|
||||
sb.append(course.getTitle()+"已购买 ");//空格用来分割多门课程
|
||||
}else {
|
||||
sb.append(course.getTitle()+"未购买 ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("buyState",sb.toString());
|
||||
studentRes.add(map);
|
||||
}
|
||||
}
|
||||
|
||||
Object userId;
|
||||
try {
|
||||
@@ -298,7 +486,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
ClassUser classUser = classUserDao.selectOne(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId())
|
||||
.eq(ClassUser::getUserId,userId));
|
||||
.eq(ClassUser::getUserId,userId)
|
||||
.eq(ClassUser::getRole,"0"));
|
||||
boolean isJoin = false;
|
||||
if (classUser!=null){
|
||||
isJoin = true;
|
||||
@@ -309,7 +498,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
result.put("classModel",classModel);
|
||||
result.put("courses",courses);
|
||||
result.put("admins",admins);
|
||||
result.put("students",students);
|
||||
result.put("students",studentRes);
|
||||
result.put("studentNumber",students.size());
|
||||
result.put("isJoin",isJoin);
|
||||
return result;
|
||||
@@ -338,15 +527,47 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassEntity::getModelId);
|
||||
wrapper.leftJoin(ClassCourse.class,ClassCourse::getModelId,ClassModel::getId);
|
||||
wrapper.eq(ClassCourse::getCourseId,params.get("courseId"));
|
||||
wrapper.eq(ClassEntity::getState,params.get("state"));
|
||||
wrapper.eq(ClassModel::getType,params.get("type"));
|
||||
if (StringUtils.isNotEmpty(params.get("state").toString())){
|
||||
wrapper.eq(ClassEntity::getState,params.get("state"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.eq(ClassModel::getType,params.get("type"));
|
||||
}
|
||||
List<ClassEntity> classes = this.baseMapper.selectList(wrapper);
|
||||
if (classes.size() > 0){
|
||||
for (ClassEntity classEntity:classes){
|
||||
classEntity.setClassModel(classModelDao.selectById(classEntity.getModelId()));
|
||||
}
|
||||
}
|
||||
return classes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean joinClass(Map<String, Object> params) {
|
||||
public R joinClass(Map<String, Object> params) {
|
||||
ClassEntity classEntity = this.baseMapper.selectById(params.get("classId").toString());
|
||||
//查询本班级关联课程
|
||||
MPJLambdaWrapper<ClassCourse> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
wrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
wrapper.selectAll(ClassCourse.class);
|
||||
wrapper.eq(ClassEntity::getId,classEntity.getId());
|
||||
List<ClassCourse> courseList = classCourseDao.selectList(wrapper);
|
||||
//关联课程是否有已进班的
|
||||
if (courseList.size() > 0){
|
||||
for (ClassCourse classCourse:courseList){
|
||||
MPJLambdaWrapper<ClassCourse> courseWrapper = new MPJLambdaWrapper();
|
||||
courseWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
courseWrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
courseWrapper.leftJoin(ClassUser.class,ClassUser::getClassId,ClassEntity::getId);
|
||||
courseWrapper.eq(ClassCourse::getCourseId,classCourse.getCourseId());
|
||||
courseWrapper.eq(ClassUser::getUserId,ShiroUtils.getUId());
|
||||
courseWrapper.ne(ClassEntity::getState,"2");
|
||||
if (classCourseDao.selectCount(courseWrapper)>0){
|
||||
return R.error("已有本课程班级");
|
||||
}
|
||||
}
|
||||
}
|
||||
//判断开班人数
|
||||
int count = classUserDao.selectCount(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classEntity.getId())
|
||||
.eq(ClassUser::getRole,"0"));
|
||||
@@ -355,9 +576,9 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
classUser.setClassId(classEntity.getId());
|
||||
classUser.setUserId(ShiroUtils.getUId());
|
||||
classUserDao.insert(classUser);
|
||||
return true;
|
||||
return R.ok();
|
||||
}else {
|
||||
return false;
|
||||
return R.error("人数已满");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,20 +587,385 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
classUserDao.delete(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,params.get("classId"))
|
||||
.eq(ClassUser::getUserId,params.get("userId")));
|
||||
|
||||
LambdaQueryWrapper<ClassTask> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
List<ClassTask> taskList = classTaskDao.selectList(wrapper);
|
||||
if (taskList.size() > 0) {
|
||||
for (ClassTask taskTask : taskList) {
|
||||
if (taskTask.getUserId().toString().equals(params.get("userId").toString())){
|
||||
classTaskDao.deleteById(taskTask.getId());
|
||||
}
|
||||
classTaskAndQuesReplyDao.delete(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,taskTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getUserId,params.get("userId")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClassEntity> MyClassList(Map<String, Object> params) {
|
||||
public List<Map<String,Object>> MyClassList(Map<String, Object> params) {
|
||||
MPJLambdaWrapper<ClassEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(ClassUser.class,ClassUser::getClassId,ClassEntity::getId);
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassEntity::getModelId);
|
||||
wrapper.selectAll(ClassEntity.class);
|
||||
wrapper.select(ClassEntity::getId,ClassEntity::getTitle,ClassEntity::getNumber,ClassEntity::getIcon);
|
||||
wrapper.selectAs(ClassModel::getId,"modelId");
|
||||
wrapper.select(ClassModel::getType);
|
||||
wrapper.distinct();
|
||||
wrapper.eq(ClassEntity::getState,params.get("state"));
|
||||
wrapper.eq(ClassModel::getType,params.get("type"));
|
||||
if("1".equals(params.get("isCommittee").toString())){
|
||||
wrapper.in(ClassUser::getRole,"1","2","3","4","5");
|
||||
}else {
|
||||
wrapper.eq(ClassUser::getRole,"0");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.eq(ClassModel::getType,params.get("type"));
|
||||
}
|
||||
wrapper.eq(ClassUser::getUserId,ShiroUtils.getUId());
|
||||
List<ClassEntity> list = this.baseMapper.selectList(wrapper);
|
||||
List<Map<String,Object>> list = this.baseMapper.selectMaps(wrapper);
|
||||
if (list.size() > 0){
|
||||
for (Map<String,Object> map:list){
|
||||
map.put("classModel",classModelDao.selectById(map.get("modelId").toString()));
|
||||
map.put("role",classUserDao.selectList(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,map.get("id").toString())
|
||||
.eq(ClassUser::getUserId,ShiroUtils.getUId())));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassTask(ClassTask classTask) {
|
||||
classTask.setUserId(ShiroUtils.getUId());
|
||||
classTaskDao.insert(classTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page getClassTaskList(Map<String, Object> params) {
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
LambdaQueryWrapper<ClassTask> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
if (StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.eq(ClassTask::getType,params.get("type"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("title").toString())){
|
||||
wrapper.like(ClassTask::getTitle,params.get("title"));
|
||||
}
|
||||
wrapper.orderByAsc(ClassTask::getScoreSuccess);
|
||||
wrapper.orderByDesc(ClassTask::getCreateTime);
|
||||
Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper);
|
||||
for (ClassTask classTask:classTaskPage.getRecords()){
|
||||
classTask.setCreateUser(myUserDao.selectById(classTask.getUserId()));
|
||||
ClassEntity classEntity = this.baseMapper.selectById(classTask.getClassId());
|
||||
int alreadyReply = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId()));
|
||||
int noReply = classEntity.getNumber() - alreadyReply;
|
||||
int alreadyScore = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getScoreSuccess,"1"));
|
||||
int noScore = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getScoreSuccess,"0"));
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("setGiveHomeWorkNumber",alreadyReply);
|
||||
result.put("setNoGiveHomeWorkNumber",noReply);
|
||||
result.put("setGiveScoreNumber",alreadyScore);
|
||||
result.put("setNoGiveScoreNumber",noScore);
|
||||
classTask.setOtherInfo(result);
|
||||
}
|
||||
return classTaskPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page getClassTaskListStudent(Map<String, Object> params) {
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
LambdaQueryWrapper<ClassTask> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
if (StringUtils.isNotEmpty(params.get("type").toString())){
|
||||
wrapper.eq(ClassTask::getType,params.get("type"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("title").toString())){
|
||||
wrapper.like(ClassTask::getTitle,params.get("title"));
|
||||
}
|
||||
if ("1".equals(params.get("myExperience").toString())){
|
||||
wrapper.eq(ClassTask::getUserId,ShiroUtils.getUId());
|
||||
}else {
|
||||
wrapper.eq(ClassTask::getDisplay,"1");
|
||||
}
|
||||
wrapper.orderByDesc(ClassTask::getCreateTime);
|
||||
Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper);
|
||||
for (ClassTask classTask:classTaskPage.getRecords()){
|
||||
classTask.setCreateUser(myUserDao.selectById(classTask.getUserId()));
|
||||
int count = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId()));
|
||||
if (count > 0) {
|
||||
classTask.setReply(true);
|
||||
}else {
|
||||
classTask.setReply(false);
|
||||
}
|
||||
}
|
||||
return classTaskPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editClassTask(ClassTask classTask) {
|
||||
classTaskDao.updateById(classTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> getClassTaskInfo(Map<String, Object> params) {
|
||||
ClassTask classTask = classTaskDao.selectById(params.get("taskId").toString());
|
||||
classTask.setCreateUser(myUserDao.selectById(classTask.getUserId().toString()));
|
||||
List<ClassUser> userList = classUserDao.selectList(new LambdaQueryWrapper<ClassUser>()
|
||||
.eq(ClassUser::getClassId,classTask.getClassId())
|
||||
.eq(ClassUser::getRole,"0"));
|
||||
if (userList.size() > 0){
|
||||
for (ClassUser classUser:userList){
|
||||
ClassTaskAndQuesReply reply = classTaskAndQuesReplyDao.selectOne(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getUserId,classUser.getUserId()));
|
||||
classUser.setReply(reply==null?false:true);
|
||||
classUser.setReplySuccess(reply==null?false:("0".equals(reply.getScoreSuccess())?false:true));
|
||||
classUser.setScore(reply==null?0:reply.getScore());
|
||||
}
|
||||
}
|
||||
Map<String,Object> result = new HashMap<>();
|
||||
result.put("classTask",classTask);
|
||||
result.put("userList",userList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassTask getClassTaskInfoStudent(Map<String, Object> params) {
|
||||
ClassTask classTask = classTaskDao.selectById(params.get("taskId").toString());
|
||||
classTask.setCreateUser(myUserDao.selectById(classTask.getUserId().toString()));
|
||||
int count = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
|
||||
.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId()));
|
||||
if (count > 0) {
|
||||
classTask.setReply(true);
|
||||
}else {
|
||||
classTask.setReply(false);
|
||||
}
|
||||
return classTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addClassTaskAndQuesReply(ClassTaskAndQuesReply classTaskAndQuesReply) {
|
||||
classTaskAndQuesReply.setUserId(ShiroUtils.getUId());
|
||||
classTaskAndQuesReplyDao.insert(classTaskAndQuesReply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page getReplyListByTaskId(Map<String, Object> params) {
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
LambdaQueryWrapper<ClassTaskAndQuesReply> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClassTaskAndQuesReply::getRelationId,params.get("taskId"));
|
||||
wrapper.orderByAsc(ClassTaskAndQuesReply::getScoreSuccess);
|
||||
wrapper.orderByDesc(ClassTaskAndQuesReply::getCreateTime);
|
||||
Page<ClassTaskAndQuesReply> TaskAndQuesReplyPage = classTaskAndQuesReplyDao.selectPage(new Page<>(page, limit), wrapper);
|
||||
for (ClassTaskAndQuesReply classTaskAndQuesReply :TaskAndQuesReplyPage.getRecords()){
|
||||
classTaskAndQuesReply.setCreateUser(myUserDao.selectById(classTaskAndQuesReply.getUserId()));
|
||||
}
|
||||
return TaskAndQuesReplyPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page getReplyListByTaskIdStudent(Map<String, Object> params) {
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
LambdaQueryWrapper<ClassTaskAndQuesReply> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClassTaskAndQuesReply::getRelationId,params.get("taskId"));
|
||||
if ("1".equals(params.get("myReply").toString())){
|
||||
wrapper.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId());
|
||||
}else {
|
||||
wrapper.eq(ClassTaskAndQuesReply::getDisplay,"1");
|
||||
}
|
||||
wrapper.orderByDesc(ClassTaskAndQuesReply::getCreateTime);
|
||||
Page<ClassTaskAndQuesReply> TaskAndQuesReplyPage = classTaskAndQuesReplyDao.selectPage(new Page<>(page, limit), wrapper);
|
||||
for (ClassTaskAndQuesReply classTaskAndQuesReply :TaskAndQuesReplyPage.getRecords()){
|
||||
classTaskAndQuesReply.setCreateUser(myUserDao.selectById(classTaskAndQuesReply.getUserId()));
|
||||
}
|
||||
return TaskAndQuesReplyPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editTaskScore(Map<String, Object> params) {
|
||||
ClassTask classTask = classTaskDao.selectById(params.get("taskId").toString());
|
||||
classTask.setScoreSuccess("1");
|
||||
classTask.setScore(Double.parseDouble(params.get("score").toString()));
|
||||
classTaskDao.updateById(classTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editScore(Map<String, Object> params) {
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classTaskAndQuesReplyDao.selectById(params.get("replyId").toString());
|
||||
String score = params.get("score").toString();
|
||||
String scoreInfo = "";
|
||||
Map<String,Object> userIdAndScore = new HashMap<>();
|
||||
if (StringUtils.isNotEmpty(classTaskAndQuesReply.getScoreInfo())){
|
||||
boolean flag = true;
|
||||
userIdAndScore = JSON.parseObject(classTaskAndQuesReply.getScoreInfo());
|
||||
for (Map.Entry<String,Object> key : userIdAndScore.entrySet()) {
|
||||
if (key.equals(ShiroUtils.getUId().toString())){
|
||||
flag = false;
|
||||
key.setValue(score);
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
userIdAndScore.put(""+ShiroUtils.getUId(),score);
|
||||
}
|
||||
}else {
|
||||
userIdAndScore.put(""+ShiroUtils.getUId(),score);
|
||||
}
|
||||
scoreInfo = JSON.toJSONString(userIdAndScore);
|
||||
classTaskAndQuesReply.setScoreInfo(scoreInfo);
|
||||
classTaskAndQuesReplyDao.updateById(classTaskAndQuesReply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateScore(Map<String, Object> params) {
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classTaskAndQuesReplyDao.selectById(params.get("replyId").toString());
|
||||
if (StringUtils.isNotEmpty(classTaskAndQuesReply.getScoreInfo())) {
|
||||
Map<String,Object> userIdAndScore = JSON.parseObject(classTaskAndQuesReply.getScoreInfo());
|
||||
double socre = 0;
|
||||
for (Map.Entry<String,Object> key : userIdAndScore.entrySet()) {
|
||||
socre = socre + Double.valueOf(key.getValue().toString());
|
||||
}
|
||||
socre = socre/userIdAndScore.size();
|
||||
BigDecimal socre2 = new BigDecimal(socre);
|
||||
socre2 = socre2.setScale(2,RoundingMode.HALF_UP);
|
||||
classTaskAndQuesReply.setScoreSuccess("1");
|
||||
classTaskAndQuesReply.setScore(socre2.doubleValue());
|
||||
classTaskAndQuesReplyDao.updateById(classTaskAndQuesReply);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editClassTaskAndQuesReply(ClassTaskAndQuesReply classTaskAndQuesReply) {
|
||||
classTaskAndQuesReplyDao.updateById(classTaskAndQuesReply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassTaskAndQuesReply getClassTaskAndQuesReplyInfo(Map<String, Object> params) {
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classTaskAndQuesReplyDao.selectById(params.get("replyId").toString());
|
||||
classTaskAndQuesReply.setCreateUser(myUserDao.selectById(classTaskAndQuesReply.getUserId().toString()));
|
||||
return classTaskAndQuesReply;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassTaskAndQuesReply getQuesReplyInfo(Map<String, Object> params) {
|
||||
ClassTaskAndQuesReply classTaskAndQuesReply = classTaskAndQuesReplyDao.selectOne(
|
||||
new LambdaQueryWrapper<ClassTaskAndQuesReply>()
|
||||
.eq(ClassTaskAndQuesReply::getRelationId,params.get("relationId").toString())
|
||||
.eq(ClassTaskAndQuesReply::getUserId,params.get("userId").toString()));
|
||||
return classTaskAndQuesReply;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getThinkQuestionList(Map<String, Object> params) {
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||
wrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseEntity::getId);
|
||||
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
wrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
wrapper.eq(ClassEntity::getId,params.get("classId"));
|
||||
wrapper.select(CourseEntity::getId,CourseEntity::getTitle,CourseEntity
|
||||
::getSort);
|
||||
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
|
||||
wrapper.selectAs(CourseCatalogueEntity::getTitle,"catalogueTitle");
|
||||
wrapper.selectAs(CourseCatalogueEntity::getSort,"catalogueSort");
|
||||
wrapper.orderByAsc("sort","catalogueSort");
|
||||
List<Map<String,Object>> list = courseDao.selectMaps(wrapper);
|
||||
if (list.size() > 0){
|
||||
for (Map<String,Object> map : list){
|
||||
List<Map<String,Object>> chapters = courseCatalogueChapterDao.selectMaps(
|
||||
new LambdaQueryWrapper<CourseCatalogueChapterEntity>()
|
||||
.eq(CourseCatalogueChapterEntity::getCatalogueId,map.get("catalogueId"))
|
||||
.ne(CourseCatalogueChapterEntity::getQuestions,"")
|
||||
.orderByAsc(CourseCatalogueChapterEntity::getSort)
|
||||
.select(CourseCatalogueChapterEntity::getId
|
||||
,CourseCatalogueChapterEntity::getTitle
|
||||
,CourseCatalogueChapterEntity::getQuestions));
|
||||
map.put("chapters",chapters);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getUserScore(Map<String, Object> params) {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
double task0Score = 0;
|
||||
MPJLambdaWrapper<ClassTaskAndQuesReply> task0wrapper = new MPJLambdaWrapper<>();
|
||||
task0wrapper.leftJoin(ClassTask.class,ClassTask::getId,ClassTaskAndQuesReply::getRelationId);
|
||||
task0wrapper.selectAll(ClassTaskAndQuesReply.class);
|
||||
task0wrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
task0wrapper.eq(ClassTask::getType,"0");
|
||||
task0wrapper.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId());
|
||||
List<ClassTaskAndQuesReply> task0Replys = classTaskAndQuesReplyDao.selectList(task0wrapper);
|
||||
if (task0Replys.size() > 0) {
|
||||
for (ClassTaskAndQuesReply reply : task0Replys) {
|
||||
if ("1".equals(reply.getScoreSuccess())){
|
||||
task0Score += reply.getScore();
|
||||
}
|
||||
}
|
||||
}
|
||||
double task1Score = 0;
|
||||
MPJLambdaWrapper<ClassTaskAndQuesReply> task1wrapper = new MPJLambdaWrapper<>();
|
||||
task1wrapper.leftJoin(ClassTask.class,ClassTask::getId,ClassTaskAndQuesReply::getRelationId);
|
||||
task1wrapper.selectAll(ClassTaskAndQuesReply.class);
|
||||
task1wrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
task1wrapper.eq(ClassTask::getType,"1");
|
||||
task1wrapper.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId());
|
||||
List<ClassTaskAndQuesReply> task1Replys = classTaskAndQuesReplyDao.selectList(task1wrapper);
|
||||
if (task1Replys.size() > 0) {
|
||||
for (ClassTaskAndQuesReply reply : task1Replys) {
|
||||
if ("1".equals(reply.getScoreSuccess())){
|
||||
task1Score += reply.getScore();
|
||||
}
|
||||
}
|
||||
}
|
||||
double experienceScore = 0;
|
||||
MPJLambdaWrapper<ClassTask> experiencewrapper = new MPJLambdaWrapper<>();
|
||||
experiencewrapper.eq(ClassTask::getUserId,ShiroUtils.getUId());
|
||||
experiencewrapper.eq(ClassTask::getClassId,params.get("classId"));
|
||||
experiencewrapper.eq(ClassTask::getType,"2");
|
||||
List<ClassTask> experiences = classTaskDao.selectList(experiencewrapper);
|
||||
if (experiences.size() > 0) {
|
||||
for (ClassTask task : experiences) {
|
||||
if ("1".equals(task.getScoreSuccess())){
|
||||
experienceScore += task.getScore();
|
||||
}
|
||||
}
|
||||
}
|
||||
double questionScore = 0;
|
||||
MPJLambdaWrapper<ClassTaskAndQuesReply> questionWrapper = new MPJLambdaWrapper<>();
|
||||
questionWrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getId,ClassTaskAndQuesReply::getRelationId);
|
||||
questionWrapper.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueEntity::getCourseId);
|
||||
questionWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
questionWrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
questionWrapper.selectAll(ClassTaskAndQuesReply.class);
|
||||
questionWrapper.eq(ClassEntity::getId,params.get("classId"));
|
||||
questionWrapper.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId());
|
||||
List<ClassTaskAndQuesReply> questionReplys = classTaskAndQuesReplyDao.selectList(questionWrapper);
|
||||
if (questionReplys.size() > 0) {
|
||||
for (ClassTaskAndQuesReply reply : questionReplys) {
|
||||
if ("1".equals(reply.getScoreSuccess())){
|
||||
questionScore += reply.getScore();
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("task0Score",task0Score);
|
||||
map.put("task1Score",task1Score);
|
||||
map.put("experienceScore",experienceScore);
|
||||
map.put("questionScore",questionScore);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
package com.peanut.modules.common.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.modules.common.dao.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.ClassExamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service("commonClassExamService")
|
||||
public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> implements ClassExamService {
|
||||
|
||||
@Autowired
|
||||
private ClassExamSubjectDao classExamSubjectDao;
|
||||
@Autowired
|
||||
private ClassExamOptionDao classExamOptionDao;
|
||||
@Autowired
|
||||
private ClassCourseDao classCourseDao;
|
||||
@Autowired
|
||||
private ClassExamUserDao classExamUserDao;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public String importSubject(MultipartFile file, String courseId) {
|
||||
try (InputStream fis = file.getInputStream()) {
|
||||
Workbook workbook = WorkbookFactory.create(fis);
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
// 遍历行
|
||||
for (Row row : sheet) {
|
||||
if (!isRowEmpty(row)){
|
||||
if (row.getRowNum()==0){
|
||||
continue;
|
||||
}
|
||||
ClassExamSubject subject = new ClassExamSubject();
|
||||
subject.setCourseId(1);
|
||||
//类型
|
||||
String type = row.getCell(0)==null?"":row.getCell(0).toString();
|
||||
if (type.contains("单选")){
|
||||
subject.setType(0);
|
||||
}else if (type.contains("多选")){
|
||||
subject.setType(1);
|
||||
}else {
|
||||
System.out.println(row.getRowNum()+"此题无题目类型");
|
||||
}
|
||||
//题目
|
||||
subject.setContent(row.getCell(1)==null?"":row.getCell(1).toString());
|
||||
//所属章节
|
||||
subject.setChapter(row.getCell(13)==null?"":row.getCell(13).toString());
|
||||
//音视频序号
|
||||
subject.setMedia(row.getCell(14)==null?"":row.getCell(14).toString());
|
||||
//音视频时间
|
||||
subject.setMediaTime(row.getCell(15)==null?"":row.getCell(15).toString());
|
||||
//出题人
|
||||
subject.setCreateUser(row.getCell(16)==null?"":row.getCell(16).toString());
|
||||
classExamSubjectDao.insert(subject);
|
||||
//选项1-6
|
||||
for (int i=2; i<=7;i++) {
|
||||
if (row.getCell(i)!=null&&!"".equals(row.getCell(i).toString())){
|
||||
ClassExamOption option = new ClassExamOption();
|
||||
option.setSubjectId(subject.getId());
|
||||
String content = row.getCell(i).toString();
|
||||
String raw = row.getCell(8)==null?"":row.getCell(8).toString();
|
||||
if (raw.contains(content.substring(0,1))){
|
||||
option.setRightWrong(1);
|
||||
}else {
|
||||
option.setRightWrong(0);
|
||||
}
|
||||
char[] c = content.toCharArray();
|
||||
if (c.length>1){
|
||||
if (c[1]=='、'||c[1]==':'||c[1]==';'||c[1]==':'||c[1]==';'||c[1]==' '||c[1]=='.'){
|
||||
content = content.substring(2);
|
||||
}else {
|
||||
content = content.substring(1);
|
||||
}
|
||||
}else {
|
||||
content = "";
|
||||
}
|
||||
if (StringUtils.isNotBlank(content)){
|
||||
option.setContent(content);
|
||||
classExamOptionDao.insert(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException | InvalidFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static boolean isRowEmpty(Row row) {
|
||||
for (Cell cell : row) {
|
||||
if (cell.getCellTypeEnum() != CellType.BLANK) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addClassExamSubject(ClassExamSubject classExamSubject) {
|
||||
return classExamSubjectDao.insert(classExamSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addClassExamOption(ClassExamOption classExamOption) {
|
||||
return classExamOptionDao.insert(classExamOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateClassExamSubject(ClassExamSubject classExamSubject) {
|
||||
return classExamSubjectDao.updateById(classExamSubject);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateClassExamOption(ClassExamOption classExamOption) {
|
||||
return classExamOptionDao.updateById(classExamOption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delClassExamSubject(Map<String, Object> params) {
|
||||
return classExamSubjectDao.deleteById(params.get("subjectId").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delClassExamOption(Map<String, Object> params) {
|
||||
return classExamOptionDao.deleteById(params.get("optionId").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page getClassExamSubjectList(Map<String, Object> params) {
|
||||
Integer limit = Integer.valueOf(params.get("limit").toString());
|
||||
Integer page = Integer.valueOf(params.get("page").toString());
|
||||
MPJLambdaWrapper<ClassExamSubject> wrapper = new MPJLambdaWrapper<>();
|
||||
if (StringUtils.isNotEmpty(params.get("content").toString())){
|
||||
wrapper.like(ClassExamSubject::getContent,params.get("content"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("courseId").toString())){
|
||||
wrapper.eq(ClassExamSubject::getCourseId,params.get("courseId"));
|
||||
}
|
||||
wrapper.orderByDesc(ClassExamSubject::getId);
|
||||
Page<ClassExamSubject> classExamSubjectPage = classExamSubjectDao.selectPage(new Page<>(page, limit), wrapper);
|
||||
for (ClassExamSubject subject:classExamSubjectPage.getRecords()){
|
||||
//配置选项
|
||||
subject.setOptions(classExamOptionDao.selectList(
|
||||
new LambdaQueryWrapper<ClassExamOption>().eq(ClassExamOption::getSubjectId,subject.getId())));
|
||||
}
|
||||
return classExamSubjectPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object generateExamPaper(Map<String, Object> params) {
|
||||
MPJLambdaWrapper<ClassCourse> courseWrapper = new MPJLambdaWrapper<>();
|
||||
courseWrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassCourse::getModelId);
|
||||
courseWrapper.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassModel::getId);
|
||||
courseWrapper.eq(ClassEntity::getId,params.get("classId"));
|
||||
courseWrapper.selectAll(ClassCourse.class);
|
||||
List<ClassCourse> courseList = classCourseDao.selectList(courseWrapper);
|
||||
List<ClassExamSubject> resultList = new ArrayList<>();
|
||||
List<ClassExamSubject> sList = new ArrayList<>();
|
||||
List<ClassExamSubject> mList = new ArrayList<>();
|
||||
if (courseList.size() > 0) {
|
||||
int stotal = 50;//单选题总数
|
||||
int mtotal = 50;//多选题总数
|
||||
int snum = (int)Math.floor(stotal/courseList.size());
|
||||
int mnum = (int)Math.floor(mtotal/courseList.size());
|
||||
for (ClassCourse course:courseList){
|
||||
//单选
|
||||
List<ClassExamSubject> singleList = classExamSubjectDao.selectList(new LambdaQueryWrapper<ClassExamSubject>()
|
||||
.eq(ClassExamSubject::getCourseId,course.getCourseId())
|
||||
.eq(ClassExamSubject::getType,0));
|
||||
Collections.shuffle(singleList);//打乱顺序
|
||||
if (sList.size()+snum>stotal){
|
||||
sList.addAll(singleList.subList(0,stotal-sList.size()));
|
||||
}else {
|
||||
sList.addAll(singleList.subList(0,snum));
|
||||
}
|
||||
//多选
|
||||
List<ClassExamSubject> mulList = classExamSubjectDao.selectList(new LambdaQueryWrapper<ClassExamSubject>()
|
||||
.eq(ClassExamSubject::getCourseId,course.getCourseId())
|
||||
.eq(ClassExamSubject::getType,1));
|
||||
Collections.shuffle(mulList);//打乱顺序
|
||||
if (mList.size()+mnum>mtotal){
|
||||
mList.addAll(mulList.subList(0,mtotal-mList.size()));
|
||||
}else {
|
||||
mList.addAll(mulList.subList(0,mnum));
|
||||
}
|
||||
}
|
||||
}
|
||||
resultList.addAll(sList);
|
||||
resultList.addAll(mList);
|
||||
//拼装选项
|
||||
if (resultList.size()>0){
|
||||
for (ClassExamSubject subject:resultList) {
|
||||
List<ClassExamOption> options = classExamOptionDao.selectList(
|
||||
new LambdaQueryWrapper<ClassExamOption>().eq(ClassExamOption::getSubjectId,subject.getId()));
|
||||
Collections.shuffle(options);//打乱顺序
|
||||
subject.setOptions(options);
|
||||
}
|
||||
}
|
||||
ClassExamUser classExamUser = new ClassExamUser();
|
||||
classExamUser.setExamId(this.getBaseMapper().selectOne(new LambdaQueryWrapper<ClassExam>().eq(ClassExam::getClassId,params.get("classId"))).getId());
|
||||
classExamUser.setSubject(JSONUtil.toJsonStr(resultList));
|
||||
classExamUser.setUserId(ShiroUtils.getUId());
|
||||
classExamUserDao.insert(classExamUser);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object submitExamPaper(Map<String, Object> params) {
|
||||
ClassExamUser classExamUser = classExamUserDao.selectById(params.get("id").toString());
|
||||
List<String> answerList = (List)params.get("answer");
|
||||
List<String> resAnswerList = new ArrayList<>();
|
||||
List<Object> subjectList = JSONUtil.parseArray(classExamUser.getSubject());
|
||||
int score = 0;
|
||||
for (int i=0;i<answerList.size(); i++){
|
||||
ClassExamSubject subject = JSONUtil.toBean(JSONUtil.toJsonStr(subjectList.get(i)),ClassExamSubject.class);
|
||||
if (subject.getType()==0){
|
||||
ClassExamOption option = classExamOptionDao.selectById(answerList.get(i));
|
||||
if (option.getRightWrong()==1){
|
||||
score++;
|
||||
resAnswerList.add(answerList.get(i)+":1");
|
||||
}else {
|
||||
resAnswerList.add(answerList.get(i)+":0");
|
||||
}
|
||||
}else {
|
||||
List<ClassExamOption> options = subject.getOptions();
|
||||
boolean flag = true;
|
||||
for (ClassExamOption o:options){
|
||||
if (o.getRightWrong()==1){
|
||||
if (answerList.get(i).contains(o.getId().toString())){
|
||||
}else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag){
|
||||
score++;
|
||||
resAnswerList.add(answerList.get(i)+":1");
|
||||
}else {
|
||||
resAnswerList.add(answerList.get(i)+":0");
|
||||
}
|
||||
}
|
||||
}
|
||||
classExamUser.setAnswer(JSONUtil.toJsonStr(resAnswerList));
|
||||
classExamUser.setScore(score);
|
||||
classExamUser.setScoreSuccess("1");
|
||||
classExamUserDao.updateById(classExamUser);
|
||||
return classExamUser;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user