|
|
@ -1,26 +1,88 @@
|
|
|
|
package com.sztzjy.resource_center.controller.api;
|
|
|
|
package com.sztzjy.resource_center.controller.api;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.sztzjy.resource_center.annotation.AnonymousAccess;
|
|
|
|
|
|
|
|
import com.sztzjy.resource_center.entity.SysCaseQuestion;
|
|
|
|
|
|
|
|
import com.sztzjy.resource_center.entity.SysResourceData;
|
|
|
|
|
|
|
|
import com.sztzjy.resource_center.entity.SysResourceDataExample;
|
|
|
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysCaseQuestionMapper;
|
|
|
|
|
|
|
|
import com.sztzjy.resource_center.mapper.SysResourceDataMapper;
|
|
|
|
|
|
|
|
import com.sztzjy.resource_center.util.file.IFileUtil;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@Api(tags = "课程方面API")
|
|
|
|
@Api(tags = "课程方面API")
|
|
|
|
@RequestMapping("api/tea/ResourceApi")
|
|
|
|
@RequestMapping("api/tea/ResourceApi")
|
|
|
|
public class ResourceDataApi {
|
|
|
|
public class ResourceDataApi {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private SysResourceDataMapper sysResourceDataMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private SysCaseQuestionMapper caseQuestionMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
IFileUtil fileUtil;
|
|
|
|
|
|
|
|
@Value("${file.path}")
|
|
|
|
|
|
|
|
private String filePath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 数据集文件上传
|
|
|
|
* 数据集文件上传
|
|
|
|
* 方法名:uploadResourceData
|
|
|
|
* 方法名:uploadResourceData
|
|
|
|
* 参数:MultipartFile schoolId caseId
|
|
|
|
* 参数:MultipartFile schoolId caseId
|
|
|
|
* return: boolean
|
|
|
|
* return: boolean
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
|
|
|
@ApiOperation("数据集文件上传")
|
|
|
|
|
|
|
|
@PostMapping("uploadResourceData")
|
|
|
|
|
|
|
|
private Boolean uploadResourceData(@RequestParam MultipartFile file,
|
|
|
|
|
|
|
|
@RequestParam String schoolId,
|
|
|
|
|
|
|
|
@RequestParam String caseId) {
|
|
|
|
|
|
|
|
SysCaseQuestion sysCaseQuestion = caseQuestionMapper.selectByPrimaryKey(caseId);
|
|
|
|
|
|
|
|
if (!schoolId.equals(sysCaseQuestion.getSource())) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String uploadUrl = fileUtil.upload(file);
|
|
|
|
|
|
|
|
SysResourceData resourceData = new SysResourceData();
|
|
|
|
|
|
|
|
resourceData.setResourceDataId(String.valueOf(UUID.randomUUID()));
|
|
|
|
|
|
|
|
resourceData.setResourceName(file.getOriginalFilename());
|
|
|
|
|
|
|
|
resourceData.setSize((double) file.getSize());
|
|
|
|
|
|
|
|
resourceData.setSource(schoolId);
|
|
|
|
|
|
|
|
resourceData.setCaseId(caseId);
|
|
|
|
|
|
|
|
resourceData.setUrl(uploadUrl);
|
|
|
|
|
|
|
|
sysResourceDataMapper.insert(resourceData);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 数据集列表信息查询
|
|
|
|
* 数据集列表信息查询
|
|
|
|
* 方法名:selectResourceDataList
|
|
|
|
* 方法名:selectResourceDataList
|
|
|
|
* 参数:caseId
|
|
|
|
* 参数:caseId
|
|
|
|
* return: List<SysResource>
|
|
|
|
* return: List<SysResourceData>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
|
|
|
@ApiOperation("数据集列表信息查询")
|
|
|
|
|
|
|
|
@PostMapping("selectResourceDataList")
|
|
|
|
|
|
|
|
private List<SysResourceData> selectResourceDataList(@RequestParam String caseId) {
|
|
|
|
|
|
|
|
SysResourceDataExample example = new SysResourceDataExample();
|
|
|
|
|
|
|
|
example.createCriteria().andCaseIdEqualTo(caseId);
|
|
|
|
|
|
|
|
return sysResourceDataMapper.selectByExample(example);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 数据集删除
|
|
|
|
* 数据集删除
|
|
|
@ -28,6 +90,20 @@ public class ResourceDataApi {
|
|
|
|
* 参数:resourceId schoolId
|
|
|
|
* 参数:resourceId schoolId
|
|
|
|
* return: boolean
|
|
|
|
* return: boolean
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
|
|
|
@ApiOperation("数据集删除")
|
|
|
|
|
|
|
|
@PostMapping("deleteResourceData")
|
|
|
|
|
|
|
|
private Boolean deleteResourceData(@RequestParam String resourceId,
|
|
|
|
|
|
|
|
@RequestParam String schoolId) {
|
|
|
|
|
|
|
|
SysResourceData sysResourceData = sysResourceDataMapper.selectByPrimaryKey(resourceId);
|
|
|
|
|
|
|
|
if (!sysResourceData.getSource().equals(schoolId)) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
sysResourceDataMapper.deleteByPrimaryKey(resourceId);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 数据集下载
|
|
|
|
* 数据集下载
|
|
|
@ -35,4 +111,18 @@ public class ResourceDataApi {
|
|
|
|
* 参数:resourceId response
|
|
|
|
* 参数:resourceId response
|
|
|
|
* return: void
|
|
|
|
* return: void
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
@AnonymousAccess
|
|
|
|
|
|
|
|
@ApiOperation("数据集下载")
|
|
|
|
|
|
|
|
@PostMapping("downloadResourceData")
|
|
|
|
|
|
|
|
private Boolean selectResourceDataList(@RequestParam String resourceId,
|
|
|
|
|
|
|
|
HttpServletResponse response) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
SysResourceData sysResourceData = sysResourceDataMapper.selectByPrimaryKey(resourceId);
|
|
|
|
|
|
|
|
String resourceName = sysResourceData.getResourceName();
|
|
|
|
|
|
|
|
fileUtil.download(response,resourceName ,sysResourceData.getUrl());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|