|
|
@ -137,6 +137,20 @@ public class ResourceServiceImpl implements ResourceService { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public BaseResponse<String> upload(MultipartFile file) { |
|
|
|
|
|
|
|
ResourceUploadVO ResourceUploadVO = minioUtils.upload(file); |
|
|
|
|
|
|
|
if (ResourceUploadVO == null) { |
|
|
|
|
|
|
|
return ResultUtils.error(ErrorCode.OPERATION_ERROR, "上传失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String url = ResourceUploadVO.getUrl(); |
|
|
|
|
|
|
|
// String name = ResourceUploadVO.getName();
|
|
|
|
|
|
|
|
// String objectName = ResourceUploadVO.getObjectName();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResultUtils.success(url); |
|
|
|
|
|
|
|
======= |
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
// @Override
|
|
|
|
// public BaseResponse<ResourceUploadVO> upload(MultipartFile file) {
|
|
|
|
// public BaseResponse<ResourceUploadVO> upload(MultipartFile file) {
|
|
|
@ -193,7 +207,25 @@ public class ResourceServiceImpl implements ResourceService { |
|
|
|
return ResultUtils.error(ErrorCode.SYSTEM_ERROR,"添加关系失败"); |
|
|
|
return ResultUtils.error(ErrorCode.SYSTEM_ERROR,"添加关系失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return ResultUtils.success(resourceMysql); |
|
|
|
return ResultUtils.success(resourceMysql); |
|
|
|
|
|
|
|
>>>>>>> 2b31a38a8270bebc5e82f07db8833ab038aac30b |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public BaseResponse<String> delete(String objectName) {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// minioUtils.delete(objectName);
|
|
|
|
|
|
|
|
// }catch (Exception e){
|
|
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
|
|
// LOGGER.info("删除失败,故障");
|
|
|
|
|
|
|
|
// return ResultUtils.error(ErrorCode.OPERATION_ERROR, "删除失败");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return ResultUtils.success("删除成功");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public ResponseEntity<InputStreamResource> readFile(String filename) {
|
|
|
|
|
|
|
|
// return minioUtils.readFile(filename);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
// @Override
|
|
|
@ -223,6 +255,32 @@ public class ResourceServiceImpl implements ResourceService { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
public BaseResponse<ResourceMysql> addResourceForMysql(MultipartFile file,Long knowId) { |
|
|
|
|
|
|
|
ResourceUploadVO ResourceUploadVO = minioUtils.upload(file); |
|
|
|
|
|
|
|
ResourceMysql resourceMysql = new ResourceMysql(); |
|
|
|
|
|
|
|
resourceMysql.setName(ResourceUploadVO.getName()); |
|
|
|
|
|
|
|
resourceMysql.setType(ResourceUploadVO.getType()); |
|
|
|
|
|
|
|
resourceMysql.setStatus(status); |
|
|
|
|
|
|
|
resourceMysql.setUrl(ResourceUploadVO.getUrl()); |
|
|
|
|
|
|
|
resourceMysql.setCreateTime(LocalDateTime.now()); |
|
|
|
|
|
|
|
int ans = resourceMapper.insert(resourceMysql); |
|
|
|
|
|
|
|
if(ans <= 0){ |
|
|
|
|
|
|
|
return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加资源失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//查询知识点
|
|
|
|
|
|
|
|
KnowPoint knowPoint = knowtmpMapper.selectById(knowId); |
|
|
|
|
|
|
|
//添加资源和知识点的关系
|
|
|
|
|
|
|
|
ResourceRelationship resourceRelationship = new ResourceRelationship(); |
|
|
|
|
|
|
|
resourceRelationship.setResourceId(resourceMysql.getId()); |
|
|
|
|
|
|
|
resourceRelationship.setCourseId(knowPoint.getCourseId()); |
|
|
|
|
|
|
|
resourceRelationship.setKnowId(knowId); |
|
|
|
|
|
|
|
int ans2 = resourceRelationshipMapper.insert(resourceRelationship); |
|
|
|
|
|
|
|
if(ans2 < 0){ |
|
|
|
|
|
|
|
return ResultUtils.error(ErrorCode.SYSTEM_ERROR,"添加关系失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ResultUtils.success(resourceMysql); |
|
|
|
|
|
|
|
======= |
|
|
|
public BaseResponse<String> deleteResourceForMysql(long id) throws Exception { |
|
|
|
public BaseResponse<String> deleteResourceForMysql(long id) throws Exception { |
|
|
|
ResourceMysql resourceMysql = resourceMapper.selectById(id); |
|
|
|
ResourceMysql resourceMysql = resourceMapper.selectById(id); |
|
|
|
if(resourceMysql == null){ |
|
|
|
if(resourceMysql == null){ |
|
|
@ -235,6 +293,117 @@ public class ResourceServiceImpl implements ResourceService { |
|
|
|
return ResultUtils.success("删除成功"); |
|
|
|
return ResultUtils.success("删除成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"删除失败"); |
|
|
|
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"删除失败"); |
|
|
|
|
|
|
|
>>>>>>> 2b31a38a8270bebc5e82f07db8833ab038aac30b |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// @Transactional
|
|
|
|
|
|
|
|
// public BaseResponse<String> deleteResource(long id) throws Exception {
|
|
|
|
|
|
|
|
// Resources resources = resourcesRepository.queryResourcesByIds(id);
|
|
|
|
|
|
|
|
// if (resources == null) {
|
|
|
|
|
|
|
|
// return ResultUtils.error(ErrorCode.PARAMS_ERROR, "删除ID不存在");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// minioUtils.delete(resources.getName());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// int ans = resourceMapper.deleteById(resources.getResourceId());
|
|
|
|
|
|
|
|
// if (ans <= 0) {
|
|
|
|
|
|
|
|
// return ResultUtils.error(ErrorCode.PARAMS_ERROR, "删除-mysql-失败");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Boolean flag = resourcesRepository.deleteByid(id);
|
|
|
|
|
|
|
|
// if(flag){
|
|
|
|
|
|
|
|
// return ResultUtils.success("删除成功");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return ResultUtils.error(ErrorCode.PARAMS_ERROR, "删除-neo4j-失败");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// //查询资源-关系表
|
|
|
|
|
|
|
|
// QueryWrapper<ResourceRelationship> resourceRelationshipQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
// resourceRelationshipQueryWrapper.eq("resource_id",id);
|
|
|
|
|
|
|
|
// List<ResourceRelationship> resourceRelationshipList = resourceRelationshipMapper.selectList(resourceRelationshipQueryWrapper);
|
|
|
|
|
|
|
|
// if(resourceRelationshipList != null){
|
|
|
|
|
|
|
|
// int delete = resourceRelationshipMapper.delete(resourceRelationshipQueryWrapper);
|
|
|
|
|
|
|
|
// if(delete <= 0){
|
|
|
|
|
|
|
|
// return ResultUtils.error(ErrorCode.PARAMS_ERROR,"删除-mysql-resource关系失败");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// boolean f = resourcesRepository.deleteByResourceId(id);
|
|
|
|
|
|
|
|
// if(f){
|
|
|
|
|
|
|
|
// return ResultUtils.success("删除成功");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return ResultUtils.error(ErrorCode.PARAMS_ERROR,"删除失败");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public BaseResponse<String> recoverdata() {
|
|
|
|
|
|
|
|
// resourcesRepository.deleteAll();
|
|
|
|
|
|
|
|
// QueryWrapper<ResourceMysql> resourceMysqlQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
// List<ResourceMysql> resourceMysqls = resourceMapper.selectList(resourceMysqlQueryWrapper);
|
|
|
|
|
|
|
|
// for (ResourceMysql rs:resourceMysqls) {
|
|
|
|
|
|
|
|
// String temp = "CREATE (n:Resources {"
|
|
|
|
|
|
|
|
// +"name: '"+rs.getName()+"',"
|
|
|
|
|
|
|
|
// +"resourceId: "+rs.getId()+","
|
|
|
|
|
|
|
|
// +"url: '"+rs.getUrl()+"',"
|
|
|
|
|
|
|
|
// +"status: "+rs.getStatus()+","
|
|
|
|
|
|
|
|
// +"type: "+rs.getType()+","
|
|
|
|
|
|
|
|
// +"tags: '"+rs.getTags()+"',"
|
|
|
|
|
|
|
|
// +"description: '"+rs.getDescription()
|
|
|
|
|
|
|
|
// +"'}) return ID(n)";
|
|
|
|
|
|
|
|
// Collection<Map<String, Object>> all = neo4jClient.query(temp).fetch().all();
|
|
|
|
|
|
|
|
// if(all == null){
|
|
|
|
|
|
|
|
// return ResultUtils.success("恢复失败");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// System.out.println(all);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return ResultUtils.success("恢复成功");
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// @Transactional
|
|
|
|
|
|
|
|
// public BaseResponse<ResourceMysql> addResource(MultipartFile file) {
|
|
|
|
|
|
|
|
// ResourceUploadVO ResourceUploadVO = minioUtils.upload(file);
|
|
|
|
|
|
|
|
// //添加mysql
|
|
|
|
|
|
|
|
// ResourceMysql resourceMysql = new ResourceMysql();
|
|
|
|
|
|
|
|
// resourceMysql.setName(ResourceUploadVO.getName());
|
|
|
|
|
|
|
|
// resourceMysql.setType(ResourceUploadVO.getType());
|
|
|
|
|
|
|
|
// resourceMysql.setStatus(status);
|
|
|
|
|
|
|
|
// resourceMysql.setUrl(ResourceUploadVO.getUrl());
|
|
|
|
|
|
|
|
// long ans = resourceMapper.insert(resourceMysql);
|
|
|
|
|
|
|
|
// //添加neo4j
|
|
|
|
|
|
|
|
// Resources resources = new Resources();
|
|
|
|
|
|
|
|
// resources.setType(ResourceUploadVO.getType());
|
|
|
|
|
|
|
|
// resources.setName(ResourceUploadVO.getName());
|
|
|
|
|
|
|
|
// resources.setStatus(status);
|
|
|
|
|
|
|
|
// resources.setResourceId(resourceMysql.getId());
|
|
|
|
|
|
|
|
// resources.setUrl(ResourceUploadVO.getUrl());
|
|
|
|
|
|
|
|
// Resources resourcesNew = resourcesRepository.save(resources);
|
|
|
|
|
|
|
|
// if (resourcesNew != null && ans > 0) {
|
|
|
|
|
|
|
|
// return ResultUtils.success(resourceMysql);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return ResultUtils.error(ErrorCode.OPERATION_ERROR,"添加资原失败");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public BaseResponse<String> deleteResourceForMysql(long id) throws Exception { |
|
|
|
|
|
|
|
ResourceMysql resourceMysql = resourceMapper.selectById(id); |
|
|
|
|
|
|
|
if(resourceMysql == null){ |
|
|
|
|
|
|
|
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"删除ID不存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
minioUtils.delete(resourceMysql.getName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ans = resourceMapper.deleteById(id); |
|
|
|
|
|
|
|
if (ans < 0) { |
|
|
|
|
|
|
|
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"删除失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//删除资源与知识点的关系
|
|
|
|
|
|
|
|
QueryWrapper<ResourceRelationship> resourceRelationshipQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
resourceRelationshipQueryWrapper.eq("resource_id", id); |
|
|
|
|
|
|
|
resourceRelationshipMapper.delete(resourceRelationshipQueryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResultUtils.success("删除成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
// @Override
|
|
|
@ -300,4 +469,6 @@ public class ResourceServiceImpl implements ResourceService { |
|
|
|
//
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
|
|
|
|
|
>>>>>>> 2b31a38a8270bebc5e82f07db8833ab038aac30b |
|
|
|
} |
|
|
|
} |
|
|
|