commit
aeadc75e7a
51 changed files with 1979 additions and 1507 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@ |
||||
package com.teaching.backend.controller.Know; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-08-29-11:23 |
||||
* @Description: |
||||
*/ |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class KnowPathVO { |
||||
private List<String>nodeList; |
||||
private Double weight; |
||||
|
||||
} |
@ -0,0 +1,24 @@ |
||||
package com.teaching.backend.controller.Know; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import lombok.NonNull; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-09-02-9:47 |
||||
* @Description: |
||||
*/ |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class RelsNodesVO { |
||||
@NonNull |
||||
private String courseId; |
||||
private Integer level; |
||||
private List<String> types; |
||||
} |
@ -0,0 +1,78 @@ |
||||
package com.teaching.backend.controller.resource; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-06-09-9:55 |
||||
* @Description: |
||||
*/ |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.model.entity.resource.Resources; |
||||
import com.teaching.backend.service.resource.ResourceGraphService; |
||||
import com.teaching.backend.service.resource.ResourceService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.core.io.InputStreamResource; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping("/api/resource/graph") |
||||
@Api(tags= "资源与图管理") |
||||
public class ResourceGraphController { |
||||
|
||||
@Autowired |
||||
private ResourceGraphService resourceGraphService; |
||||
|
||||
|
||||
@GetMapping("/addRelationship/BetweenKnowAndResources") |
||||
@ApiOperation(value = "添加知识点资源关系") |
||||
public BaseResponse<String> addResourcesByIdAndResourcesId(@RequestParam Long id,@RequestParam Long resourcesId){ |
||||
return resourceGraphService.addResourcesByIdAndResourcesId(id,resourcesId); |
||||
} |
||||
|
||||
@GetMapping("/deleteRelationship/BetweenKnowAndResources") |
||||
@ApiOperation(value = "删除知识点资源关系") |
||||
public BaseResponse<String> deleteResourcesAndKnowById(@RequestParam Long id, @RequestParam Long resourcesId){ |
||||
return resourceGraphService.deleteResourcesAndKnowById(id,resourcesId); |
||||
} |
||||
|
||||
//查询课程下资源
|
||||
@GetMapping("/queryByCourseId") |
||||
@ApiOperation(value = "查询课程下资源") |
||||
BaseResponse<Set<Resources>> queryResourcesByCourseId(@RequestParam String courseId){ |
||||
return resourceGraphService.queryResourcesByCourseId(courseId); |
||||
} |
||||
|
||||
//查询章节下资源
|
||||
@GetMapping("/queryByChapterId") |
||||
@ApiOperation(value = "查询章节下资源") |
||||
BaseResponse<Set<Resources>> queryResourcesByChapterId(@RequestParam Long chapterId){ |
||||
return resourceGraphService.queryResourcesByChapterId(chapterId); |
||||
} |
||||
|
||||
//查询二级节点下资源
|
||||
@ApiOperation(value = "查询二级节点下资源") |
||||
@GetMapping("/queryBesidesKnow") |
||||
BaseResponse<Set<Resources>> queryBesidesKnowToResources(@RequestParam Long knowId){ |
||||
return resourceGraphService.queryBesidesKnowToResources(knowId); |
||||
} |
||||
|
||||
//查询知识点下资源
|
||||
@GetMapping("/queryResourcesByKnowId") |
||||
@ApiOperation(value = "查询知识点下资源") |
||||
BaseResponse<Set<Resources>> queryResourcesByKnowId(@RequestParam Long knowId){ |
||||
return resourceGraphService.queryResourcesByKnowId(knowId); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,43 @@ |
||||
package com.teaching.backend.controller.resource; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import com.teaching.backend.service.impl.resource.ResourceMysqlServiceImpl; |
||||
import com.teaching.backend.service.impl.resource.ResourceServiceImpl; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/resourcemysql") |
||||
@Api(tags= "数据库资源管理") |
||||
public class ResourceMysqlController { |
||||
private ResourceMysqlServiceImpl resourceMysqlService; |
||||
|
||||
private ResourceServiceImpl resourceService; |
||||
|
||||
//添加资源
|
||||
@PostMapping("/add") |
||||
@ApiOperation(value = "添加资源") |
||||
public BaseResponse<String> addFile(@RequestPart("file") MultipartFile file, ResourceMysql resourceMysql) { |
||||
System.out.println("资源:"+ resourceMysql); |
||||
System.out.println(file); |
||||
String url = resourceService.upload(file).getData().getUrl(); |
||||
System.out.println(url); |
||||
//return ResultUtils.success("添加xx");
|
||||
return resourceMysqlService.resourceUpload(file, resourceMysql); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,23 @@ |
||||
package com.teaching.backend.mapper.Knowtemp; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.teaching.backend.model.entity.know.KnowStr; |
||||
import com.teaching.backend.model.entity.knowtmp.Knowtmp; |
||||
import io.lettuce.core.dynamic.annotation.Param; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Select; |
||||
|
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
@Mapper |
||||
public interface KnowstrMapper extends BaseMapper<KnowStr> { |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,17 @@ |
||||
package com.teaching.backend.mapper.resource; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
|
||||
/** |
||||
* <p> |
||||
* Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
public interface ResourceMysqlMapper extends BaseMapper<ResourceMysql> { |
||||
|
||||
} |
@ -0,0 +1,30 @@ |
||||
package com.teaching.backend.model.entity.know; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import lombok.Data; |
||||
|
||||
import javax.xml.soap.Text; |
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-08-23-17:29 |
||||
* @Description: |
||||
*/ |
||||
@Data |
||||
@TableName("know_str") |
||||
public class KnowStr implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
private String courseId; |
||||
|
||||
private String coursestr; |
||||
private String chapterstr; |
||||
private String knowstr; |
||||
private String edgestr; |
||||
|
||||
} |
@ -0,0 +1,29 @@ |
||||
package com.teaching.backend.model.entity.know; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import org.checkerframework.checker.units.qual.A; |
||||
import org.springframework.data.neo4j.core.schema.GeneratedValue; |
||||
import org.springframework.data.neo4j.core.schema.Id; |
||||
import org.springframework.data.neo4j.core.schema.Node; |
||||
import org.springframework.data.neo4j.core.schema.Property; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-07-21-16:32 |
||||
* @Description: |
||||
*/ |
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class LinksVO { |
||||
|
||||
private Long source; |
||||
|
||||
private Long target; |
||||
|
||||
private String label; |
||||
|
||||
|
||||
} |
@ -0,0 +1,65 @@ |
||||
package com.teaching.backend.model.entity.resource; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import java.io.Serializable; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
/** |
||||
* <p> |
||||
* |
||||
* </p> |
||||
* |
||||
* @author wenyu |
||||
* @since 2024-09-02 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@Accessors(chain = true) |
||||
@TableName("resource") |
||||
@ApiModel(value="Resource对象", description="") |
||||
public class ResourceMysql implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.ASSIGN_ID) |
||||
private String id; |
||||
|
||||
@ApiModelProperty(value = "课程id") |
||||
private String courseId; |
||||
|
||||
@ApiModelProperty(value = "章节id") |
||||
private String chapterId; |
||||
|
||||
@ApiModelProperty(value = "知识点id") |
||||
private String knowledgeId; |
||||
|
||||
@ApiModelProperty(value = "资源名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "资源类型") |
||||
private Integer type; |
||||
|
||||
@ApiModelProperty(value = "资源路径") |
||||
private String path; |
||||
|
||||
@ApiModelProperty(value = "资源状态") |
||||
private Integer status; |
||||
|
||||
@ApiModelProperty(value = "标签") |
||||
private String tags; |
||||
|
||||
@ApiModelProperty(value = "简介") |
||||
private String description; |
||||
|
||||
@ApiModelProperty(value = "封面") |
||||
private String img; |
||||
|
||||
|
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,146 @@ |
||||
package com.teaching.backend.service.impl.resource; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ErrorCode; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.mapper.know.KnowRepository; |
||||
import com.teaching.backend.mapper.resource.ResourcesRepository; |
||||
import com.teaching.backend.model.dto.resource.ResourceUploadDto; |
||||
import com.teaching.backend.model.entity.know.KnowChapter; |
||||
import com.teaching.backend.model.entity.know.KnowCourse; |
||||
import com.teaching.backend.model.entity.resource.Resources; |
||||
import com.teaching.backend.service.resource.ResourceGraphService; |
||||
import com.teaching.backend.service.resource.ResourceService; |
||||
import com.teaching.backend.utils.MinioUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.core.io.InputStreamResource; |
||||
import org.springframework.data.neo4j.core.Neo4jClient; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-07-26-13:58 |
||||
* @Description: |
||||
*/ |
||||
@Service |
||||
public class ResourceGraphServiceImpl implements ResourceGraphService { |
||||
|
||||
@Autowired |
||||
private ResourcesRepository resourcesRepository; |
||||
|
||||
@Autowired |
||||
private KnowRepository knowRepository; |
||||
|
||||
|
||||
|
||||
@Override |
||||
public BaseResponse<String> addResourcesByIdAndResourcesId(Long id,Long resourcesId) { |
||||
// 查询知识点是否存在 ,资源是否存在
|
||||
int f = knowRepository.queryNode(id); |
||||
if(f <= 0){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"知识点不存在"); |
||||
} |
||||
Resources resources = resourcesRepository.queryResourcesByIds(resourcesId); |
||||
if(resources == null){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"资源不存在"); |
||||
} |
||||
//查询关系是否存在
|
||||
int g = resourcesRepository.queryExisitRel(id,resourcesId); |
||||
if(g >0){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"关系已经存在"); |
||||
} |
||||
//添加关系 addResourcesAndKnowById
|
||||
f = resourcesRepository.addResourcesAndKnowById(id,resourcesId); |
||||
if(f<= 0){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"创建关系失败"); |
||||
} |
||||
|
||||
return ResultUtils.success("添加关系成功"); |
||||
} |
||||
|
||||
@Override |
||||
public BaseResponse<String> deleteResourcesAndKnowById(Long id, Long resourcesId) { |
||||
// 查询知识点是否存在 ,资源是否存在
|
||||
int f = knowRepository.queryNode(id); |
||||
if(f <= 0){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"知识点不存在"); |
||||
} |
||||
Resources resources = resourcesRepository.queryResourcesByIds(resourcesId); |
||||
|
||||
if(resources == null){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"资源不存在"); |
||||
} |
||||
//查询关系是否存在
|
||||
int g = resourcesRepository.queryExisitRel(id,resourcesId); |
||||
if(g < 0){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"关系未存在"); |
||||
} |
||||
|
||||
//删除关系
|
||||
f = resourcesRepository.deleteResourcesAndKnowById(id,resourcesId); |
||||
if(f<= 0){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"删除关系失败"); |
||||
} |
||||
return ResultUtils.success("删除关系成功"); |
||||
} |
||||
|
||||
@Override |
||||
//查询课程下资源
|
||||
public BaseResponse<Set<Resources>> queryResourcesByCourseId(String courseId){ |
||||
// 判空,查询
|
||||
KnowCourse knowCourse = knowRepository.queryCourse(courseId); |
||||
if(knowCourse == null){ |
||||
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"课程不存在"); |
||||
} |
||||
Set<Resources> resourcesSet = resourcesRepository.queryResourcesByCourseId(courseId); |
||||
return ResultUtils.success(resourcesSet); |
||||
} |
||||
@Override |
||||
//查询章节下资源
|
||||
public BaseResponse<Set<Resources>> queryResourcesByChapterId(Long chapterId){ |
||||
// 判空,查询
|
||||
KnowChapter knowChapter = knowRepository.queryChapter(chapterId); |
||||
if(knowChapter == null){ |
||||
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"章节不存在"); |
||||
} |
||||
Set<Resources>resourcesSet ; |
||||
resourcesSet = resourcesRepository.queryResourcesByChapterId(chapterId); |
||||
return ResultUtils.success(resourcesSet); |
||||
} |
||||
|
||||
@Override |
||||
//查询二级节点下资源
|
||||
public BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long knowId){ |
||||
// 判空,查询
|
||||
int i = knowRepository.queryNode(knowId); |
||||
if(i <= 0){ |
||||
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"知识点不存在"); |
||||
} |
||||
Set<Resources> resourcesSet = resourcesRepository.queryBesidesKnowToResources(knowId); |
||||
return ResultUtils.success(resourcesSet); |
||||
} |
||||
|
||||
@Override |
||||
public BaseResponse<Set<Resources>> queryResourcesByKnowId(Long knowId) { |
||||
// 判空,查询
|
||||
int i = knowRepository.queryNode(knowId); |
||||
if(i <= 0){ |
||||
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"知识点不存在"); |
||||
} |
||||
Set<Resources> resourcesSet = resourcesRepository.queryResourcesByKnowId(knowId); |
||||
return ResultUtils.success(resourcesSet); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,34 @@ |
||||
package com.teaching.backend.service.impl.resource; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.mapper.resource.ResourceMysqlMapper; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import com.teaching.backend.service.resource.IResourceMysqlService; |
||||
import org.apache.ibatis.annotations.Results; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
@Service |
||||
public class ResourceMysqlServiceImpl extends ServiceImpl<ResourceMysqlMapper, ResourceMysql> implements IResourceMysqlService { |
||||
private ResourceServiceImpl resourceService; |
||||
@Override |
||||
public BaseResponse<String> resourceUpload(MultipartFile file, ResourceMysql resourceMysql) { |
||||
System.out.println(1); |
||||
System.out.println(file); |
||||
String url = resourceService.upload(file).getData().getUrl(); |
||||
resourceMysql.setPath(url); |
||||
save(resourceMysql); |
||||
return ResultUtils.success("添加成功"); |
||||
} |
||||
} |
@ -0,0 +1,19 @@ |
||||
package com.teaching.backend.service.resource; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务类 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
public interface IResourceMysqlService extends IService<ResourceMysql> { |
||||
|
||||
BaseResponse<String> resourceUpload(MultipartFile file, ResourceMysql resourceMysql); |
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.teaching.backend.service.resource; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.model.entity.resource.Resources; |
||||
import org.springframework.core.io.InputStreamResource; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-07-26-13:55 |
||||
* @Description: |
||||
*/ |
||||
|
||||
public interface ResourceGraphService { |
||||
|
||||
public BaseResponse<String> deleteResourcesAndKnowById(Long id, Long resourcesId); |
||||
|
||||
BaseResponse<String> addResourcesByIdAndResourcesId(Long id, Long resourcesId); |
||||
|
||||
|
||||
//查询课程下资源
|
||||
BaseResponse<Set<Resources>> queryResourcesByCourseId(String courseId); |
||||
|
||||
//查询章节下资源
|
||||
BaseResponse<Set<Resources>> queryResourcesByChapterId(Long chapterId); |
||||
|
||||
//查询二级节点下资源
|
||||
BaseResponse<Set<Resources>> queryBesidesKnowToResources(Long knowId); |
||||
|
||||
BaseResponse<Set<Resources>> queryResourcesByKnowId(Long knowId); |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue