|
|
|
@ -4,11 +4,10 @@ import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.sztzjy.resource_center.annotation.AnonymousAccess;
|
|
|
|
|
import com.sztzjy.resource_center.entity.SysCaseQuestion;
|
|
|
|
|
import com.sztzjy.resource_center.entity.SysCaseQuestionExample;
|
|
|
|
|
import com.sztzjy.resource_center.entity.SysTopicAndCourse;
|
|
|
|
|
import com.sztzjy.resource_center.entity.*;
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysCaseQuestionMapper;
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysCaseQuestionStepMapper;
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysOneCatalogMapper;
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysTopicAndCourseMapper;
|
|
|
|
|
import com.sztzjy.resource_center.util.ResultEntity;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
@ -21,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author xcj
|
|
|
|
@ -37,7 +37,8 @@ public class CaseController {
|
|
|
|
|
private SysCaseQuestionMapper caseQuestionMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysTopicAndCourseMapper topicAndCourseMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysOneCatalogMapper sysOneCatalogMapper;
|
|
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题新增")
|
|
|
|
@ -84,7 +85,7 @@ public class CaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题查询")
|
|
|
|
|
@ApiOperation("案例题页面查询")
|
|
|
|
|
@PostMapping("selectCaseByConditions")
|
|
|
|
|
public ResultEntity<PageInfo<SysCaseQuestion>> selectCaseByConditions(@RequestParam Integer index,
|
|
|
|
|
@RequestParam Integer size,
|
|
|
|
@ -96,26 +97,92 @@ public class CaseController {
|
|
|
|
|
return new ResultEntity<PageInfo<SysCaseQuestion>>(pageInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题详细内容展示")
|
|
|
|
|
@PostMapping("selectCaseByConditionsByID")
|
|
|
|
|
public ResultEntity<SysCaseQuestion> selectCaseByConditionsByID(@RequestParam String caseId) {
|
|
|
|
|
SysCaseQuestion sysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(caseId);
|
|
|
|
|
return new ResultEntity<SysCaseQuestion>(sysCaseQuestion);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//案例库自动同步课程配置新增的和老师新增的案例,老师新增的案例正在使用时只能查看,如果老师删除了这个案例,这个案例可以编辑删除。
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题编辑")
|
|
|
|
|
@PostMapping("updateCase")
|
|
|
|
|
public ResultEntity<HttpStatus> updateCase() {
|
|
|
|
|
return null;
|
|
|
|
|
public ResultEntity<HttpStatus> updateCase(@RequestBody SysCaseQuestion sysCaseQuestion,
|
|
|
|
|
@ApiParam("谁调的请求,传管理员/学校ID") @RequestParam String source) {
|
|
|
|
|
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId());
|
|
|
|
|
if (!sysTopicAndCourses.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例题正在被使用!");
|
|
|
|
|
} else {
|
|
|
|
|
//todo 管理员任意修改,老师只能改自己的
|
|
|
|
|
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
|
|
|
|
|
caseQuestionMapper.updateByPrimaryKey(sysCaseQuestion);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
|
|
|
|
|
} else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除案例时如果案例正在被使用则不能删除,提示该案例正在被xx课程xx章节使用,不能删除。
|
|
|
|
|
|
|
|
|
|
//删除案例时如果案例正在被使用,则不能删除,提示该案例正在被xx课程xx章节使用,不能删除。
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题删除")
|
|
|
|
|
@ApiOperation("案例题删除") //逻辑删除
|
|
|
|
|
@PostMapping("deleteCase")
|
|
|
|
|
public ResultEntity<HttpStatus> deleteCase() {
|
|
|
|
|
return null;
|
|
|
|
|
public ResultEntity<HttpStatus> deleteCase(@RequestBody SysCaseQuestion sysCaseQuestion,
|
|
|
|
|
@ApiParam("哪个用的掉的请求,传管理员/学校ID") @RequestParam String source) {
|
|
|
|
|
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId());
|
|
|
|
|
if (!sysTopicAndCourses.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "无法删除!该案例题正在被使用!");
|
|
|
|
|
} else {
|
|
|
|
|
//todo 管理员任意删除 老师只能删除自己上传的
|
|
|
|
|
if ("管理员".equals(source) || source.equals(sysCaseQuestion.getSource())) {
|
|
|
|
|
SysCaseQuestion dataSysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(sysCaseQuestion.getCaseId());
|
|
|
|
|
dataSysCaseQuestion.setUnmountStatus(true);
|
|
|
|
|
caseQuestionMapper.updateByPrimaryKey(dataSysCaseQuestion);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "编辑成功!");
|
|
|
|
|
} else {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<SysTopicAndCourse> getSysTopicAndCourses(String caseId) {
|
|
|
|
|
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
|
|
|
|
|
example.createCriteria().andTopicIdEqualTo(caseId).andTopicTypeEqualTo("1");
|
|
|
|
|
List<SysTopicAndCourse> sysTopicAndCourses = topicAndCourseMapper.selectByExample(example);
|
|
|
|
|
return sysTopicAndCourses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题添加步骤")
|
|
|
|
|
@PostMapping("insertCaseStepByCaseId")
|
|
|
|
|
public ResultEntity<HttpStatus> insertCaseStepByCaseId() {
|
|
|
|
|
return null;
|
|
|
|
|
public ResultEntity<HttpStatus> insertCaseStepByCaseId(@RequestBody SysCaseQuestionStepWithBLOBs caseQuestionStep,
|
|
|
|
|
@RequestParam @ApiParam("管理员/学校ID") String source) {
|
|
|
|
|
if (caseQuestionStep.getCaseId().isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "案例步骤新增失败,未选择添加案例");
|
|
|
|
|
}
|
|
|
|
|
if (caseQuestionStep.getTitle().isEmpty()
|
|
|
|
|
|| caseQuestionStep.getQuestion().isEmpty()
|
|
|
|
|
|| caseQuestionStep.getAnswer().isEmpty()
|
|
|
|
|
|| caseQuestionStep.getContent().isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "案例步骤新增失败,必填内容为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//todo 现在逻辑是 管理员和老师只能给各自新增的案例题加步骤
|
|
|
|
|
SysCaseQuestion sysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(caseQuestionStep.getCaseId());
|
|
|
|
|
if (!source.equals(sysCaseQuestion.getSource())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "权限不足");
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
caseQuestionStep.setCaseStepId(String.valueOf(UUID.randomUUID()));
|
|
|
|
|
caseQuestionStepMapper.insert(caseQuestionStep);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "案例步骤新增成功");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "案例步骤新增失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|