小班相关

This commit is contained in:
wuchunlei
2024-08-28 10:11:41 +08:00
parent 8ac3fc29f4
commit 40f192a8bc
14 changed files with 197 additions and 17 deletions

View File

@@ -37,8 +37,12 @@ public interface ClassEntityService extends IService<ClassEntity> {
Object getClassInfo(Map<String ,Object> params);
List<ClassEntity> getClassNoUser();
List<ClassEntity> getClassByCourseIdNoUser(Map<String ,Object> params);
ClassEntity getClassByUser(Map<String, Object> params);
R joinClass(Map<String ,Object> params);
void quitClass(Map<String ,Object> params);

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ClassExamOption;
public interface ClassExamOptionService extends IService<ClassExamOption> {
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ClassExamSubject;
public interface ClassExamSubjectService extends IService<ClassExamSubject> {
}

View File

@@ -495,6 +495,17 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
return result;
}
@Override
public List<ClassEntity> getClassNoUser() {
MPJLambdaWrapper<ClassEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(ClassEntity.class);
String classSql = "select 1 from ( select c.id from class c left join class_course cc on cc.model_id = c.model_id left join class_user cu on cu.class_id = c.id where c.del_flag = 0 and cc.del_flag = 0 and cu.del_flag = 0 and cu.user_id = "+ShiroUtils.getUId()+" ) s where s.id = t.id";
String courseSql = "select 1 from (select cc.model_id from class_course cc where cc.del_flag = 0 and cc.course_id in (select cc.course_id from class_course cc left join class_model cm on cm.id = cc.model_id left join class c on c.model_id = cm.id left join class_user cu on cu.class_id = c.id where cc.del_flag = 0 and cm.del_flag = 0 and c.del_flag = 0 and cu.del_flag = 0 and cu.user_id = "+ShiroUtils.getUId()+")) q where q.model_id = t.model_id";
wrapper.notExists(classSql);
wrapper.notExists(courseSql);
return this.baseMapper.selectList(wrapper);
}
@Override
public List<ClassEntity> getClassByCourseIdNoUser(Map<String, Object> params) {
MPJLambdaWrapper<ClassEntity> wrapper = new MPJLambdaWrapper<>();
@@ -504,7 +515,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
wrapper.leftJoin(ClassUser.class,ClassUser::getClassId,ClassEntity::getId);
wrapper.eq(ClassCourse::getCourseId,params.get("courseId"));
wrapper.eq(ClassUser::getUserId,ShiroUtils.getUId());
wrapper.eq(ClassEntity::getState,"2");
wrapper.ne(ClassEntity::getState,"2");
List<ClassEntity> classesUser = this.baseMapper.selectList(wrapper);
if (classesUser.size() > 0){
return new ArrayList<>();
@@ -513,18 +524,26 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
}
}
@Override
public ClassEntity getClassByUser(Map<String, Object> params) {
MPJLambdaWrapper<ClassEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(ClassEntity.class);
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassEntity::getModelId);
wrapper.leftJoin(ClassCourse.class,ClassCourse::getModelId,ClassModel::getId);
wrapper.leftJoin(ClassUser.class,ClassUser::getClassId,ClassEntity::getId);
wrapper.eq(ClassCourse::getCourseId,params.get("courseId"));
wrapper.eq(ClassUser::getUserId,ShiroUtils.getUId());
wrapper.ne(ClassEntity::getState,"2");
return this.baseMapper.selectOne(wrapper);
}
public List<ClassEntity> getClassByCourseId(Map<String, Object> params) {
MPJLambdaWrapper<ClassEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(ClassEntity.class);
wrapper.leftJoin(ClassModel.class,ClassModel::getId,ClassEntity::getModelId);
wrapper.leftJoin(ClassCourse.class,ClassCourse::getModelId,ClassModel::getId);
wrapper.eq(ClassCourse::getCourseId,params.get("courseId"));
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"));
}
wrapper.ne(ClassEntity::getState,"2");
List<ClassEntity> classes = this.baseMapper.selectList(wrapper);
if (classes.size() > 0){
for (ClassEntity classEntity:classes){
@@ -655,7 +674,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
ClassTask classTask = new ClassTask();
classTask.setClassId(classEntity.getId());
classTask.setUserId(ShiroUtils.getUId());
classTask.setSort(i*10+"");
classTask.setSort(i*30+"");
classTask.setTitle(""+i+"周的笔记");
classTask.setContent("请提交第"+i+"周的笔记");
classTaskDao.insert(classTask);
@@ -669,20 +688,23 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
LambdaQueryWrapper<ClassTask> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ClassTask::getClassId,params.get("classId"));
if (StringUtils.isNotEmpty(params.get("type").toString())){
if ("2".equals(params.get("type").toString())){
wrapper.orderByAsc(ClassTask::getScoreSuccess);
}
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.orderByAsc(ClassTask::getSort);
wrapper.orderByDesc(ClassTask::getId);
Page<ClassTask> classTaskPage = classTaskDao.selectPage(new Page<>(page, limit), wrapper);
for (ClassTask classTask:classTaskPage.getRecords()){
int alreadyReply = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId()));
int noScore = classTaskAndQuesReplyDao.selectCount(new LambdaQueryWrapper<ClassTaskAndQuesReply>()
.eq(ClassTaskAndQuesReply::getRelationId,classTask.getId())
.eq(ClassTaskAndQuesReply::getScoreSuccess,0));
.lt(ClassTaskAndQuesReply::getScoreSuccess,2));
Map<String,Object> result = new HashMap<>();
result.put("setGiveHomeWorkNumber",alreadyReply);
result.put("setNoGiveScoreNumber",noScore);
@@ -882,6 +904,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
MPJLambdaWrapper<ClassTaskAndQuesReply> replyWrap = new MPJLambdaWrapper<>();
replyWrap.leftJoin(CourseCatalogueChapterEntity.class,CourseCatalogueChapterEntity::getId,ClassTaskAndQuesReply::getRelationId);
replyWrap.leftJoin(ClassCourse.class,ClassCourse::getCourseId,CourseCatalogueChapterEntity::getCourseId);
replyWrap.leftJoin(CourseEntity.class,CourseEntity::getId,ClassCourse::getCourseId);
replyWrap.leftJoin(ClassEntity.class,ClassEntity::getModelId,ClassCourse::getModelId);
replyWrap.eq(ClassEntity::getId,params.get("classId"));
replyWrap.eq(ClassTaskAndQuesReply::getType,"1");
@@ -892,6 +915,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
replyWrap.selectAs(ClassTaskAndQuesReply::getScoreSuccess,"scoreSuccess");
replyWrap.selectAs(ClassTaskAndQuesReply::getScore,"score");
replyWrap.selectAs(CourseCatalogueChapterEntity::getId,"chapterId");
replyWrap.selectAs(CourseCatalogueChapterEntity::getTitle,"chapterTitle");
replyWrap.selectAs(CourseEntity::getTitle,"courseTitle");
replyWrap.selectAs(CourseCatalogueChapterEntity::getQuestions,"questions");
replyWrap.orderByAsc(ClassTaskAndQuesReply::getScoreSuccess);
Page<Map<String,Object>> replyPage = classTaskAndQuesReplyDao.selectMapsPage(new Page<>(page, limit), replyWrap);
@@ -911,7 +936,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
List<ClassTaskAndQuesReply> task0Replys = classTaskAndQuesReplyDao.selectList(task0wrapper);
if (task0Replys.size() > 0) {
for (ClassTaskAndQuesReply reply : task0Replys) {
if (reply.getScoreSuccess()>=1){
if (reply.getScoreSuccess()>1){
task0Score += reply.getScore();
}
}
@@ -926,7 +951,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
List<ClassTaskAndQuesReply> task1Replys = classTaskAndQuesReplyDao.selectList(task1wrapper);
if (task1Replys.size() > 0) {
for (ClassTaskAndQuesReply reply : task1Replys) {
if (reply.getScoreSuccess()>=1){
if (reply.getScoreSuccess()>1){
task1Score += reply.getScore();
}
}
@@ -953,6 +978,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
questionWrapper.selectAll(ClassTaskAndQuesReply.class);
questionWrapper.eq(ClassEntity::getId,params.get("classId"));
questionWrapper.eq(ClassTaskAndQuesReply::getUserId,ShiroUtils.getUId());
questionWrapper.eq(ClassTaskAndQuesReply::getClassId,params.get("classId"));
List<ClassTaskAndQuesReply> questionReplys = classTaskAndQuesReplyDao.selectList(questionWrapper);
if (questionReplys.size() > 0) {
for (ClassTaskAndQuesReply reply : questionReplys) {

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ClassExamOptionDao;
import com.peanut.modules.common.entity.ClassExamOption;
import com.peanut.modules.common.service.ClassExamOptionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("commonClassExamOptionService")
public class ClassExamOptionServiceImpl extends ServiceImpl<ClassExamOptionDao, ClassExamOption> implements ClassExamOptionService {
}

View File

@@ -40,6 +40,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
try (InputStream fis = file.getInputStream()) {
Workbook workbook = WorkbookFactory.create(fis);
Sheet sheet = workbook.getSheetAt(0);
Date date = new Date();
// 遍历行
for (Row row : sheet) {
if (!isRowEmpty(row)){
@@ -98,6 +99,7 @@ public class ClassExamServiceImpl extends ServiceImpl<ClassExamDao, ClassExam> i
}
}
}
System.out.println("结束"+(new Date().getTime()-date.getTime()));
} catch (IOException | InvalidFormatException e) {
e.printStackTrace();
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ClassExamSubjectDao;
import com.peanut.modules.common.entity.ClassExamSubject;
import com.peanut.modules.common.service.ClassExamSubjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("commonClassExamSubjectService")
public class ClassExamSubjectServiceImpl extends ServiceImpl<ClassExamSubjectDao, ClassExamSubject> implements ClassExamSubjectService {
}