关于我们的添加

master
wenyu441069198 3 months ago
parent e5c79d8c90
commit e6f2c3401d
  1. 1029
      sql/teaching_db6.0.sql
  2. 8
      sql/teaching_db6.1.sql
  3. 4
      src/main/java/com/teaching/backend/controller/FavourInformation/FavourInformationController.java
  4. 12
      src/main/java/com/teaching/backend/controller/cms/CmsEssayController.java
  5. 4
      src/main/java/com/teaching/backend/controller/favour/SeKnowFavourController.java
  6. 4
      src/main/java/com/teaching/backend/controller/favour/SeResourceFavourController.java
  7. 2
      src/main/java/com/teaching/backend/controller/records/ResourceLearningRecordController.java
  8. 7
      src/main/java/com/teaching/backend/controller/resource/ResourceController.java
  9. 43
      src/main/java/com/teaching/backend/controller/resource/ResourceMysqlController.java
  10. 4
      src/main/java/com/teaching/backend/controller/thumb/SeKnowThumbController.java
  11. 4
      src/main/java/com/teaching/backend/controller/thumb/SeResourceThumbController.java
  12. 17
      src/main/java/com/teaching/backend/mapper/resource/ResourceMysqlMapper.java
  13. 2
      src/main/java/com/teaching/backend/mapper/resource/ResourcesRepository.java
  14. 65
      src/main/java/com/teaching/backend/model/entity/resource/ResourceMysql.java
  15. 2
      src/main/java/com/teaching/backend/service/cms/ICmsEssayService.java
  16. 26
      src/main/java/com/teaching/backend/service/impl/cms/CmsEssayServiceImpl.java
  17. 2
      src/main/java/com/teaching/backend/service/impl/records/RecordKnowledgeFinishServiceImpl.java
  18. 2
      src/main/java/com/teaching/backend/service/impl/records/RecordResourceFinishServiceImpl.java
  19. 5
      src/main/java/com/teaching/backend/service/impl/records/ResourceLearningRecordServiceImpl.java
  20. 34
      src/main/java/com/teaching/backend/service/impl/resource/ResourceMysqlServiceImpl.java
  21. 20
      src/main/java/com/teaching/backend/service/impl/resource/ResourceServiceImpl.java
  22. 2
      src/main/java/com/teaching/backend/service/records/IResourceLearningRecordService.java
  23. 19
      src/main/java/com/teaching/backend/service/resource/IResourceMysqlService.java
  24. 8
      src/main/java/com/teaching/backend/service/resource/ResourceService.java
  25. 0
      src/main/resources/mapper/IResourceMysqlService.xml

File diff suppressed because it is too large Load Diff

@ -239,10 +239,10 @@ INSERT INTO `objectives_type` VALUES (2, '知识目标');
INSERT INTO `objectives_type` VALUES (3, '素质目标');
-- ----------------------------
-- Table structure for resource
-- Table structure for resourceMysql
-- ----------------------------
DROP TABLE IF EXISTS `resource`;
CREATE TABLE `resource` (
DROP TABLE IF EXISTS `resourceMysql`;
CREATE TABLE `resourceMysql` (
`id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键',
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '资源名称',
`type` int(11) NULL DEFAULT NULL COMMENT '资源类型',
@ -253,7 +253,7 @@ CREATE TABLE `resource` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of resource
-- Records of resourceMysql
-- ----------------------------
-- ----------------------------

@ -7,7 +7,7 @@
//import com.teaching.backend.model.entity.resource.CourseResources;
//import org.springframework.web.bind.annotation.*;
//
//import javax.annotation.Resource;
//import javax.annotation.ResourceMysql;
//import java.util.List;
//
///**
@ -24,7 +24,7 @@
//public class FavourInformationController{
//
//
// @Resource
// @ResourceMysql
// CourseResourcesService courseResourcesService;
//
//

@ -59,7 +59,7 @@ public class CmsEssayController {
}
/**
* 查询文章
* 根据栏目id查询文章
* @param category_id
* @return
*/
@ -68,6 +68,16 @@ public class CmsEssayController {
return cmsEssayService.queryEssay(category_id);
}
/**
* 根据文章id查询文章
* @param essay_id
* @return
*/
@GetMapping("/queryessaybyid")
public BaseResponse<CmsEssay> queryEssayById(Integer essay_id){
return cmsEssayService.queryEssayById(essay_id);
}
/**
* 取消发布
* @param cmsEssay

@ -12,7 +12,7 @@
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import javax.annotation.ResourceMysql;
//
///**
// * @Author:youhang
@ -24,7 +24,7 @@
//@Slf4j
//public class SeKnowFavourController {
//
// @Resource
// @ResourceMysql
// private SeKnowFavourService seKnowFavourService;
//
//

@ -16,7 +16,7 @@
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import javax.annotation.ResourceMysql;
//
///**
// * @Author:youhang
@ -28,7 +28,7 @@
//@Slf4j
//public class SeResourceFavourController {
//
// @Resource
// @ResourceMysql
// private SeResourceFavourService seResourceFavourService;
//
//

@ -37,7 +37,7 @@ public class ResourceLearningRecordController {
// @ValidateParams({"userId","type","coursesId"})
@PostMapping("/saverecords")
public BaseResponse<String> saveResourceRecords(@RequestBody ResourceLearningRecord resourceLearningRecord) {
return resourceLearningRecordService.saveCoursesRecords(resourceLearningRecord);
return resourceLearningRecordService.saveResourceRecords(resourceLearningRecord);
}
/**

@ -8,11 +8,10 @@ package com.teaching.backend.controller.resource;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.dto.resource.ResourceUploadDto;
import com.teaching.backend.model.entity.resource.ResourceMysql;
import com.teaching.backend.model.entity.resource.Resources;
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;
@ -20,9 +19,6 @@ 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")
@ -55,4 +51,5 @@ public class ResourceController {
return resourceService.readFile(filename);
}
}

@ -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);
}
}

@ -12,7 +12,7 @@
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import javax.annotation.ResourceMysql;
//
///**
// * @Author:youhang
@ -24,7 +24,7 @@
//@Slf4j
//public class SeKnowThumbController {
//
// @Resource
// @ResourceMysql
// private SeKnowThumbService seKnowThumbService;
//
//

@ -12,7 +12,7 @@
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.annotation.Resource;
//import javax.annotation.ResourceMysql;
//
///**
// * @Author:youhang
@ -24,7 +24,7 @@
//@Slf4j
//public class SeResourceThumbController {
//
// @Resource
// @ResourceMysql
// private SeResourceThumbService seResourceThumbService;
//
//

@ -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> {
}

@ -74,7 +74,7 @@ public interface ResourcesRepository extends Neo4jRepository<Resources, Long> {
//
//
// @Query("MATCH(n:Know)-[r:resources]->(nn:Resources) where ID(nn) = $id RETURN nn")
// List<Resource> queryResourceAllId(Long id);
// List<ResourceMysql> queryResourceAllId(Long id);
//
// @Query("MATCH p = (a:Know)-[rels*]-(b:Resources) WHERE ID(a) = $KnowId and ANY(rel IN rels WHERE TYPE(rel) = 'resources') RETURN b")
// Set<Resources> queryCourseKnowToResources(Long KnowId);

@ -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;
}

@ -26,4 +26,6 @@ public interface ICmsEssayService extends IService<CmsEssay> {
BaseResponse<List<?>> queryEssay(Integer category_id);
BaseResponse<String> editStatus(CmsEssay cmsEssay);
BaseResponse<CmsEssay> queryEssayById(Integer essayId);
}

@ -25,19 +25,40 @@ public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> i
@Override
public BaseResponse<String> addEssay(CmsEssay cmsEssay) {
//设置文章发布时间
cmsEssay.setPublishTime(LocalDate.now());
//如果数据库里没有文章,文章id设为2
Long count = query().count();
if (count == 0){
cmsEssay.setId(2);
}
save(cmsEssay);
return ResultUtils.success("添加成功");
}
@Override
public BaseResponse<String> deleteEssay(List<Integer> ids) {
//如果要删除的文章中包含id为1的文章(就是包含关于我们)就删除失败
if (ids.contains(1)){
return ResultUtils.success("删除失败,不能删除关于我们!");
}
removeByIds(ids);
return ResultUtils.success("删除成功");
}
@Override
public BaseResponse<String> editEssay(CmsEssay cmsEssay) {
//获取要修改的文章id
Integer id = cmsEssay.getId();
//判断文章id是否为1
if (id == 1){
Long count = query().eq("id", id).count();
//如果数据库里没id为的文章就先新增
if (count == 0){
save(cmsEssay);
return ResultUtils.success("添加成功!");
}
}
updateById(cmsEssay);
return ResultUtils.success("编辑成功!");
}
@ -54,4 +75,9 @@ public class CmsEssayServiceImpl extends ServiceImpl<CmsEssayMapper, CmsEssay> i
updateById(cmsEssay);
return ResultUtils.success("修改成功");
}
@Override
public BaseResponse<CmsEssay> queryEssayById(Integer essayId) {
return ResultUtils.success(getById(essayId));
}
}

@ -53,11 +53,13 @@ public class RecordKnowledgeFinishServiceImpl extends ServiceImpl<RecordKnowledg
@Override
public void editFinish(ResourceLearningRecord resourceLearningRecord) {
System.out.println(resourceLearningRecord);
//设置完成状态
RecordKnowledgeFinish one = query()
.eq("course_id", resourceLearningRecord.getCoursesId())
.eq("knowledge_id", resourceLearningRecord.getKnowledgeId())
.eq("user_id", resourceLearningRecord.getUserId()).one();
System.out.println(one);
one.setFinish(1);
updateById(one);
}

@ -36,7 +36,7 @@ public class RecordResourceFinishServiceImpl extends ServiceImpl<RecordResourceF
recordResourceFinish.setKnowledgeId(resourceLearningRecord.getKnowledgeId());
recordResourceFinish.setResourceId(resourceLearningRecord.getResourceId());
recordResourceFinish.setFinish(resourceLearningRecord.getFinish());
System.out.println(recordResourceFinish);
System.out.println("资源完成:"+recordResourceFinish);
save(recordResourceFinish);
}

@ -40,7 +40,7 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
private RecordResourceFinishServiceImpl recordResourceFinishService;
@Override
public BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord) {
public BaseResponse<String> saveResourceRecords(ResourceLearningRecord resourceLearningRecord) {
//课程id
String courseId = resourceLearningRecord.getCoursesId();
String knowledgeId = resourceLearningRecord.getKnowledgeId();
@ -67,7 +67,7 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
.eq("course_id",courseId)
.eq("knowledge_id",knowledgeId)
.eq("resource_id",resourceId).update();
// System.out.println("用户:"+userId+"第一次学这门课");
System.out.println("用户:"+userId+"第一次学这门课");
//添加完成状态
recordResourceFinishService.addFinish(resourceLearningRecord);
}else {
@ -103,7 +103,6 @@ public class ResourceLearningRecordServiceImpl extends ServiceImpl<ResourceLearn
save(resourceLearningRecord);
return ResultUtils.success("添加成功");
}
@Override
public BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId) {
//格式化时间

@ -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("添加成功");
}
}

@ -1,42 +1,28 @@
package com.teaching.backend.service.impl.resource;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.constant.ViewContentTypeEnum;
import com.teaching.backend.mapper.know.KnowRepository;
import com.teaching.backend.mapper.resource.ResourcesRepository;
import com.teaching.backend.model.dto.resource.BucketPolicyConfigDto;
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.ResourceMysql;
import com.teaching.backend.model.entity.resource.Resources;
import com.teaching.backend.service.resource.ResourceService;
import com.teaching.backend.utils.MinioUtils;
import io.minio.*;
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.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
@ -115,8 +101,4 @@ public class ResourceServiceImpl implements ResourceService {
public ResponseEntity<InputStreamResource> readFile(String filename) {
return minioUtils.readFile(filename);
}
}

@ -18,7 +18,7 @@ import java.util.List;
*/
public interface IResourceLearningRecordService extends IService<ResourceLearningRecord> {
BaseResponse<String> saveCoursesRecords(ResourceLearningRecord resourceLearningRecord);
BaseResponse<String> saveResourceRecords(ResourceLearningRecord resourceLearningRecord);
BaseResponse<Page> getPage(int pagenum, int pagesize, String userId, String knowledgeId, String courseId);

@ -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);
}

@ -2,17 +2,12 @@ package com.teaching.backend.service.resource;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.dto.resource.ResourceUploadDto;
import com.teaching.backend.model.entity.resource.ResourceMysql;
import com.teaching.backend.model.entity.resource.Resources;
import org.springframework.core.io.InputStreamResource;
import org.springframework.data.neo4j.repository.query.Query;
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
@ -27,5 +22,4 @@ public interface ResourceService {
ResponseEntity<InputStreamResource> readFile(String filename);
}

Loading…
Cancel
Save