模型相关
This commit is contained in:
@@ -2,16 +2,16 @@ 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.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.entity.*;
|
||||
import com.peanut.modules.common.service.ClassEntityService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
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.RestController;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -33,6 +33,15 @@ public class ClassController {
|
||||
//新增班级模型
|
||||
@RequestMapping("/addClassModel")
|
||||
public R addClassModel(@RequestBody ClassModel classModel){
|
||||
String[] courseIds = classModel.getCourseIds().split(",");
|
||||
if(courseIds.length > 0){
|
||||
HashSet<String> set = new HashSet<>();
|
||||
for (String courseId : courseIds) {
|
||||
if (!set.add(courseId)){
|
||||
return R.error("课程不能重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
int score = 0;
|
||||
if (classModel.getIsQuestion()==1){
|
||||
score += classModel.getQuestionScore();
|
||||
@@ -50,11 +59,7 @@ public class ClassController {
|
||||
score += classModel.getExamScore();
|
||||
}
|
||||
if (score==100){
|
||||
if (classEntityService.addClassModel(classModel)){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("保存出错");
|
||||
}
|
||||
return classEntityService.addClassModel(classModel);
|
||||
}else {
|
||||
return R.error("请设置各模块占比总和为100");
|
||||
}
|
||||
@@ -63,6 +68,15 @@ public class ClassController {
|
||||
//修改班级模型
|
||||
@RequestMapping("/editClassModel")
|
||||
public R editClassModel(@RequestBody ClassModel classModel){
|
||||
String[] courseIds = classModel.getCourseIds().split(",");
|
||||
if(courseIds.length > 0){
|
||||
HashSet<String> set = new HashSet<>();
|
||||
for (String courseId : courseIds) {
|
||||
if (!set.add(courseId)){
|
||||
return R.error("课程不能重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
int score = 0;
|
||||
if (classModel.getIsQuestion()==1){
|
||||
score += classModel.getQuestionScore();
|
||||
@@ -86,6 +100,13 @@ public class ClassController {
|
||||
}
|
||||
}
|
||||
|
||||
//获取模型可选课程
|
||||
@RequestMapping("/getClassModelCourseList")
|
||||
public R getClassModelCourseList(@RequestBody Map<String,Object> params){
|
||||
List<CourseEntity> courseList = classEntityService.getClassModelCourseList(params);
|
||||
return R.ok().put("courseList",courseList);
|
||||
}
|
||||
|
||||
//获取主任下的班级模型
|
||||
@RequestMapping("/getClassModelByUserid")
|
||||
public R getClassModelByUserid(@RequestBody Map<String,Object> params){
|
||||
|
||||
Reference in New Issue
Block a user