|
|
|
@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@Api(tags = "课程方面API")
|
|
|
|
@ -35,30 +36,29 @@ public class CaseApi {
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysOneCatalogMapper sysOneCatalogMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//案例题新增 SysCaseQuestion
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题新增")
|
|
|
|
|
@PostMapping("insertCase")
|
|
|
|
|
public ResultEntity<HttpStatus> insertCase(@ApiParam("目前二级三级ID可以为空,来源和题型要传,上架状态传true") @RequestBody SysCaseQuestion sysCaseQuestion) {
|
|
|
|
|
public Boolean insertCase(@ApiParam("目前二级三级ID可以为空,来源和题型要传,上架状态传true") @RequestBody SysCaseQuestion sysCaseQuestion) {
|
|
|
|
|
if (("3").equals(sysCaseQuestion.getType())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "题型错误!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(sysCaseQuestion.getOneId())) { //todo 目前二级三级ID可以为空
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "课程不能为空!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(sysCaseQuestion.getContent()) || StringUtils.isBlank(sysCaseQuestion.getTitle())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "题目内容不能为空!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(sysCaseQuestion.getSource())) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "题目来源不能为空!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
String title = sysCaseQuestion.getTitle();
|
|
|
|
|
SysCaseQuestionExample example = new SysCaseQuestionExample();
|
|
|
|
|
example.createCriteria().andTitleEqualTo(title);
|
|
|
|
|
List<SysCaseQuestion> sysCaseQuestions = caseQuestionMapper.selectByExample(example);
|
|
|
|
|
if (!sysCaseQuestions.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "案例名称不能重复!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String uuid = IdUtil.randomUUID();
|
|
|
|
@ -74,6 +74,7 @@ public class CaseApi {
|
|
|
|
|
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(sysCaseQuestion.getOneId()); //name放在ID传过来
|
|
|
|
|
String oneId = sysOneCatalogs.getOneId();
|
|
|
|
|
sysTopicAndCourse.setOneId(oneId);
|
|
|
|
|
sysTopicAndCourse.setOneName(sysCaseQuestion.getOneId());
|
|
|
|
|
if (StringUtils.isNotBlank(sysCaseQuestion.getTwoId())) {
|
|
|
|
|
sysTopicAndCourse.setTwoId(sysCaseQuestion.getTwoId());
|
|
|
|
|
}
|
|
|
|
@ -81,7 +82,7 @@ public class CaseApi {
|
|
|
|
|
sysTopicAndCourse.setThreeId(sysCaseQuestion.getThreeId());
|
|
|
|
|
}
|
|
|
|
|
topicAndCourseMapper.insert(sysTopicAndCourse);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "新增成功!");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private SysOneCatalog getSysOneCatalogs(String systemOwner) {
|
|
|
|
@ -97,21 +98,144 @@ public class CaseApi {
|
|
|
|
|
@PostMapping("selectCaseByConditions")
|
|
|
|
|
public ResultEntity<PageInfo<SysCaseQuestion>> selectCaseByConditions(@RequestParam Integer index,
|
|
|
|
|
@RequestParam Integer size,
|
|
|
|
|
@RequestParam(required = false) String title,
|
|
|
|
|
@RequestParam(required = false) String oneId) {
|
|
|
|
|
@RequestParam(required = false) String keyword,
|
|
|
|
|
@RequestParam(required = false) String systemOwner,
|
|
|
|
|
@RequestParam(required = false) String schoolId) {
|
|
|
|
|
PageHelper.startPage(index, size);
|
|
|
|
|
List<SysCaseQuestion> list = caseQuestionMapper.selectCaseByConditions(title, oneId);
|
|
|
|
|
SysOneCatalog sysOneCatalogs = getSysOneCatalogs(systemOwner);
|
|
|
|
|
String oneId = sysOneCatalogs.getOneId();
|
|
|
|
|
List<SysCaseQuestion> list = caseQuestionMapper.selectCaseByConditions(keyword, oneId, schoolId);
|
|
|
|
|
PageInfo pageInfo = new PageInfo<SysCaseQuestion>(list);
|
|
|
|
|
return new ResultEntity<PageInfo<SysCaseQuestion>>(pageInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//案例题详情查询 caseId
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题详细内容展示")
|
|
|
|
|
@PostMapping("selectCaseByConditionsByID")
|
|
|
|
|
public ResultEntity<SysCaseQuestion> selectCaseByConditionsByID(@RequestParam String caseId) {
|
|
|
|
|
SysCaseQuestion sysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(caseId);
|
|
|
|
|
return new ResultEntity<SysCaseQuestion>(sysCaseQuestion);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//案例题删除 caseId
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题删除") //逻辑删除
|
|
|
|
|
@PostMapping("deleteCase")
|
|
|
|
|
public Boolean deleteCase(@RequestParam String caseId) {
|
|
|
|
|
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(caseId);
|
|
|
|
|
if (!sysTopicAndCourses.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
SysCaseQuestion sysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(caseId);
|
|
|
|
|
String source = sysCaseQuestion.getSource();
|
|
|
|
|
//todo 管理员任意删除 老师只能删除自己上传的
|
|
|
|
|
if (!"管理员".equals(source)) {
|
|
|
|
|
SysCaseQuestion dataSysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(sysCaseQuestion.getCaseId());
|
|
|
|
|
dataSysCaseQuestion.setUnmountStatus(true);
|
|
|
|
|
caseQuestionMapper.updateByPrimaryKey(dataSysCaseQuestion);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<SysTopicAndCourse> getSysTopicAndCourses(String caseId) {
|
|
|
|
|
SysTopicAndCourseExample example = new SysTopicAndCourseExample();
|
|
|
|
|
example.createCriteria().andTopicIdEqualTo(caseId).andTopicTypeEqualTo("1");
|
|
|
|
|
List<SysTopicAndCourse> sysTopicAndCourses = topicAndCourseMapper.selectByExample(example);
|
|
|
|
|
return sysTopicAndCourses;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//案例题编辑 SysCaseQuestion
|
|
|
|
|
//案例题信息查询 caseId
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题编辑")
|
|
|
|
|
@PostMapping("updateCase")
|
|
|
|
|
public Boolean updateCase(@RequestBody SysCaseQuestion sysCaseQuestion) {
|
|
|
|
|
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(sysCaseQuestion.getCaseId());
|
|
|
|
|
if (!sysTopicAndCourses.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
caseQuestionMapper.updateByPrimaryKey(sysCaseQuestion);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//案例题步骤信息查询 caseId
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例步骤展示")
|
|
|
|
|
@PostMapping("selectCaseStep")
|
|
|
|
|
public ResultEntity<List<SysCaseQuestionStepWithBLOBs>> selectCaseStep(@ApiParam("案例题ID") @RequestParam String caseId) {
|
|
|
|
|
SysCaseQuestionStepExample example = new SysCaseQuestionStepExample();
|
|
|
|
|
example.createCriteria().andCaseIdEqualTo(caseId);
|
|
|
|
|
// example.setOrderByClause("sort ASC");
|
|
|
|
|
List<SysCaseQuestionStepWithBLOBs> stepList = caseQuestionStepMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
return new ResultEntity<>(stepList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//案例题步骤新增 SysCaseQuestionStep
|
|
|
|
|
//案例步骤编辑 SysCaseQuestionStep
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题添加步骤")
|
|
|
|
|
@PostMapping("insertCaseStepByCaseId")
|
|
|
|
|
public Boolean insertCaseStepByCaseId(@RequestBody SysCaseQuestionStepWithBLOBs caseQuestionStep) {
|
|
|
|
|
if (caseQuestionStep.getCaseId().isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (caseQuestionStep.getTitle().isEmpty()
|
|
|
|
|
|| caseQuestionStep.getQuestion().isEmpty()
|
|
|
|
|
|| caseQuestionStep.getAnswer().isEmpty()
|
|
|
|
|
|| caseQuestionStep.getContent().isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
caseQuestionStep.setCaseStepId(String.valueOf(UUID.randomUUID()));
|
|
|
|
|
caseQuestionStepMapper.insert(caseQuestionStep);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//案例步骤编辑 SysCaseQuestionStepWithBLOBs
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题步骤编辑")
|
|
|
|
|
@PostMapping("updateCaseStep")
|
|
|
|
|
public Boolean updateCaseStep(@RequestBody SysCaseQuestionStepWithBLOBs caseQuestionStepWithBLOBs) {
|
|
|
|
|
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(caseQuestionStepWithBLOBs.getCaseId());
|
|
|
|
|
if (!sysTopicAndCourses.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
caseQuestionStepMapper.updateByPrimaryKey(caseQuestionStepWithBLOBs);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//案例步骤删除 caseStepId
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
@ApiOperation("案例题步骤删除")
|
|
|
|
|
@PostMapping("deleteCaseStep")
|
|
|
|
|
public Boolean deleteCaseStep(@RequestParam String caseStepId) {
|
|
|
|
|
List<SysTopicAndCourse> sysTopicAndCourses = getSysTopicAndCourses(caseStepId);
|
|
|
|
|
if (!sysTopicAndCourses.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
caseQuestionStepMapper.deleteByPrimaryKey(caseStepId);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//案例题步骤内容查看 caseStepId
|
|
|
|
|
@PostMapping("selectCaseStepDetails")
|
|
|
|
|
@ApiOperation("案例题步骤内容查看")
|
|
|
|
|
public ResultEntity<SysCaseQuestionStep> selectCaseStepDetails(@ApiParam("案例题步骤ID") @RequestParam String caseStepId) {
|
|
|
|
|
SysCaseQuestionStep sysCaseQuestionStep = caseQuestionStepMapper.selectByPrimaryKey(caseStepId);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "案例题步骤内容查看成功", sysCaseQuestionStep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|