修改接口

master
xiaoCJ 8 months ago
parent c0fe06b160
commit 2435a7b7e1

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

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

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

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

@ -130,27 +130,34 @@ public class CourseTagManageController {
@PostMapping("deleteTwoAndThreeCatalog") @PostMapping("deleteTwoAndThreeCatalog")
public ResultEntity<String> deleteTwoAndThreeCatalog(@ApiParam("二级目录传2/三级传3") @RequestParam int type, public ResultEntity<String> deleteTwoAndThreeCatalog(@ApiParam("二级目录传2/三级传3") @RequestParam int type,
@RequestParam String id) { @RequestParam String id) {
if (type == 2) { try {
//删除资源 if (type == 2) {
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample(); sysTwoCatalogMapper.deleteByPrimaryKey(id);
example1.createCriteria().andTwoIdEqualTo(id); //删除资源
sysResourceAndCourseMapper.deleteByExample(example1); SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
example1.createCriteria().andTwoIdEqualTo(id);
//删除题目 sysResourceAndCourseMapper.deleteByExample(example1);
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
example.createCriteria().andTwoIdEqualTo(id); //删除题目
sysTopicAndCourseMapper.deleteByExample(example); SysTopicAndCourseExample example = new SysTopicAndCourseExample();
} else { example.createCriteria().andTwoIdEqualTo(id);
//删除资源 sysTopicAndCourseMapper.deleteByExample(example);
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample(); } else {
example1.createCriteria().andThreeIdEqualTo(id); sysThreeCatalogMapper.deleteByPrimaryKey(id);
sysResourceAndCourseMapper.deleteByExample(example1); //删除资源
SysResourceAndCourseExample example1 = new SysResourceAndCourseExample();
//删除题目 example1.createCriteria().andThreeIdEqualTo(id);
SysTopicAndCourseExample example = new SysTopicAndCourseExample(); sysResourceAndCourseMapper.deleteByExample(example1);
example.createCriteria().andThreeIdEqualTo(id);
sysTopicAndCourseMapper.deleteByExample(example); //删除题目
sysThreeCatalogMapper.deleteByPrimaryKey(id); 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, "删除成功"); return new ResultEntity<>(HttpStatus.OK, "删除成功");
} }

@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.sztzjy.resource_center.annotation.AnonymousAccess; import com.sztzjy.resource_center.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.SysResource; 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.entity.dto.SysResourceDto;
import com.sztzjy.resource_center.mapper.SysResourceAndCourseMapper;
import com.sztzjy.resource_center.mapper.SysResourceMapper; import com.sztzjy.resource_center.mapper.SysResourceMapper;
import com.sztzjy.resource_center.util.ResultEntity; import com.sztzjy.resource_center.util.ResultEntity;
import com.sztzjy.resource_center.util.file.IFileUtil; import com.sztzjy.resource_center.util.file.IFileUtil;
@ -38,7 +40,8 @@ public class LearningResourceController {
private String filePath; private String filePath;
@Autowired @Autowired
private IFileUtil fileUtil; private IFileUtil fileUtil;
@Autowired
private SysResourceAndCourseMapper sysResourceAndCourseMapper;
@AnonymousAccess @AnonymousAccess
@ApiOperation("学习资源/资源列表展示/有重复数据") @ApiOperation("学习资源/资源列表展示/有重复数据")
@ -61,6 +64,9 @@ public class LearningResourceController {
@PostMapping("deleteResource") @PostMapping("deleteResource")
public ResultEntity<String> deleteResource(@ApiParam("来源是学校的不允许传过来") @RequestParam String id) { public ResultEntity<String> deleteResource(@ApiParam("来源是学校的不允许传过来") @RequestParam String id) {
sysResourceMapper.deleteByPrimaryKey(id); sysResourceMapper.deleteByPrimaryKey(id);
SysResourceAndCourseExample example = new SysResourceAndCourseExample();
example.createCriteria().andResourceIdEqualTo(id);
sysResourceAndCourseMapper.deleteByExample(example);
return new ResultEntity<>(HttpStatus.OK, "删除成功!"); 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.SysTopicAndCourse;
import com.sztzjy.resource_center.entity.SysTopicAndCourseExample; import com.sztzjy.resource_center.entity.SysTopicAndCourseExample;
import com.sztzjy.resource_center.entity.dto.SysObjectiveQuestionsDto; import com.sztzjy.resource_center.entity.dto.SysObjectiveQuestionsDto;
import com.sztzjy.resource_center.mapper.SysObjectiveQuestionsMapper; import com.sztzjy.resource_center.mapper.*;
import com.sztzjy.resource_center.mapper.SysTopicAndCourseMapper;
import com.sztzjy.resource_center.util.ResultEntity; import com.sztzjy.resource_center.util.ResultEntity;
import com.sztzjy.resource_center.util.file.IFileUtil; import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -39,7 +38,8 @@ import java.util.*;
@RestController @RestController
@RequestMapping("api/sys/topic/resource") @RequestMapping("api/sys/topic/resource")
public class TopicResourceController { public class TopicResourceController {
@Autowired
SysOneCatalogMapper oneCatalogMapper;
@Autowired @Autowired
private SysObjectiveQuestionsMapper sysObjectiveQuestionMapper; private SysObjectiveQuestionsMapper sysObjectiveQuestionMapper;
@Autowired @Autowired
@ -48,7 +48,10 @@ public class TopicResourceController {
IFileUtil fileUtil; IFileUtil fileUtil;
@Value("${file.path}") @Value("${file.path}")
private String filePath; private String filePath;
@Autowired
private SysTwoCatalogMapper sysTwoCatalogMapper;
@Autowired
private SysThreeCatalogMapper sysThreeCatalogMapper;
@AnonymousAccess @AnonymousAccess
@ApiOperation("新增单个试题") //新增 题干不允许重复 @ApiOperation("新增单个试题") //新增 题干不允许重复
@ -292,9 +295,17 @@ public class TopicResourceController {
//如果是老师增加 则只需要提供课程信息 //如果是老师增加 则只需要提供课程信息
public ResultEntity<HttpStatus> insertObjectiveByExcel(MultipartFile file, String source) throws IOException, InvalidFormatException { public ResultEntity<HttpStatus> insertObjectiveByExcel(MultipartFile file, String source) throws IOException, InvalidFormatException {
List<SysObjectiveQuestions> objectiveQuestionList = new ArrayList<>(); List<SysObjectiveQuestions> objectiveQuestionList = new ArrayList<>();
List<SysTopicAndCourse> topicAndCourseList = new ArrayList<>();
Workbook workbook = WorkbookFactory.create(file.getInputStream()); Workbook workbook = WorkbookFactory.create(file.getInputStream());
Sheet sheet = workbook.getSheetAt(0); 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<Row> iterator = sheet.iterator();
iterator.next(); iterator.next();
@ -312,6 +323,10 @@ public class TopicResourceController {
Cell cell7 = row.getCell(7); Cell cell7 = row.getCell(7);
Cell cell8 = row.getCell(8); Cell cell8 = row.getCell(8);
Cell cell9 = row.getCell(9); Cell cell9 = row.getCell(9);
Cell cell10 = row.getCell(10);
Cell cell11 = row.getCell(11);
Cell cell12 = row.getCell(12);
//判断题的BCDE选项和解析可能为空 //判断题的BCDE选项和解析可能为空
if (cell0 == null || cell1 == null || cell2 == null || cell6 == null || cell7 == null || cell9 == null) { if (cell0 == null || cell1 == null || cell2 == null || cell6 == null || cell7 == null || cell9 == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "必填项不能为空"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "必填项不能为空");
@ -323,6 +338,9 @@ public class TopicResourceController {
String type = this.getCellValue(cell6);//题型 String type = this.getCellValue(cell6);//题型
String answer = this.getCellValue(cell7);//答案 String answer = this.getCellValue(cell7);//答案
String score = this.getCellValue(cell9);//分值 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 c = cell3 != null ? this.getCellValue(cell3) : null;
String d = cell4 != null ? this.getCellValue(cell4) : null; String d = cell4 != null ? this.getCellValue(cell4) : null;
String e = cell5 != null ? this.getCellValue(cell5) : null; String e = cell5 != null ? this.getCellValue(cell5) : null;
@ -330,7 +348,8 @@ public class TopicResourceController {
SysObjectiveQuestions obj = new SysObjectiveQuestions(); SysObjectiveQuestions obj = new SysObjectiveQuestions();
obj.setObjectiveId(String.valueOf(UUID.randomUUID())); String topicId = IdUtil.randomUUID();
obj.setObjectiveId(topicId);
obj.setContent(content); obj.setContent(content);
obj.setType(type); obj.setType(type);
obj.setSource(source); obj.setSource(source);
@ -345,7 +364,51 @@ public class TopicResourceController {
obj.setCreateTime(new Date()); obj.setCreateTime(new Date());
obj.setIsDelete(false); obj.setIsDelete(false);
objectiveQuestionList.add(obj); 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); int result = sysObjectiveQuestionMapper.insertBatch(objectiveQuestionList);
if (result > 0) { if (result > 0) {
return new ResultEntity<>(HttpStatus.OK, "批量导入成功!"); return new ResultEntity<>(HttpStatus.OK, "批量导入成功!");

@ -40,6 +40,8 @@ public class CaseApi {
@PostMapping("insertCase") @PostMapping("insertCase")
public Boolean insertCase(@ApiParam("目前二级三级ID可以为空来源和题型要传,上架状态传true") @RequestBody SysCaseQuestion sysCaseQuestion) { public Boolean insertCase(@ApiParam("目前二级三级ID可以为空来源和题型要传,上架状态传true") @RequestBody SysCaseQuestion sysCaseQuestion) {
SysOneCatalog sysOneCatalogs1 = getSysOneCatalogs(sysCaseQuestion.getOneName()); SysOneCatalog sysOneCatalogs1 = getSysOneCatalogs(sysCaseQuestion.getOneName());
String oneId = sysOneCatalogs1.getOneId();
if (("3").equals(sysCaseQuestion.getType())) { if (("3").equals(sysCaseQuestion.getType())) {
return false; return false;
} }
@ -54,7 +56,7 @@ public class CaseApi {
} }
String title = sysCaseQuestion.getTitle(); String title = sysCaseQuestion.getTitle();
SysCaseQuestionExample example = new SysCaseQuestionExample(); 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); List<SysCaseQuestion> sysCaseQuestions = caseQuestionMapper.selectByExample(example);
if (!sysCaseQuestions.isEmpty()) { if (!sysCaseQuestions.isEmpty()) {
return false; return false;
@ -70,9 +72,8 @@ public class CaseApi {
sysTopicAndCourse.setId(IdUtil.randomUUID()); sysTopicAndCourse.setId(IdUtil.randomUUID());
sysTopicAndCourse.setTopicType("1"); sysTopicAndCourse.setTopicType("1");
sysTopicAndCourse.setTopicId(uuid); sysTopicAndCourse.setTopicId(uuid);
String oneId = sysOneCatalogs1.getOneId();
sysTopicAndCourse.setOneId(oneId); sysTopicAndCourse.setOneId(oneId);
sysTopicAndCourse.setOneName(sysCaseQuestion.getOneName()); sysTopicAndCourse.setOneName(sysOneCatalogs1.getOneName());
if (StringUtils.isNotBlank(sysCaseQuestion.getTwoId())) { if (StringUtils.isNotBlank(sysCaseQuestion.getTwoId())) {
sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId()); sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId());
sysTopicAndCourse.setTwoName(sysCaseQuestion.getTwoName()); sysTopicAndCourse.setTwoName(sysCaseQuestion.getTwoName());
@ -389,11 +390,8 @@ public class CaseApi {
@PostMapping("selectAllStepBySystemOwner") @PostMapping("selectAllStepBySystemOwner")
public List<SysCaseQuestionStepWithBLOBs> selectAllStepBySystemOwner(@RequestParam String systemOwner) { public List<SysCaseQuestionStepWithBLOBs> selectAllStepBySystemOwner(@RequestParam String systemOwner) {
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner); SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
List<String> ids = topicAndCourseMapper.getCaseIdsBySourceIsAdmin(sysOneCatalogs.getOneId()); List<String> ids = topicAndCourseMapper.getCaseIdsBySourceIsAdmin(sysOneCatalogs.getOneId());
SysCaseQuestionStepExample example1 = new SysCaseQuestionStepExample(); return caseQuestionStepMapper.getCaseStepByIds(ids);
example1.createCriteria().andCaseIdIn(ids);
return caseQuestionStepMapper.selectByExampleWithBLOBs(example1);
} }
@ -412,9 +410,9 @@ public class CaseApi {
chapterIdList.add(chapter.getThreeId()); 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) { 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"); String caseId = (String) result.get("case_id");
if (!caseIdMap.containsKey(chapterId)) { if (!caseIdMap.containsKey(chapterId)) {
caseIdMap.put(chapterId, new ArrayList<>()); 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.annotation.AnonymousAccess;
import com.sztzjy.resource_center.entity.*; import com.sztzjy.resource_center.entity.*;
import com.sztzjy.resource_center.entity.dto.SysObjectiveQuestionsDto; import com.sztzjy.resource_center.entity.dto.SysObjectiveQuestionsDto;
import com.sztzjy.resource_center.mapper.SysObjectiveQuestionsMapper; import com.sztzjy.resource_center.mapper.*;
import com.sztzjy.resource_center.mapper.SysOneCatalogMapper;
import com.sztzjy.resource_center.mapper.SysTopicAndCourseMapper;
import com.sztzjy.resource_center.util.PageUtil; import com.sztzjy.resource_center.util.PageUtil;
import com.sztzjy.resource_center.util.file.IFileUtil; import com.sztzjy.resource_center.util.file.IFileUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -19,6 +17,7 @@ import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -42,7 +41,10 @@ public class ObjectiveApi {
IFileUtil fileUtil; IFileUtil fileUtil;
@Value("${file.path}") @Value("${file.path}")
private String filePath; private String filePath;
@Autowired
private SysTwoCatalogMapper sysTwoCatalogMapper;
@Autowired
private SysThreeCatalogMapper sysThreeCatalogMapper;
private SysOneCatalog getSysOneCatalogs(String systemOwner) { private SysOneCatalog getSysOneCatalogs(String systemOwner) {
SysOneCatalogExample example = new SysOneCatalogExample(); SysOneCatalogExample example = new SysOneCatalogExample();
@ -252,8 +254,9 @@ public class ObjectiveApi {
@AnonymousAccess @AnonymousAccess
@ApiOperation("本地excel导入试题") @ApiOperation("本地excel导入试题")
@PostMapping("insertObjectiveByExcel") @PostMapping("insertObjectiveByExcel")
private Boolean importTopicByLocal(@RequestParam MultipartFile file, @Transactional
@RequestParam String schoolId) throws IOException, InvalidFormatException { Boolean importTopicByLocal(@RequestParam MultipartFile file,
@RequestParam String schoolId) throws IOException, InvalidFormatException {
if (file == null) { if (file == null) {
return false; return false;
} }
@ -264,9 +267,17 @@ public class ObjectiveApi {
//如果是老师增加 则只需要提供课程信息 //如果是老师增加 则只需要提供课程信息
public Boolean insertObjectiveByExcel(MultipartFile file, String schoolId) throws IOException, InvalidFormatException { public Boolean insertObjectiveByExcel(MultipartFile file, String schoolId) throws IOException, InvalidFormatException {
List<SysObjectiveQuestions> objectiveQuestionList = new ArrayList<>(); List<SysObjectiveQuestions> objectiveQuestionList = new ArrayList<>();
List<SysTopicAndCourse> topicAndCourseList = new ArrayList<>();
Workbook workbook = WorkbookFactory.create(file.getInputStream()); Workbook workbook = WorkbookFactory.create(file.getInputStream());
Sheet sheet = workbook.getSheetAt(0); 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<Row> iterator = sheet.iterator();
iterator.next(); iterator.next();
@ -284,6 +295,9 @@ public class ObjectiveApi {
Cell cell7 = row.getCell(7); Cell cell7 = row.getCell(7);
Cell cell8 = row.getCell(8); Cell cell8 = row.getCell(8);
Cell cell9 = row.getCell(9); Cell cell9 = row.getCell(9);
Cell cell10 = row.getCell(10);
Cell cell11 = row.getCell(11);
Cell cell12 = row.getCell(12);
//判断题的BCDE选项和解析可能为空 //判断题的BCDE选项和解析可能为空
if (cell0 == null || cell1 == null || cell2 == null || cell6 == null || cell7 == null || cell9 == null) { if (cell0 == null || cell1 == null || cell2 == null || cell6 == null || cell7 == null || cell9 == null) {
return false; return false;
@ -295,6 +309,9 @@ public class ObjectiveApi {
String type = this.getCellValue(cell6);//题型 String type = this.getCellValue(cell6);//题型
String answer = this.getCellValue(cell7);//答案 String answer = this.getCellValue(cell7);//答案
String score = this.getCellValue(cell9);//分值 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 c = cell3 != null ? this.getCellValue(cell3) : null;
String d = cell4 != null ? this.getCellValue(cell4) : null; String d = cell4 != null ? this.getCellValue(cell4) : null;
String e = cell5 != null ? this.getCellValue(cell5) : null; String e = cell5 != null ? this.getCellValue(cell5) : null;
@ -302,7 +319,8 @@ public class ObjectiveApi {
SysObjectiveQuestions obj = new SysObjectiveQuestions(); SysObjectiveQuestions obj = new SysObjectiveQuestions();
obj.setObjectiveId(String.valueOf(UUID.randomUUID())); String topicId = IdUtil.randomUUID();
obj.setObjectiveId(topicId);
obj.setContent(content); obj.setContent(content);
obj.setType(type); obj.setType(type);
obj.setSource(schoolId); obj.setSource(schoolId);
@ -317,7 +335,40 @@ public class ObjectiveApi {
obj.setCreateTime(new Date()); obj.setCreateTime(new Date());
obj.setIsDelete(false); obj.setIsDelete(false);
objectiveQuestionList.add(obj); 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); int result = sysObjectiveQuestionMapper.insertBatch(objectiveQuestionList);
if (result > 0) { if (result > 0) {
return true; return true;

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

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

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

@ -43,6 +43,4 @@ public interface SysCaseQuestionMapper {
@Param("source") String source); @Param("source") String source);
List<SysCaseQuestion> selectCaseByConditionsByBind(@Param("title") String title); 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); @Param("oneId") String oneId);
List<TrainingDto> selectTrainingByIds(@Param("list") List<String> caseStepIdList); 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(); List<Map<String, String>> getAllOneCatalogListByDropDown();
void updateByBatch(@Param("sysOneCatalogs") List<SysOneCatalog> sysOneCatalogs); 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})") "where s.creator in ('管理员',#{source})")
List<String> selectNameByCourseID(@Param("oneId") String oneId, List<String> selectNameByCourseID(@Param("oneId") String oneId,
@Param("source") String source); @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 org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
import java.util.Map;
@Mapper @Mapper
public interface SysTopicAndCourseMapper { 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}") @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<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); List<Map<String, String>> getAllTwoCatalogList(@Param("oneId")String oneId);
void updateByBatch(@Param("sysTwoCatalogs")List<SysTwoCatalog> sysTwoCatalogs); 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 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 from sys_case_questions s
left join sys_topic_and_course st left join sys_topic_and_course st
on s.case_id = st.topic_id on s.case_id = st.topic_id
@ -470,17 +471,4 @@
</where> </where>
order by s.create_time order by s.create_time
</select> </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> </mapper>

@ -432,5 +432,12 @@
GROUP BY sq.title, s3.three_name,sqs.case_id; GROUP BY sq.title, s3.three_name,sqs.case_id;
</select> </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> </mapper>

@ -328,4 +328,21 @@
#{id} #{id}
</foreach> </foreach>
</update> </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> </mapper>
Loading…
Cancel
Save