|
|
@ -67,56 +67,42 @@ public class AdminComponentCodeController {
|
|
|
|
@ApiOperation("新增")
|
|
|
|
@ApiOperation("新增")
|
|
|
|
@AnonymousAccess
|
|
|
|
@AnonymousAccess
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public ResultEntity<String> add(@ApiParam("代码内容") String codeContent,
|
|
|
|
public ResultEntity<String> add(@RequestBody UpdateAdminDataDTO dto) {
|
|
|
|
@ApiParam("参数释义")@RequestParam(required = false) String parameterContent,
|
|
|
|
|
|
|
|
@ApiParam("步骤名称(一级标签)") String stepName,
|
|
|
|
|
|
|
|
@ApiParam("案例名称(二级标签)") String caseName,
|
|
|
|
|
|
|
|
@RequestParam(required = false) List<MultipartFile> dataFile) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(stepName)) {
|
|
|
|
if (StringUtils.isBlank(dto.getStepName())) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入步骤名称!");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入步骤名称!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringUtils.isBlank(caseName)) {
|
|
|
|
if (StringUtils.isBlank(dto.getCaseName())) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入案例名称!");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入案例名称!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringUtils.isBlank(codeContent)) {
|
|
|
|
if (StringUtils.isBlank(dto.getCodeContent())) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入代码内容!");
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入代码内容!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StringUtils.isBlank(parameterContent)) {
|
|
|
|
// if (StringUtils.isBlank(dto.getParameterContent())) {
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入参数释义!");
|
|
|
|
// return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入参数释义!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询是否已有该案例名称
|
|
|
|
|
|
|
|
AdminComponentCodeExample codeExample=new AdminComponentCodeExample();
|
|
|
|
|
|
|
|
codeExample.createCriteria().andChapterNameEqualTo(dto.getCaseName()).andCourseNameEqualTo(dto.getStepName());
|
|
|
|
|
|
|
|
List<AdminComponentCode> adminComponentCodes = adminComponentCodeMapper.selectByExample(codeExample);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!adminComponentCodes.isEmpty()){
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "该案例已存在!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//新增
|
|
|
|
//新增
|
|
|
|
AdminComponentCodeWithBLOBs adminComponentCode = new AdminComponentCodeWithBLOBs();
|
|
|
|
AdminComponentCodeWithBLOBs adminComponentCode = new AdminComponentCodeWithBLOBs();
|
|
|
|
Integer uuid = UUID.randomUUID().toString().replaceAll("-", "").hashCode();
|
|
|
|
|
|
|
|
uuid = uuid < 0 ? -uuid : uuid;//String.hashCode() 值会为空
|
|
|
|
adminComponentCode.setCourseName(dto.getStepName());
|
|
|
|
adminComponentCode.setId(uuid);
|
|
|
|
adminComponentCode.setChapterName(dto.getCaseName());
|
|
|
|
adminComponentCode.setCourseName(stepName);
|
|
|
|
adminComponentCode.setItem(dto.getCodeContent());
|
|
|
|
adminComponentCode.setChapterName(caseName);
|
|
|
|
adminComponentCode.setDefinition(dto.getParameterContent());
|
|
|
|
adminComponentCode.setItem(codeContent);
|
|
|
|
|
|
|
|
adminComponentCode.setDefinition(parameterContent);
|
|
|
|
|
|
|
|
adminComponentCode.setStatus(0); //默认下架,发布后上架
|
|
|
|
adminComponentCode.setStatus(0); //默认下架,发布后上架
|
|
|
|
adminComponentCode.setCreateTime(new Date());
|
|
|
|
adminComponentCode.setCreateTime(new Date());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置数据文件
|
|
|
|
|
|
|
|
if (dataFile != null && !dataFile.isEmpty()) {
|
|
|
|
|
|
|
|
List<AdminFile> list = new ArrayList<>();
|
|
|
|
|
|
|
|
for (MultipartFile file : dataFile) {
|
|
|
|
|
|
|
|
AdminFile adminFile = new AdminFile();
|
|
|
|
|
|
|
|
adminFile.setFileId(IdUtil.randomUUID());
|
|
|
|
|
|
|
|
String dataUrl = fileUtil.upload(file);
|
|
|
|
|
|
|
|
String fullFileName = file.getOriginalFilename();
|
|
|
|
|
|
|
|
adminFile.setFileUrl(dataUrl);
|
|
|
|
|
|
|
|
adminFile.setName(fullFileName);
|
|
|
|
|
|
|
|
adminFile.setSource("案例表");
|
|
|
|
|
|
|
|
adminFile.setDataCaseId(String.valueOf(uuid));
|
|
|
|
|
|
|
|
list.add(adminFile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//批量新增数据文件
|
|
|
|
|
|
|
|
adminFileMapper.insertBatch(list);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//新增案例
|
|
|
|
//新增案例
|
|
|
|
adminComponentCodeMapper.insert(adminComponentCode);
|
|
|
|
adminComponentCodeMapper.insert(adminComponentCode);
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "新增成功!");
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "新增成功!");
|
|
|
@ -165,6 +151,8 @@ public class AdminComponentCodeController {
|
|
|
|
codeExample.createCriteria().andChapterNameLike("%"+caseName+"%");
|
|
|
|
codeExample.createCriteria().andChapterNameLike("%"+caseName+"%");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
codeExample.setOrderByClause("create_time DESC");
|
|
|
|
|
|
|
|
|
|
|
|
List<AdminComponentCodeWithBLOBs> adminComponentCodeWithBLOBs = adminComponentCodeMapper.selectByExampleWithBLOBs(codeExample);
|
|
|
|
List<AdminComponentCodeWithBLOBs> adminComponentCodeWithBLOBs = adminComponentCodeMapper.selectByExampleWithBLOBs(codeExample);
|
|
|
|
|
|
|
|
|
|
|
|
PageInfo pageInfo = PageUtil.pageHelper(adminComponentCodeWithBLOBs, index, size);
|
|
|
|
PageInfo pageInfo = PageUtil.pageHelper(adminComponentCodeWithBLOBs, index, size);
|
|
|
|