修改接口

master
xiaoCJ 8 months ago
parent c0fe06b160
commit 2435a7b7e1

@ -119,6 +119,24 @@ public class CaseController {
@PostMapping("selectCaseByConditionsByID")
public ResultEntity<SysCaseQuestion> selectCaseByConditionsByID(@RequestParam String caseId) {
SysCaseQuestion sysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(caseId);
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andTopicIdEqualTo(caseId);
List<SysTopicAndCourse> topicAndCourseList = topicAndCourseMapper.selectByExample(example);
if (!topicAndCourseList.isEmpty()) {
SysTopicAndCourse sysTopicAndCourse = topicAndCourseList.get(0);
sysCaseQuestion.setOneId(sysTopicAndCourse.getOneId());
sysCaseQuestion.setOneName(sysTopicAndCourse.getOneName());
if (StringUtils.isNotBlank(sysTopicAndCourse.getTwoId())) {
sysCaseQuestion.setTwoId(sysTopicAndCourse.getTwoId());
sysCaseQuestion.setTwoName(sysTopicAndCourse.getTwoName());
}
if (StringUtils.isNotBlank(sysCaseQuestion.getThreeId())) {
sysCaseQuestion.setThreeName(sysTopicAndCourse.getThreeName());
sysCaseQuestion.setThreeId(sysTopicAndCourse.getThreeId());
}
}
return new ResultEntity<SysCaseQuestion>(sysCaseQuestion);
}
@ -130,25 +148,25 @@ public class CaseController {
public ResultEntity<HttpStatus> updateCase(@RequestBody SysCaseQuestion sysCaseQuestion,
@ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) {
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId(), sysCaseQuestion.getOneId());
if (!sysTopicAndCourses.isEmpty()) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
} else {
//todo 管理员任意修改,老师只能改自己的
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
if (!sysTopicAndCourses.isEmpty()) {
SysTopicAndCourse sysTopicAndCourse = sysTopicAndCourses.get(0);
sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId());
sysTopicAndCourse.setThreeId(sysCaseQuestion.getThreeId());
sysTopicAndCourse.setTwoName(sysCaseQuestion.getTwoName());
sysTopicAndCourse.setThreeName(sysCaseQuestion.getThreeName());
topicAndCourseMapper.updateByPrimaryKeySelective(sysTopicAndCourse);
}
caseQuestionMapper.updateByPrimaryKeySelective(sysCaseQuestion);
return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
// if (!sysTopicAndCourses.isEmpty()) {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
// } else {
//todo 管理员任意修改,老师只能改自己的
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
if (!sysTopicAndCourses.isEmpty()) {
SysTopicAndCourse sysTopicAndCourse = sysTopicAndCourses.get(0);
sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId());
sysTopicAndCourse.setThreeId(sysCaseQuestion.getThreeId());
sysTopicAndCourse.setTwoName(sysCaseQuestion.getTwoName());
sysTopicAndCourse.setThreeName(sysCaseQuestion.getThreeName());
topicAndCourseMapper.updateByPrimaryKeySelective(sysTopicAndCourse);
}
caseQuestionMapper.updateByPrimaryKeySelective(sysCaseQuestion);
return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
}
// }
}
@ -159,18 +177,18 @@ public class CaseController {
public ResultEntity<HttpStatus> deleteCase(@RequestBody SysCaseQuestion sysCaseQuestion,
@ApiParam("哪个用的掉的请求,传管理员/学校ID") @RequestParam String source) {
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId(), sysCaseQuestion.getOneId());
if (!sysTopicAndCourses.isEmpty()) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!");
// if (!sysTopicAndCourses.isEmpty()) {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!");
// } else {
//todo 管理员任意删除 老师只能删除自己上传的
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
topicAndCourseMapper.deleteByPrimaryKey(sysTopicAndCourses.get(0).getId());
caseQuestionMapper.deleteByPrimaryKey(sysCaseQuestion.getCaseId());
return new ResultEntity<>(HttpStatus.OK, "删除成功!");
} else {
//todo 管理员任意删除 老师只能删除自己上传的
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
topicAndCourseMapper.deleteByPrimaryKey(sysTopicAndCourses.get(0).getId());
caseQuestionMapper.deleteByPrimaryKey(sysCaseQuestion.getCaseId());
return new ResultEntity<>(HttpStatus.OK, "删除成功!");
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
}
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
}
// }
}
private List<SysTopicAndCourse> getSysTopicAndCourses(String caseId, String oneId) {

@ -56,9 +56,10 @@ public class CaseStepController {
public ResultEntity<HttpStatus> updateCase(@RequestBody SysCaseQuestionStepWithBLOBs caseQuestionStepWithBLOBs,
@ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) {
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(caseQuestionStepWithBLOBs.getCaseId());
if (!sysTopicAndCourses.isEmpty()) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
} else {
// if (!sysTopicAndCourses.isEmpty()) {
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
// }
// else {
//todo 管理员任意修改,老师只能改自己的
SysCaseQuestion sysCaseQuestion = sysCaseQuestionMapper.selectByPrimaryKey(caseQuestionStepWithBLOBs.getCaseId());
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
@ -67,7 +68,7 @@ public class CaseStepController {
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
}
}
// }
}

@ -67,8 +67,7 @@ public class CourseConfigController {
//判断文件type //todo 格式可能不够全
if (extension.equals(".pdf") || extension.equals(".ppt") || extension.equals(".pptx")
|| extension.equals(".xlsx") || extension.equals(".xls")
|| extension.equals(".doc") || extension.equals(".docx")
|| extension.equals(".txt")) {
|| extension.equals(".doc") || extension.equals(".docx")){
sysResource.setResourceType("课件");
} else if (extension.equals(".mp4") || extension.equals(".wmv") || extension.equals(".avi")) {
sysResource.setResourceType("视频");

@ -6,10 +6,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.resource_center.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.*;
import com.sztzjy.resource_center.mapper.SysOneCatalogMapper;
import com.sztzjy.resource_center.mapper.SysResourceAndCourseMapper;
import com.sztzjy.resource_center.mapper.SysThreeCatalogMapper;
import com.sztzjy.resource_center.mapper.SysTwoCatalogMapper;
import com.sztzjy.resource_center.mapper.*;
import com.sztzjy.resource_center.util.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -39,6 +36,9 @@ public class CourseManageController {
private SysThreeCatalogMapper sysThreeCatalogMapper;
@Autowired
private SysResourceAndCourseMapper sysResourceAndCourseMapper;
@Autowired
private SysTopicAndCourseMapper sysTopicAndCourseMapper;
@AnonymousAccess
@ApiOperation("新增课程")
@ -67,9 +67,14 @@ public class CourseManageController {
@AnonymousAccess
@ApiOperation("编辑课程/启用停用")
@PostMapping("updateSysOneCatalog")
public ResultEntity<String> updateSysOneCatalog(@ApiParam("课程链接必填,课程简介选填") @RequestBody SysOneCatalog sysOneCatalog) {
sysOneCatalogMapper.updateByPrimaryKey(sysOneCatalog);
return new ResultEntity<>(HttpStatus.OK, "编辑成功");
public ResultEntity<String> updateSysOneCatalog(@ApiParam("课程链接必填,课程简介选填,停用传0") @RequestBody SysOneCatalog sysOneCatalog) {
try {
sysOneCatalogMapper.updateByPrimaryKey(sysOneCatalog);
return new ResultEntity<>(HttpStatus.OK, "编辑成功");
} catch (Exception e) {
e.printStackTrace();
return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR, "编辑失败,请联系管理员");
}
}
@ -93,6 +98,11 @@ public class CourseManageController {
SysResourceAndCourseExample example = new SysResourceAndCourseExample();
example.createCriteria().andOneIdEqualTo(oneId);
sysResourceAndCourseMapper.deleteByExample(example);
//删除课程题目的绑定关系
SysTopicAndCourseExample example1 = new SysTopicAndCourseExample();
example1.createCriteria().andOneIdEqualTo(oneId);
sysTopicAndCourseMapper.deleteByExample(example1);
return new ResultEntity<>(HttpStatus.OK, "删除成功");
}

@ -130,27 +130,34 @@ public class CourseTagManageController {
@PostMapping("deleteTwoAndThreeCatalog")
public ResultEntity<String> deleteTwoAndThreeCatalog(@ApiParam("二级目录传2/三级传3") @RequestParam int type,
@RequestParam String id) {
if (type == 2) {
//删除资源
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
example1.createCriteria().andTwoIdEqualTo(id);
sysResourceAndCourseMapper.deleteByExample(example1);
//删除题目
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andTwoIdEqualTo(id);
sysTopicAndCourseMapper.deleteByExample(example);
} else {
//删除资源
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
example1.createCriteria().andThreeIdEqualTo(id);
sysResourceAndCourseMapper.deleteByExample(example1);
//删除题目
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andThreeIdEqualTo(id);
sysTopicAndCourseMapper.deleteByExample(example);
sysThreeCatalogMapper.deleteByPrimaryKey(id);
try {
if (type == 2) {
sysTwoCatalogMapper.deleteByPrimaryKey(id);
//删除资源
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
example1.createCriteria().andTwoIdEqualTo(id);
sysResourceAndCourseMapper.deleteByExample(example1);
//删除题目
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andTwoIdEqualTo(id);
sysTopicAndCourseMapper.deleteByExample(example);
} else {
sysThreeCatalogMapper.deleteByPrimaryKey(id);
//删除资源
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
example1.createCriteria().andThreeIdEqualTo(id);
sysResourceAndCourseMapper.deleteByExample(example1);
//删除题目
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andThreeIdEqualTo(id);
sysTopicAndCourseMapper.deleteByExample(example);
sysThreeCatalogMapper.deleteByPrimaryKey(id);
}
} catch (Exception e) {
e.printStackTrace();
return new ResultEntity<>(HttpStatus.INTERNAL_SERVER_ERROR,"删除失败,请联系管理员");
}
return new ResultEntity<>(HttpStatus.OK, "删除成功");
}

@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.resource_center.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.SysResource;
import com.sztzjy.resource_center.entity.SysResourceAndCourseExample;
import com.sztzjy.resource_center.entity.dto.SysResourceDto;
import com.sztzjy.resource_center.mapper.SysResourceAndCourseMapper;
import com.sztzjy.resource_center.mapper.SysResourceMapper;
import com.sztzjy.resource_center.util.ResultEntity;
import com.sztzjy.resource_center.util.file.IFileUtil;
@ -38,7 +40,8 @@ public class LearningResourceController {
private String filePath;
@Autowired
private IFileUtil fileUtil;
@Autowired
private SysResourceAndCourseMapper sysResourceAndCourseMapper;
@AnonymousAccess
@ApiOperation("学习资源/资源列表展示/有重复数据")
@ -61,6 +64,9 @@ public class LearningResourceController {
@PostMapping("deleteResource")
public ResultEntity<String> deleteResource(@ApiParam("来源是学校的不允许传过来") @RequestParam String id) {
sysResourceMapper.deleteByPrimaryKey(id);
SysResourceAndCourseExample example = new SysResourceAndCourseExample();
example.createCriteria().andResourceIdEqualTo(id);
sysResourceAndCourseMapper.deleteByExample(example);
return new ResultEntity<>(HttpStatus.OK, "删除成功!");
}

@ -9,8 +9,7 @@ import com.sztzjy.resource_center.entity.SysObjectiveQuestionsExample;
import com.sztzjy.resource_center.entity.SysTopicAndCourse;
import com.sztzjy.resource_center.entity.SysTopicAndCourseExample;
import com.sztzjy.resource_center.entity.dto.SysObjectiveQuestionsDto;
import com.sztzjy.resource_center.mapper.SysObjectiveQuestionsMapper;
import com.sztzjy.resource_center.mapper.SysTopicAndCourseMapper;
import com.sztzjy.resource_center.mapper.*;
import com.sztzjy.resource_center.util.ResultEntity;
import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api;
@ -39,7 +38,8 @@ import java.util.*;
@RestController
@RequestMapping("api/sys/topic/resource")
public class TopicResourceController {
@Autowired
SysOneCatalogMapper oneCatalogMapper;
@Autowired
private SysObjectiveQuestionsMapper sysObjectiveQuestionMapper;
@Autowired
@ -48,7 +48,10 @@ public class TopicResourceController {
IFileUtil fileUtil;
@Value("${file.path}")
private String filePath;
@Autowired
private SysTwoCatalogMapper sysTwoCatalogMapper;
@Autowired
private SysThreeCatalogMapper sysThreeCatalogMapper;
@AnonymousAccess
@ApiOperation("新增单个试题") //新增 题干不允许重复
@ -292,9 +295,17 @@ public class TopicResourceController {
//如果是老师增加 则只需要提供课程信息
public ResultEntity<HttpStatus> insertObjectiveByExcel(MultipartFile file, String source) throws IOException, InvalidFormatException {
List<SysObjectiveQuestions> objectiveQuestionList = new ArrayList<>();
List<SysTopicAndCourse> topicAndCourseList = new ArrayList<>();
Workbook workbook = WorkbookFactory.create(file.getInputStream());
Sheet sheet = workbook.getSheetAt(0);
//创建三级的ID和名称Map
Map<String, String> oneIdMap = new HashMap<>();
Map<String, String> twoIdMap = new HashMap<>();
Map<String, String> threeIdMap = new HashMap<>();
// 迭代每一行
Iterator<Row> iterator = sheet.iterator();
iterator.next();
@ -312,6 +323,10 @@ public class TopicResourceController {
Cell cell7 = row.getCell(7);
Cell cell8 = row.getCell(8);
Cell cell9 = row.getCell(9);
Cell cell10 = row.getCell(10);
Cell cell11 = row.getCell(11);
Cell cell12 = row.getCell(12);
//判断题的BCDE选项和解析可能为空
if (cell0 == null || cell1 == null || cell2 == null || cell6 == null || cell7 == null || cell9 == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "必填项不能为空");
@ -323,6 +338,9 @@ public class TopicResourceController {
String type = this.getCellValue(cell6);//题型
String answer = this.getCellValue(cell7);//答案
String score = this.getCellValue(cell9);//分值
String oneName = this.getCellValue(cell10);//一级目录名称
String twoName = this.getCellValue(cell11);//二级目录名称
String threeName = this.getCellValue(cell12);//三级目录名称
String c = cell3 != null ? this.getCellValue(cell3) : null;
String d = cell4 != null ? this.getCellValue(cell4) : null;
String e = cell5 != null ? this.getCellValue(cell5) : null;
@ -330,7 +348,8 @@ public class TopicResourceController {
SysObjectiveQuestions obj = new SysObjectiveQuestions();
obj.setObjectiveId(String.valueOf(UUID.randomUUID()));
String topicId = IdUtil.randomUUID();
obj.setObjectiveId(topicId);
obj.setContent(content);
obj.setType(type);
obj.setSource(source);
@ -345,7 +364,51 @@ public class TopicResourceController {
obj.setCreateTime(new Date());
obj.setIsDelete(false);
objectiveQuestionList.add(obj);
//判断名称是否被查出来过
String oneId = oneIdMap.get(oneName);
if (oneId == null) {
oneId = oneCatalogMapper.getIdByName(oneName);
if (oneId == null) {
return new ResultEntity<HttpStatus>(HttpStatus.INTERNAL_SERVER_ERROR, "导入关联的系统不存在,请在添加后重新导入");
}
oneIdMap.put(oneName, oneId);
}
String twoId = twoIdMap.get(twoName);
if (twoId == null) {
twoId = sysTwoCatalogMapper.getIdByName(twoName);
if (twoId == null) {
return new ResultEntity<HttpStatus>(HttpStatus.INTERNAL_SERVER_ERROR, "导入关联的课程不存在,请在添加后重新导入");
}
twoIdMap.put(twoName, twoId);
}
String threeId = threeIdMap.get(threeName);
if (threeId == null) {
threeId = sysThreeCatalogMapper.getIdByName(twoName, threeName);
if (threeId==null){
return new ResultEntity<HttpStatus>(HttpStatus.INTERNAL_SERVER_ERROR,"导入关联的章节不存在,请在添加后重新导入");
}
threeIdMap.put(threeName, threeId);
}
SysTopicAndCourse sysTopicAndCourse = new SysTopicAndCourse();
sysTopicAndCourse.setId(IdUtil.randomUUID());
sysTopicAndCourse.setTopicId(topicId);
sysTopicAndCourse.setTopicType("0");
sysTopicAndCourse.setOneName(oneName);
sysTopicAndCourse.setOneId(oneId);
sysTopicAndCourse.setTwoName(twoName);
sysTopicAndCourse.setTwoId(twoId);
sysTopicAndCourse.setThreeId(threeId);
sysTopicAndCourse.setThreeName(threeName);
topicAndCourseList.add(sysTopicAndCourse);
}
sysTopicAndCourseMapper.batchInsert(topicAndCourseList);
int result = sysObjectiveQuestionMapper.insertBatch(objectiveQuestionList);
if (result > 0) {
return new ResultEntity<>(HttpStatus.OK, "批量导入成功!");

@ -40,6 +40,8 @@ public class CaseApi {
@PostMapping("insertCase")
public Boolean insertCase(@ApiParam("目前二级三级ID可以为空来源和题型要传,上架状态传true") @RequestBody SysCaseQuestion sysCaseQuestion) {
SysOneCatalog sysOneCatalogs1 = getSysOneCatalogs(sysCaseQuestion.getOneName());
String oneId = sysOneCatalogs1.getOneId();
if (("3").equals(sysCaseQuestion.getType())) {
return false;
}
@ -54,7 +56,7 @@ public class CaseApi {
}
String title = sysCaseQuestion.getTitle();
SysCaseQuestionExample example = new SysCaseQuestionExample();
example.createCriteria().andTitleEqualTo(title).andUnmountStatusEqualTo(false).andOneIdEqualTo(sysOneCatalogs1.getOneId());
example.createCriteria().andTitleEqualTo(title).andUnmountStatusEqualTo(false).andOneIdEqualTo(oneId);
List<SysCaseQuestion> sysCaseQuestions = caseQuestionMapper.selectByExample(example);
if (!sysCaseQuestions.isEmpty()) {
return false;
@ -70,9 +72,8 @@ public class CaseApi {
sysTopicAndCourse.setId(IdUtil.randomUUID());
sysTopicAndCourse.setTopicType("1");
sysTopicAndCourse.setTopicId(uuid);
String oneId = sysOneCatalogs1.getOneId();
sysTopicAndCourse.setOneId(oneId);
sysTopicAndCourse.setOneName(sysCaseQuestion.getOneName());
sysTopicAndCourse.setOneName(sysOneCatalogs1.getOneName());
if (StringUtils.isNotBlank(sysCaseQuestion.getTwoId())) {
sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId());
sysTopicAndCourse.setTwoName(sysCaseQuestion.getTwoName());
@ -389,11 +390,8 @@ public class CaseApi {
@PostMapping("selectAllStepBySystemOwner")
public List<SysCaseQuestionStepWithBLOBs> selectAllStepBySystemOwner(@RequestParam String systemOwner) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
List<String> ids = topicAndCourseMapper.getCaseIdsBySourceIsAdmin(sysOneCatalogs.getOneId());
SysCaseQuestionStepExample example1 = new SysCaseQuestionStepExample();
example1.createCriteria().andCaseIdIn(ids);
return caseQuestionStepMapper.selectByExampleWithBLOBs(example1);
return caseQuestionStepMapper.getCaseStepByIds(ids);
}
@ -412,9 +410,9 @@ public class CaseApi {
chapterIdList.add(chapter.getThreeId());
}
List<Map<String, Object>> results = caseQuestionMapper.selectCaseIdByCourseAndChapterIds(courseIdList, chapterIdList);
List<Map<String, Object>> results = topicAndCourseMapper.selectCaseIdByCourseAndChapterIds(courseIdList, chapterIdList);
for (Map<String, Object> result : results) {
String chapterId = (String) result.get("chapter_id");
String chapterId = (String) result.get("three_id");
String caseId = (String) result.get("case_id");
if (!caseIdMap.containsKey(chapterId)) {
caseIdMap.put(chapterId, new ArrayList<>());

@ -5,9 +5,7 @@ import com.github.pagehelper.PageInfo;
import com.sztzjy.resource_center.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.*;
import com.sztzjy.resource_center.entity.dto.SysObjectiveQuestionsDto;
import com.sztzjy.resource_center.mapper.SysObjectiveQuestionsMapper;
import com.sztzjy.resource_center.mapper.SysOneCatalogMapper;
import com.sztzjy.resource_center.mapper.SysTopicAndCourseMapper;
import com.sztzjy.resource_center.mapper.*;
import com.sztzjy.resource_center.util.PageUtil;
import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api;
@ -19,6 +17,7 @@ import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -42,7 +41,10 @@ public class ObjectiveApi {
IFileUtil fileUtil;
@Value("${file.path}")
private String filePath;
@Autowired
private SysTwoCatalogMapper sysTwoCatalogMapper;
@Autowired
private SysThreeCatalogMapper sysThreeCatalogMapper;
private SysOneCatalog getSysOneCatalogs(String systemOwner) {
SysOneCatalogExample example = new SysOneCatalogExample();
@ -252,8 +254,9 @@ public class ObjectiveApi {
@AnonymousAccess
@ApiOperation("本地excel导入试题")
@PostMapping("insertObjectiveByExcel")
private Boolean importTopicByLocal(@RequestParam MultipartFile file,
@RequestParam String schoolId) throws IOException, InvalidFormatException {
@Transactional
Boolean importTopicByLocal(@RequestParam MultipartFile file,
@RequestParam String schoolId) throws IOException, InvalidFormatException {
if (file == null) {
return false;
}
@ -264,9 +267,17 @@ public class ObjectiveApi {
//如果是老师增加 则只需要提供课程信息
public Boolean insertObjectiveByExcel(MultipartFile file, String schoolId) throws IOException, InvalidFormatException {
List<SysObjectiveQuestions> objectiveQuestionList = new ArrayList<>();
List<SysTopicAndCourse> topicAndCourseList = new ArrayList<>();
Workbook workbook = WorkbookFactory.create(file.getInputStream());
Sheet sheet = workbook.getSheetAt(0);
//创建三级的ID和名称Map
Map<String, String> oneIdMap = new HashMap<>();
Map<String, String> twoIdMap = new HashMap<>();
Map<String, String> threeIdMap = new HashMap<>();
// 迭代每一行
Iterator<Row> iterator = sheet.iterator();
iterator.next();
@ -284,6 +295,9 @@ public class ObjectiveApi {
Cell cell7 = row.getCell(7);
Cell cell8 = row.getCell(8);
Cell cell9 = row.getCell(9);
Cell cell10 = row.getCell(10);
Cell cell11 = row.getCell(11);
Cell cell12 = row.getCell(12);
//判断题的BCDE选项和解析可能为空
if (cell0 == null || cell1 == null || cell2 == null || cell6 == null || cell7 == null || cell9 == null) {
return false;
@ -295,6 +309,9 @@ public class ObjectiveApi {
String type = this.getCellValue(cell6);//题型
String answer = this.getCellValue(cell7);//答案
String score = this.getCellValue(cell9);//分值
String oneName = this.getCellValue(cell10);//一级目录名称
String twoName = this.getCellValue(cell11);//二级目录名称
String threeName = this.getCellValue(cell12);//三级目录名称
String c = cell3 != null ? this.getCellValue(cell3) : null;
String d = cell4 != null ? this.getCellValue(cell4) : null;
String e = cell5 != null ? this.getCellValue(cell5) : null;
@ -302,7 +319,8 @@ public class ObjectiveApi {
SysObjectiveQuestions obj = new SysObjectiveQuestions();
obj.setObjectiveId(String.valueOf(UUID.randomUUID()));
String topicId = IdUtil.randomUUID();
obj.setObjectiveId(topicId);
obj.setContent(content);
obj.setType(type);
obj.setSource(schoolId);
@ -317,7 +335,40 @@ public class ObjectiveApi {
obj.setCreateTime(new Date());
obj.setIsDelete(false);
objectiveQuestionList.add(obj);
//判断名称是否被查出来过
String oneId = oneIdMap.get(oneName);
if (oneId == null) {
oneId = oneCatalogMapper.getIdByName(oneName);
oneIdMap.put(oneName, oneId);
}
String twoId = twoIdMap.get(twoName);
if (twoId == null) {
twoId = sysTwoCatalogMapper.getIdByName(twoName);
twoIdMap.put(twoName, twoId);
}
String threeId = threeIdMap.get(threeName);
if (threeId == null) {
threeId = sysThreeCatalogMapper.getIdByName(threeName,twoName);
threeIdMap.put(threeName, threeId);
}
SysTopicAndCourse sysTopicAndCourse = new SysTopicAndCourse();
sysTopicAndCourse.setId(IdUtil.randomUUID());
sysTopicAndCourse.setTopicId(topicId);
sysTopicAndCourse.setTopicType("0");
sysTopicAndCourse.setOneName(oneName);
sysTopicAndCourse.setOneId(oneId);
sysTopicAndCourse.setTwoName(twoName);
sysTopicAndCourse.setTwoId(twoId);
sysTopicAndCourse.setThreeId(threeId);
sysTopicAndCourse.setThreeName(threeName);
topicAndCourseList.add(sysTopicAndCourse);
}
sysTopicAndCourseMapper.batchInsert(topicAndCourseList);
int result = sysObjectiveQuestionMapper.insertBatch(objectiveQuestionList);
if (result > 0) {
return true;

@ -288,6 +288,9 @@ public class ResourceApi {
if (!sysResource.getSource().equals(source)) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "删除失败!");
}
SysResourceAndCourseExample example = new SysResourceAndCourseExample();
example.createCriteria().andResourceIdEqualTo(id);
sysResourceAndCourseMapper.deleteByExample(example);
sysResourceMapper.deleteByPrimaryKey(id);
return new ResultEntity<>(HttpStatus.OK, "删除成功!");
}

@ -39,8 +39,8 @@ public class SysKnowledgeSummaryApi {
@AnonymousAccess
@ApiOperation("getSysKnowledgeSummary")
@PostMapping("uploadResourceData")
@ApiOperation("获取知识概要")
@PostMapping("getSysKnowledgeSummary")
private SysKnowledgeSummary getSysKnowledgeSummary(@RequestParam String schoolId,
@RequestParam String systemOwner,
@RequestParam String courseId,

@ -28,16 +28,19 @@ public class SysCaseQuestion {
@ApiModelProperty("一级目录ID")
private String oneId;
@ApiModelProperty("一级名称")
private String oneName;
@ApiModelProperty("二级目录ID")
private String twoId;
@ApiModelProperty("二级名称")
private String twoName;
@ApiModelProperty("三级目录ID")
private String threeId;
@ApiModelProperty("三级名称")
private String threeName;
@ApiModelProperty("上下架状态")

@ -43,6 +43,4 @@ public interface SysCaseQuestionMapper {
@Param("source") String source);
List<SysCaseQuestion> selectCaseByConditionsByBind(@Param("title") String title);
List<Map<String, Object>> selectCaseIdByCourseAndChapterIds(@Param("courseIdList") List<String> courseIdList, @Param("chapterIdList") List<String> chapterIdList);
}

@ -43,4 +43,6 @@ public interface SysCaseQuestionStepMapper {
@Param("oneId") String oneId);
List<TrainingDto> selectTrainingByIds(@Param("list") List<String> caseStepIdList);
List<SysCaseQuestionStepWithBLOBs> getCaseStepByIds(@Param("ids") List<String> ids);
}

@ -37,4 +37,7 @@ public interface SysOneCatalogMapper {
List<Map<String, String>> getAllOneCatalogListByDropDown();
void updateByBatch(@Param("sysOneCatalogs") List<SysOneCatalog> sysOneCatalogs);
@Select("select one_id from sys_one_catalog where one_name =#{name}")
String getIdByName(@Param("name") String oneName);
}

@ -48,4 +48,8 @@ public interface SysThreeCatalogMapper {
"where s.creator in ('管理员',#{source})")
List<String> selectNameByCourseID(@Param("oneId") String oneId,
@Param("source") String source);
@Select("select three_id from sys_three_catalog where three_name =#{threeName} and two_name ={twoName}")
String getIdByName(@Param("threeName") String threeName,
@Param("twoName") String twoName);
}

@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
@Mapper
public interface SysTopicAndCourseMapper {
@ -44,4 +45,6 @@ public interface SysTopicAndCourseMapper {
@Select("select sq.case_id from sys_topic_and_course sc LEFT JOIN sys_case_questions sq on sc.topic_id = sq.case_id where sq.source = '管理员' and sc.one_id = #{oneId}")
List<String> getCaseIdsBySourceIsAdmin(@Param("oneId") String oneId);
List<Map<String, Object>> selectCaseIdByCourseAndChapterIds(@Param("courseIdList") List<String> courseIdList, @Param("chapterIdList") List<String> chapterIdList);
}

@ -36,4 +36,7 @@ public interface SysTwoCatalogMapper {
List<Map<String, String>> getAllTwoCatalogList(@Param("oneId")String oneId);
void updateByBatch(@Param("sysTwoCatalogs")List<SysTwoCatalog> sysTwoCatalogs);
@Select("select two_id from sys_two_catalog where two_name =#{twoName}")
String getIdByName(String twoName);
}

@ -458,7 +458,8 @@
<!--条件查询加绑定关系,有重复数据-->
<select id="selectCaseByConditionsByBind" parameterType="java.lang.String" resultMap="BaseResultMap">
select st.one_id,st.one_name,st.two_id,st.two_name,st.three_id,st.three_name,s.case_id,s.title,s.content,s.resource_data,s.source,s.type,s.unmount_status,s.create_time,s.update_time
select st.one_id,st.one_name,st.two_id,st.two_name,st.three_id,st.three_name,
s.case_id,s.title,s.content,s.resource_data,s.source,s.type,s.unmount_status,s.create_time,s.update_time
from sys_case_questions s
left join sys_topic_and_course st
on s.case_id = st.topic_id
@ -470,17 +471,4 @@
</where>
order by s.create_time
</select>
<select id="selectCaseIdByCourseAndChapterIds" resultType="map">
SELECT chapter_id, case_id
FROM sys_case_question
WHERE course_id IN
<foreach collection="courseIdList" item="courseId" open="(" separator="," close=")">
#{courseId}
</foreach>
AND chapter_id IN
<foreach collection="chapterIdList" item="chapterId" open="(" separator="," close=")">
#{chapterId}
</foreach>
</select>
</mapper>

@ -432,5 +432,12 @@
GROUP BY sq.title, s3.three_name,sqs.case_id;
</select>
<select id="getCaseStepByIds" resultMap="ResultMapWithBLOBs">
SELECT title,case_step_id,case_id,sort,score
FROM sys_case_question_steps
where case_id in
<foreach item="item" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>

@ -328,4 +328,21 @@
#{id}
</foreach>
</update>
<select id="selectCaseIdByCourseAndChapterIds" resultType="map">
SELECT sc.three_id, s.case_id
FROM sys_topic_and_course sc
join sys_case_questions s on sc.topic_id = s.case_id
WHERE sc.two_id IN
<foreach collection="courseIdList" item="twoId" open="(" separator="," close=")">
#{twoId}
</foreach>
AND sc.three_id IN
<foreach collection="chapterIdList" item="threeId" open="(" separator="," close=")">
#{threeId}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save