模型相关
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){
|
||||
|
||||
@@ -11,10 +11,12 @@ public interface ClassEntityService extends IService<ClassEntity> {
|
||||
|
||||
Page getClassModelList(Map<String ,Object> params);
|
||||
|
||||
boolean addClassModel(ClassModel classModel);
|
||||
R addClassModel(ClassModel classModel);
|
||||
|
||||
R editClassModel(ClassModel classModel);
|
||||
|
||||
List<CourseEntity> getClassModelCourseList(Map<String, Object> params);
|
||||
|
||||
List<ClassModel> getClassModelByUserid(Map<String ,Object> params);
|
||||
|
||||
List<Map<String, Object>> getClassByDirectorid(Map<String,Object> params);
|
||||
|
||||
@@ -17,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
@@ -66,7 +68,8 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addClassModel(ClassModel classModel) {
|
||||
@Transactional
|
||||
public R addClassModel(ClassModel classModel) {
|
||||
classModelDao.insert(classModel);
|
||||
String[] courseIds = classModel.getCourseIds().split(",");
|
||||
if(courseIds.length > 0){
|
||||
@@ -77,7 +80,7 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
classCourseDao.insert(classCourse);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,6 +109,17 @@ public class ClassEntityServiceImpl extends ServiceImpl<ClassEntityDao, ClassEnt
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CourseEntity> getClassModelCourseList(Map<String, Object> params) {
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.exists("select * from course_to_medicine where del_flag = 0 and course_id = t.id");
|
||||
wrapper.like(CourseEntity::getTitle,params.get("title"));
|
||||
wrapper.selectAs(CourseEntity::getId,"id");
|
||||
wrapper.selectAs(CourseEntity::getTitle,"title");
|
||||
List<CourseEntity> list = courseDao.selectList(wrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClassModel> getClassModelByUserid(Map<String, Object> params) {
|
||||
LambdaQueryWrapper<ClassModel> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Reference in New Issue
Block a user