Merge remote-tracking branch 'origin/master'

master
Alan 5 months ago
commit ab87285e83
  1. 44
      pom.xml
  2. 2
      src/main/java/com/teaching/backend/common/CommonConstant.java
  3. 2
      src/main/java/com/teaching/backend/common/CommonResult.java
  4. 7
      src/main/java/com/teaching/backend/common/ErrorCode.java
  5. 2
      src/main/java/com/teaching/backend/common/IErrorCode.java
  6. 6
      src/main/java/com/teaching/backend/common/PageRequest.java
  7. 2
      src/main/java/com/teaching/backend/common/ResultCode.java
  8. 2
      src/main/java/com/teaching/backend/component/RestAuthenticationEntryPoint.java
  9. 2
      src/main/java/com/teaching/backend/component/RestfulAccessDeniedHandler.java
  10. 44
      src/main/java/com/teaching/backend/controller/FavourInformation/FavourInformationController.java
  11. 66
      src/main/java/com/teaching/backend/controller/courseResource/CourseResourceController.java
  12. 5
      src/main/java/com/teaching/backend/controller/courses/CoursesController.java
  13. 247
      src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java
  14. 97
      src/main/java/com/teaching/backend/controller/favour/SeKnowFavourController.java
  15. 120
      src/main/java/com/teaching/backend/controller/favour/SeResourceFavourController.java
  16. 12
      src/main/java/com/teaching/backend/controller/records/LearningRecordsController.java
  17. 67
      src/main/java/com/teaching/backend/controller/resource/ResourceController.java
  18. 152
      src/main/java/com/teaching/backend/controller/thumb/SeCourseThumbController.java
  19. 93
      src/main/java/com/teaching/backend/controller/thumb/SeKnowThumbController.java
  20. 93
      src/main/java/com/teaching/backend/controller/thumb/SeResourceThumbController.java
  21. 8
      src/main/java/com/teaching/backend/controller/umsAdmin/UmsAdminController.java
  22. 2
      src/main/java/com/teaching/backend/exception/ApiException.java
  23. 2
      src/main/java/com/teaching/backend/exception/Asserts.java
  24. 18
      src/main/java/com/teaching/backend/mapper/UserMapper.java
  25. 6
      src/main/java/com/teaching/backend/mapper/resource/CourseResourcesMapper.java
  26. 19
      src/main/java/com/teaching/backend/mapper/resource/ResourcesRelationshipMapper.java
  27. 6
      src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourQueryRequest.java
  28. 6
      src/main/java/com/teaching/backend/model/dto/favour/resourceFavour/ResourceFavourAddRequest.java
  29. 28
      src/main/java/com/teaching/backend/model/dto/favour/resourceFavour/ResourceFavourQueryRequest.java
  30. 48
      src/main/java/com/teaching/backend/model/dto/know/KnowAddRequest.java
  31. 6
      src/main/java/com/teaching/backend/model/dto/thumb/knowthumb/KnowThumbAddRequest.java
  32. 8
      src/main/java/com/teaching/backend/model/dto/thumb/resourcethumb/ResourceThumbAddRequest.java
  33. 23
      src/main/java/com/teaching/backend/model/entity/CourseResources.java
  34. 17
      src/main/java/com/teaching/backend/model/entity/ResourceRelationship.java
  35. 2
      src/main/java/com/teaching/backend/model/entity/favour/SeCourseFavour.java
  36. 7
      src/main/java/com/teaching/backend/model/entity/favour/SeKnowFavour.java
  37. 8
      src/main/java/com/teaching/backend/model/entity/favour/SeResourceFavour.java
  38. 11
      src/main/java/com/teaching/backend/model/entity/know/Know.java
  39. 2
      src/main/java/com/teaching/backend/model/entity/records/LearningRecords.java
  40. 2
      src/main/java/com/teaching/backend/model/entity/thumb/SeCourseThumb.java
  41. 8
      src/main/java/com/teaching/backend/model/entity/thumb/SeKnowThumb.java
  42. 8
      src/main/java/com/teaching/backend/model/entity/thumb/SeResourceThumb.java
  43. 23
      src/main/java/com/teaching/backend/service/FileTableService.java
  44. 16
      src/main/java/com/teaching/backend/service/UserService.java
  45. 134
      src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java
  46. 44
      src/main/java/com/teaching/backend/service/favour/SeKnowFavourService.java
  47. 50
      src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java
  48. 146
      src/main/java/com/teaching/backend/service/impl/CourseResourcesServiceImpl.java
  49. 97
      src/main/java/com/teaching/backend/service/impl/FileTableServiceImpl.java
  50. 21
      src/main/java/com/teaching/backend/service/impl/ResourcesRelationshipServiceImpl.java
  51. 24
      src/main/java/com/teaching/backend/service/impl/UserServiceImpl.java
  52. 24
      src/main/java/com/teaching/backend/service/impl/courses/CoursesServiceImpl.java
  53. 320
      src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java
  54. 135
      src/main/java/com/teaching/backend/service/impl/favour/SeKnowFavourServiceImpl.java
  55. 169
      src/main/java/com/teaching/backend/service/impl/favour/SeResourceFavourServiceImpl.java
  56. 12
      src/main/java/com/teaching/backend/service/impl/know/IknowServiceimpl.java
  57. 23
      src/main/java/com/teaching/backend/service/impl/know/KnowServiceimpl.java
  58. 9
      src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java
  59. 213
      src/main/java/com/teaching/backend/service/impl/thumb/SeCourseThumbServiceImpl.java
  60. 131
      src/main/java/com/teaching/backend/service/impl/thumb/SeKnowThumbServiceImpl.java
  61. 145
      src/main/java/com/teaching/backend/service/impl/thumb/SeResourceThumbServiceImpl.java
  62. 10
      src/main/java/com/teaching/backend/service/know/IknowService.java
  63. 12
      src/main/java/com/teaching/backend/service/know/KnowService.java
  64. 31
      src/main/java/com/teaching/backend/service/resource/CourseResourcesService.java
  65. 17
      src/main/java/com/teaching/backend/service/resource/ResourcesRelationshipService.java
  66. 73
      src/main/java/com/teaching/backend/service/thumb/SeCourseThumbService.java
  67. 45
      src/main/java/com/teaching/backend/service/thumb/SeKnowThumbService.java
  68. 44
      src/main/java/com/teaching/backend/service/thumb/SeResourceThumbService.java
  69. 80
      src/main/java/com/teaching/backend/utils/ParamOutAspect.java
  70. 84
      src/main/java/com/teaching/backend/utils/WordUtil.java
  71. 5
      src/main/resources/application.properties
  72. 70
      src/main/resources/application.yml
  73. BIN
      src/main/resources/img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png
  74. 76
      src/main/resources/static/hello.html
  75. 54
      src/main/resources/static/hello2.html
  76. 0
      src/main/resources/static/hello3.html
  77. 3
      src/main/resources/static/plugins/axios/axios.min.js
  78. 0
      src/main/resources/static/plugins/element-ui/fonts/element-icons.ttf
  79. 0
      src/main/resources/static/plugins/element-ui/fonts/element-icons.woff
  80. 1
      src/main/resources/static/plugins/element-ui/index.css
  81. 1
      src/main/resources/static/plugins/element-ui/index.js
  82. 11965
      src/main/resources/static/plugins/vue/vue.js
  83. BIN
      src/main/resources/templates/courses.docx
  84. 5
      src/test/java/com/teaching/TeachingBackendApplicationTests.java
  85. 3
      template.ftl

@ -57,6 +57,28 @@
</dependency>
<!-- Apache POI -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
@ -176,6 +198,28 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--这里写上main方法所在类的路径-->
<configuration>
<mainClass>com.teaching.TeachingBackendApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>docx</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
</plugins>
</build>

@ -1,4 +1,4 @@
package com.teaching.backend.api;
package com.teaching.backend.common;
public interface CommonConstant {

@ -1,4 +1,4 @@
package com.teaching.backend.api;
package com.teaching.backend.common;
/**
* @auther macrozheng

@ -28,6 +28,13 @@ public enum ErrorCode {
FORBIDDEN_ERROR(40300, "禁止访问"),
PARAMS_ILLEGAL(42000, "请求参数违法"),
PARAMS_NULL(4001,"参数为空"),
PARAMS_USER_NOTEXISTS(4002,"用户不存在"),
PARAMS_RESOURCE_NOTEXISTS(4003,"资源不存在"),
PARAMS_COURSE_NOTEXISTS(4004,"课程不存在"),
SYSTEM_ERROR(50000, "系统内部异常"),
OPERATION_ERROR(50001, "操作失败");

@ -1,4 +1,4 @@
package com.teaching.backend.api;
package com.teaching.backend.common;
/**
* @auther macrozheng

@ -2,12 +2,16 @@ package com.teaching.backend.common;
import com.teaching.backend.constant.CommonConstant;
import lombok.Data;
import lombok.*;
/**
* 分页请求
*/
@Data
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class PageRequest {
/**

@ -1,4 +1,4 @@
package com.teaching.backend.api;
package com.teaching.backend.common;
/**
* @auther macrozheng

@ -1,7 +1,7 @@
package com.teaching.backend.component;
import cn.hutool.json.JSONUtil;
import com.teaching.backend.api.CommonResult;
import com.teaching.backend.common.CommonResult;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

@ -1,7 +1,7 @@
package com.teaching.backend.component;
import cn.hutool.json.JSONUtil;
import com.teaching.backend.api.CommonResult;
import com.teaching.backend.common.CommonResult;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

@ -0,0 +1,44 @@
package com.teaching.backend.controller.FavourInformation;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.PageRequest;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.model.entity.CourseResources;
import com.teaching.backend.service.resource.CourseResourcesService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* ClassName: Get
* Package: com.teaching.backend.controller.FavourInformation
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/13 18:15
* @Version 1.0
*/
@RestController
public class FavourInformationController{
@Resource
CourseResourcesService courseResourcesService;
@GetMapping("/Favour/get")
public BaseResponse<Page<CourseResources>> getInformation2(@RequestParam List<Integer> resourceIdList , @RequestParam Integer type, PageRequest pageRequest) {
int page=pageRequest.getCurrent();
int pageSize=pageRequest.getPageSize();
Page<CourseResources> resourcesPage=courseResourcesService.getresourceRecords(type,resourceIdList,page,pageSize);
return ResultUtils.success(resourcesPage);
}
}

@ -0,0 +1,66 @@
package com.teaching.backend.controller.courseResource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.model.entity.CourseResources;
import com.teaching.backend.service.impl.CourseResourcesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/courses")
public class CourseResourceController {
@Autowired
private CourseResourcesServiceImpl courseResourcesService;
@GetMapping("/all")
public BaseResponse<List<CourseResources>> All(){
System.out.println("学习记录:"+courseResourcesService.list());
return ResultUtils.success(courseResourcesService.list());
}
@GetMapping("/getall")
public BaseResponse<Page> getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum,
@RequestParam(value = "pagesize", defaultValue = "10") int pagesize,
String type) {
List<CourseResources> cs = courseResourcesService.getByType(type);
List<CourseResources> pageCs = new ArrayList<>();
//当前页面
for(int i = (pagenum - 1) * pagesize; i < cs.size() && i < (pagenum) * pagesize; i++){
pageCs.add(cs.get(i));
}
long total = cs.size(); // 总记录数
Page<CourseResources> pageInfo = new Page<>(pagenum,pagesize,total);
pageInfo.setRecords(pageCs);
pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数
return ResultUtils.success(pageInfo);
}
/**
* 根据id删除
* @param ids
* @return
*/
@DeleteMapping("/delete")
public BaseResponse<String> deleteRecords(@RequestParam List<Long> ids){
// courseResourcesService.removeCourseResources(ids);
courseResourcesService.removeBatchByIds(ids);
return ResultUtils.success("删除成功!!");
}
/**
* 新增
* @param courseResources
* @return
*/
@GetMapping("/save")
public BaseResponse<String> saveCourseResource(@RequestBody CourseResources courseResources){
courseResourcesService.save(courseResources);
return ResultUtils.success("添加成功!");
}
}

@ -5,7 +5,7 @@ import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.UserMapper;
import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.courses.PageDTO;
@ -38,8 +38,7 @@ public class CoursesController {
@Autowired
ICoursesService coursesService;
@Autowired
UserMapper userMapper;
@ApiOperation("网站首页")
@GetMapping("/index")

@ -1,133 +1,114 @@
package com.teaching.backend.controller.favour;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAddRequest;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAllRequest;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourListRequest;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourQueryRequest;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import com.teaching.backend.service.favour.SeCourseFavourService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/course_favour")
@Slf4j
public class SeCourseFavourController {
@Resource
private SeCourseFavourService seCourseFavourService;
/**
* 点赞
*
* @param courseFavourAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doFavour(@RequestBody CourseFavourAddRequest courseFavourAddRequest) {
System.out.println(courseFavourAddRequest);
if (StringUtils.isAnyBlank(courseFavourAddRequest.getCourseId(), courseFavourAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// todo 从数据库中校验是否存在courseid , userid
Boolean result = seCourseFavourService.doCourseFavour(courseFavourAddRequest.getCourseId(), courseFavourAddRequest.getUserId());
return ResultUtils.success(result);
}
/**
* 课程点赞总数
*
* @param courseFavourAddRequest
* @return result 课程点赞总数
*/
@PostMapping("/count")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Long> favourCount(@RequestBody CourseFavourAddRequest courseFavourAddRequest) {
if (StringUtils.isAnyBlank(courseFavourAddRequest.getCourseId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数不能为空");
}
// todo 从数据库中校验是否存在courseid
Long result = seCourseFavourService.favourCount(courseFavourAddRequest.getCourseId());
return ResultUtils.success(result);
}
/**
* 课程下资源和知识点点赞总数
*
* @param courseFavourAllRequest
* @return result 课程下资源和知识点点赞总数
*/
@PostMapping("/countAll")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Long> courseCount(@RequestBody CourseFavourAllRequest courseFavourAllRequest) {
if (StringUtils.isAnyBlank(courseFavourAllRequest.getCourseId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数不能为空");
}
// todo 从数据库中校验是否存在courseid
Long result = seCourseFavourService.courseCount(courseFavourAllRequest.getCourseId());
return ResultUtils.success(result);
}
/**
* 某个用户课程列表
*
* @param courseFavourListRequest
* @return result 某个用户课程列表
*/
@PostMapping("/countList")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<List<String>> courseList(@RequestBody CourseFavourListRequest courseFavourListRequest) {
if (StringUtils.isAnyBlank(courseFavourListRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数-用户id不能为空");
}
// todo 从数据库中校验是否存在userid
List<String> result = seCourseFavourService.courseList(courseFavourListRequest.getUserId());
return ResultUtils.success(result);
}
/**
* 分页获取列表仅管理员
*
* @return
*/
@PostMapping("/list/page")
public BaseResponse<Page<CourseFavourDetailVO>> listPostByPage(@RequestBody CourseFavourQueryRequest courseFavourQueryRequest) {
long current = courseFavourQueryRequest.getCurrent();
long size = courseFavourQueryRequest.getPageSize();
String userId = courseFavourQueryRequest.getUserId();
List<String> ids = seCourseFavourService.courseList(userId);
QueryWrapper<Courses> courseQueryWrapper = new QueryWrapper<>();
courseQueryWrapper.in("id", ids);
Page<CourseFavourDetailVO> courseFavourDetailVOPage = seCourseFavourService.listCourseFavourByPage(new Page<>(current, size), courseQueryWrapper);
return ResultUtils.success(courseFavourDetailVOPage);
}
}
package com.teaching.backend.controller.favour;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAddRequest;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAllRequest;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourQueryRequest;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import com.teaching.backend.service.favour.SeCourseFavourService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/course_favour")
@Slf4j
public class SeCourseFavourController {
@Resource
private SeCourseFavourService seCourseFavourService;
/**
* 收藏/取消收藏
*
* @param courseFavourAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// 加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doFavour(@RequestBody CourseFavourAddRequest courseFavourAddRequest) {
System.out.println(courseFavourAddRequest);
//判断字段是否为空
if (StringUtils.isAnyBlank(courseFavourAddRequest.getCourseId(), courseFavourAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
return seCourseFavourService.doCourseFavour(courseFavourAddRequest.getCourseId(), courseFavourAddRequest.getUserId());
}
/**
* 课程点赞总数
*
* @param courseFavourAddRequest
* @return result 课程点赞总数
*/
@PostMapping("/count")
// HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Long> favourCount(@RequestBody CourseFavourAddRequest courseFavourAddRequest) {
if (StringUtils.isAnyBlank(courseFavourAddRequest.getCourseId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数不能为空");
}
return seCourseFavourService.favourCount(courseFavourAddRequest.getCourseId());
}
/**
* 课程下资源和知识点点赞总数
*
* @param courseFavourAllRequest
* @return result 课程下资源和知识点点赞总数
*/
@PostMapping("/countAll")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Long> courseCount(@RequestBody CourseFavourAllRequest courseFavourAllRequest) {
if (StringUtils.isAnyBlank(courseFavourAllRequest.getCourseId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数不能为空");
}
// todo 从数据库中校验是否存在courseid
return seCourseFavourService.courseCount(courseFavourAllRequest.getCourseId());
}
/**
* 分页获取课程列表
*
* @return
*/
@PostMapping("/list/page")
public BaseResponse<Page<CourseFavourDetailVO>> listPostByPage(@RequestBody CourseFavourQueryRequest courseFavourQueryRequest) {
System.out.println(courseFavourQueryRequest);
long current = courseFavourQueryRequest.getCurrent();
long size = courseFavourQueryRequest.getPageSize();
String userId = courseFavourQueryRequest.getUserId();
List<String> ids = seCourseFavourService.courseList(userId);
QueryWrapper<Courses> courseQueryWrapper = new QueryWrapper<>();
courseQueryWrapper.in("id", ids);
Page<CourseFavourDetailVO> courseFavourDetailVOPage = seCourseFavourService.listCourseFavourByPage(new Page<>(current, size), courseQueryWrapper);
return ResultUtils.success(courseFavourDetailVOPage);
}
}

@ -1,50 +1,47 @@
package com.teaching.backend.controller.favour;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.favour.knowFavour.KnowFavourAddRequest;
import com.teaching.backend.service.favour.SeKnowFavourService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/know_favour")
@Slf4j
public class SeKnowFavourController {
@Resource
private SeKnowFavourService seKnowFavourService;
/**
* 点赞
*
* @param knowFavourAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doFavour(@RequestBody KnowFavourAddRequest knowFavourAddRequest) {
if (StringUtils.isAnyBlank(knowFavourAddRequest.getCourseId(), knowFavourAddRequest.getKnowId(), knowFavourAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// todo 从数据库中校验是否存在knowid , userid ,courseid
Boolean result = seKnowFavourService.doKnowFavour(knowFavourAddRequest.getCourseId(), knowFavourAddRequest.getKnowId(), knowFavourAddRequest.getUserId());
return ResultUtils.success(result);
}
}
package com.teaching.backend.controller.favour;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.favour.knowFavour.KnowFavourAddRequest;
import com.teaching.backend.service.favour.SeKnowFavourService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/know_favour")
@Slf4j
public class SeKnowFavourController {
@Resource
private SeKnowFavourService seKnowFavourService;
/**
* 知识点收藏
*
* @param knowFavourAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// 加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doFavour(@RequestBody KnowFavourAddRequest knowFavourAddRequest) {
if (StringUtils.isAnyBlank(knowFavourAddRequest.getCourseId(), knowFavourAddRequest.getKnowId(), knowFavourAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
return seKnowFavourService.doKnowFavour( knowFavourAddRequest.getKnowId(), knowFavourAddRequest.getUserId());
}
}

@ -1,51 +1,69 @@
package com.teaching.backend.controller.favour;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.favour.resourceFavour.ResourceFavourAddRequest;
import com.teaching.backend.service.favour.SeResourceFavourService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/resource_favour")
@Slf4j
public class SeResourceFavourController {
@Resource
private SeResourceFavourService seResourceFavourService;
/**
* 收藏
*
* @param resourceFavourAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doFavour(@RequestBody ResourceFavourAddRequest resourceFavourAddRequest) {
if (StringUtils.isAnyBlank(resourceFavourAddRequest.getCourseId(), resourceFavourAddRequest.getResourceId(), resourceFavourAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// todo 从数据库中校验是否存在resourceid , userid ,courseid
Boolean result = seResourceFavourService.doResourceFavour(resourceFavourAddRequest.getCourseId(), resourceFavourAddRequest.getResourceId(), resourceFavourAddRequest.getUserId());
return ResultUtils.success(result);
}
}
package com.teaching.backend.controller.favour;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.favour.resourceFavour.ResourceFavourAddRequest;
import com.teaching.backend.model.dto.favour.resourceFavour.ResourceFavourQueryRequest;
import com.teaching.backend.model.entity.CourseResources;
import com.teaching.backend.service.favour.SeResourceFavourService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/resource_favour")
@Slf4j
public class SeResourceFavourController {
@Resource
private SeResourceFavourService seResourceFavourService;
/**
* 资源收藏
*
* @param resourceFavourAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// 加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doFavour(@RequestBody ResourceFavourAddRequest resourceFavourAddRequest) {
if (StringUtils.isAnyBlank(resourceFavourAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
return seResourceFavourService.doResourceFavour(resourceFavourAddRequest.getResourceId(), resourceFavourAddRequest.getUserId());
}
/**
* 分页获取资源列表
*
* @return
*/
@PostMapping("/list/page")
public BaseResponse<Page<CourseResources>> listPostByPage(@RequestBody ResourceFavourQueryRequest resourceFavourQueryRequest) {
Integer current = resourceFavourQueryRequest.getCurrent();
Integer size = resourceFavourQueryRequest.getPageSize();
String userId = resourceFavourQueryRequest.getUserId();
Integer type = resourceFavourQueryRequest.getType();
return ResultUtils.success(seResourceFavourService.listCourseFavourByPage(userId,type,current,size));
}
}

@ -43,13 +43,13 @@ public class LearningRecordsController {
long total = cs.size(); // 总记录数
Page<LearningRecordsVo> pageInfo = new Page<>(pagenum,pagesize,total);
pageInfo.setRecords(pageCs);
System.out.println("总记录数"+pageInfo.getTotal());
System.out.println("当前页面:"+pagenum);
System.out.println("当前页面大小:"+pagesize);
System.out.println("当前页面内容:"+pageCs);
System.out.println("页面数:"+pageInfo.getPages());
// System.out.println("总记录数"+pageInfo.getTotal());
// System.out.println("当前页面:"+pagenum);
// System.out.println("当前页面大小:"+pagesize);
// System.out.println("当前页面内容:"+pageCs);
// System.out.println("页面数:"+pageInfo.getPages());
pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数
System.out.println(pageInfo.getPages());
// System.out.println(pageInfo.getPages());
return ResultUtils.success(pageInfo);
}

@ -1,19 +1,12 @@
package com.teaching.backend.controller;
package com.teaching.backend.controller.resource;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.OSSObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.model.entity.FileTable;
import com.teaching.backend.service.FileTableService;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import com.teaching.backend.service.resource.CourseResourcesService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -22,12 +15,9 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.*;
import java.nio.file.Paths;
import java.util.Date;
import java.util.UUID;
/**
@ -40,11 +30,11 @@ import java.util.UUID;
* @Version 1.0
*/
@RestController
public class CommonController {
public class ResourceController {
@Resource
private FileTableService fileTableService;
private CourseResourcesService courseResourcesService;
@Value("${aliyun.oss.endpoint}")
private String endpoint;
@ -60,21 +50,28 @@ public class CommonController {
@PostMapping("/upload")
public BaseResponse<String> upload(@RequestParam("courseId") String courseId, MultipartFile file) throws IOException {
public BaseResponse<String> upload(MultipartFile file) throws IOException {
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
String originalFilename = file.getOriginalFilename();
String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
Integer Filetype;
String subDir;
if (suffix.equalsIgnoreCase(".jpg") || suffix.equalsIgnoreCase(".jpeg") || suffix.equalsIgnoreCase(".png")) {
subDir = "img/";
Filetype=1 ;
} else if (suffix.equalsIgnoreCase(".mp4") || suffix.equalsIgnoreCase(".avi") || suffix.equalsIgnoreCase(".mov")) {
subDir = "video/";
} else {
Filetype=2 ;
} else if (suffix.equalsIgnoreCase(".mp3") || suffix.equalsIgnoreCase(".wav") || suffix.equalsIgnoreCase(".flac")) {
subDir = "video/";
Filetype = 3;
}else {
subDir = "others/";
Filetype=4;
}
@ -84,9 +81,9 @@ public class CommonController {
ossClient.putObject(bucketName, subDir + fileName, file.getInputStream());
String objectUrl = ossClient.generatePresignedUrl(bucketName, subDir + fileName, new Date(System.currentTimeMillis() + 3600 * 1000)).toString();
fileTableService.updateFile(courseId, fileName, objectUrl); // 更新文件路径为OSS生成的URL
String objectUrl = "https://" + bucketName + "." + endpoint + "/" + subDir + fileName;
Integer type=Filetype;
courseResourcesService.updateFile(type, fileName, objectUrl); // 更新文件路径为OSS生成的URL
ossClient.shutdown();
@ -97,34 +94,14 @@ public class CommonController {
//文件下载
@GetMapping("/download")
public BaseResponse<String> download(@RequestParam String courseId, @RequestParam String path, HttpServletResponse response) throws IOException {
public BaseResponse<String> download(@RequestParam String Id, @RequestParam String path, HttpServletResponse response) throws IOException {
System.out.println("执行了下载的方法");
fileTableService.download(courseId,path,response,endpoint,accessKeyId,accessKeySecret,bucketName);
courseResourcesService.download(Id,path,response,endpoint,accessKeyId,accessKeySecret,bucketName);
return ResultUtils.success("成功");
}
@GetMapping("/get/record")
public BaseResponse<Page<FileTable>> pageBaseResponse(int page,int pageSize){
Page<FileTable> pageInfo=new Page<>(page,pageSize);
LambdaQueryWrapper<FileTable> lambdaQueryWrapper=new LambdaQueryWrapper<>();
fileTableService.page(pageInfo, lambdaQueryWrapper);
return ResultUtils.success(pageInfo);
}
}

@ -1,87 +1,65 @@
package com.teaching.backend.controller.thumb;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.thumb.coursethumb.CourseThumbAddRequest;
import com.teaching.backend.model.dto.thumb.coursethumb.CourseThumbAllRequest;
import com.teaching.backend.service.thumb.SeCourseThumbService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/course_thumb")
@Slf4j
public class SeCourseThumbController {
@Resource
private SeCourseThumbService seCourseThumbService;
/**
* 点赞/取消点赞
*
* @param courseThumbAddRequest
* @return result 执行情况
*/
@PostMapping("/")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doThumb(@RequestBody CourseThumbAddRequest courseThumbAddRequest) {
if (StringUtils.isAnyBlank(courseThumbAddRequest.getCourseId(), courseThumbAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// todo 从数据库中校验是否存在courseid , userid 从课程表和用户表查询
Boolean result = seCourseThumbService.doCourseThumb(courseThumbAddRequest.getCourseId(), courseThumbAddRequest.getUserId());
return ResultUtils.success(result);
}
/**
* 课程点赞总数
*
* @param courseThumbAddRequest
* @return result 课程点赞总数
*/
@PostMapping("/count")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Long> thumbCount(@RequestBody CourseThumbAddRequest courseThumbAddRequest) {
if (StringUtils.isAnyBlank(courseThumbAddRequest.getCourseId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数不能为空");
}
// todo 从数据库中校验是否存在courseid
Long result = seCourseThumbService.thumbCount(courseThumbAddRequest.getCourseId());
return ResultUtils.success(result);
}
/**
* 课程下资源和知识点点赞总数
*
* @param courseThumbAllRequest
* @return result 课程下资源和知识点点赞总数
*/
@PostMapping("/countAll")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Long> courseCount(@RequestBody CourseThumbAllRequest courseThumbAllRequest) {
if (StringUtils.isAnyBlank(courseThumbAllRequest.getCourseId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数不能为空");
}
// todo 从数据库中校验是否存在courseid
Long result = seCourseThumbService.courseCount(courseThumbAllRequest.getCourseId());
return ResultUtils.success(result);
}
}
package com.teaching.backend.controller.thumb;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.thumb.coursethumb.CourseThumbAddRequest;
import com.teaching.backend.model.dto.thumb.coursethumb.CourseThumbAllRequest;
import com.teaching.backend.service.thumb.SeCourseThumbService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/course_thumb")
@Slf4j
public class SeCourseThumbController {
@Resource
private SeCourseThumbService seCourseThumbService;
/**
* 点赞/取消点赞
*
* @param courseThumbAddRequest
* @return result 执行情况
*/
@PostMapping("/")
// HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doThumb(@RequestBody CourseThumbAddRequest courseThumbAddRequest) {
return seCourseThumbService.doCourseThumb(courseThumbAddRequest.getCourseId(), courseThumbAddRequest.getUserId());
}
/**
* 课程点赞总数
*
* @param courseThumbAddRequest
* @return result 课程点赞总数
*/
@PostMapping("/count")
// HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Long> thumbCount(@RequestBody CourseThumbAddRequest courseThumbAddRequest) {
if (StringUtils.isAnyBlank(courseThumbAddRequest.getCourseId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR, "请求参数不能为空");
}
return seCourseThumbService.thumbCount(courseThumbAddRequest.getCourseId());
}
}

@ -1,49 +1,44 @@
package com.teaching.backend.controller.thumb;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.thumb.knowthumb.KnowThumbAddRequest;
import com.teaching.backend.service.thumb.SeKnowThumbService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/know_thumb")
@Slf4j
public class SeKnowThumbController {
@Resource
private SeKnowThumbService seKnowThumbService;
/**
* 点赞
*
* @param knowThumbAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doThumb(@RequestBody KnowThumbAddRequest knowThumbAddRequest) {
if (StringUtils.isAnyBlank(knowThumbAddRequest.getCourseId(), knowThumbAddRequest.getKnowId(), knowThumbAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// todo 从数据库中校验是否存在knowid , userid ,courseid
Boolean result = seKnowThumbService.doKnowThumb(knowThumbAddRequest.getCourseId(), knowThumbAddRequest.getKnowId(), knowThumbAddRequest.getUserId());
return ResultUtils.success(result);
}
}
package com.teaching.backend.controller.thumb;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.thumb.knowthumb.KnowThumbAddRequest;
import com.teaching.backend.service.thumb.SeKnowThumbService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/know_thumb")
@Slf4j
public class SeKnowThumbController {
@Resource
private SeKnowThumbService seKnowThumbService;
/**
* 点赞
*
* @param knowThumbAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// 加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doThumb(@RequestBody KnowThumbAddRequest knowThumbAddRequest) {
return seKnowThumbService.doKnowThumb(knowThumbAddRequest.getKnowId(), knowThumbAddRequest.getUserId());
}
}

@ -1,49 +1,44 @@
package com.teaching.backend.controller.thumb;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.thumb.resourcethumb.ResourceThumbAddRequest;
import com.teaching.backend.service.thumb.SeResourceThumbService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/resource_thumb")
@Slf4j
public class SeResourceThumbController {
@Resource
private SeResourceThumbService seResourceThumbService;
/**
* 点赞
*
* @param resourceThumbAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doThumb(@RequestBody ResourceThumbAddRequest resourceThumbAddRequest) {
if (StringUtils.isAnyBlank(resourceThumbAddRequest.getCourseId(), resourceThumbAddRequest.getResourceId(), resourceThumbAddRequest.getUserId())) {
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
// todo 从数据库中校验是否存在resourceid , userid ,courseid
Boolean result = seResourceThumbService.doResourceThumb(resourceThumbAddRequest.getCourseId(), resourceThumbAddRequest.getResourceId(), resourceThumbAddRequest.getUserId());
return ResultUtils.success(result);
}
}
package com.teaching.backend.controller.thumb;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.thumb.resourcethumb.ResourceThumbAddRequest;
import com.teaching.backend.service.thumb.SeResourceThumbService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
@RestController
@RequestMapping("/resource_thumb")
@Slf4j
public class SeResourceThumbController {
@Resource
private SeResourceThumbService seResourceThumbService;
/**
* 点赞
*
* @param resourceThumbAddRequest
* @return result 执行情况
*/
@PostMapping("/add")
// 加上 HttpServletRequest request 在一个fitter里面进行鉴权操作
public BaseResponse<Boolean> doThumb(@RequestBody ResourceThumbAddRequest resourceThumbAddRequest) {
return seResourceThumbService.doResourceThumb( resourceThumbAddRequest.getResourceId(), resourceThumbAddRequest.getUserId());
}
}

@ -1,16 +1,12 @@
package com.teaching.backend.controller.umsAdmin;
import cn.hutool.core.collection.CollUtil;
import com.teaching.backend.api.CommonResult;
import com.teaching.backend.common.CommonResult;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.model.dto.UmsAdminParam;
import com.teaching.backend.model.dto.UpdateAdminPasswordParam;
import com.teaching.backend.model.dto.courses.CoursesDTO;
import com.teaching.backend.model.dto.umsAdmin.UmsStudentAndTeacherDTO;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.model.entity.umsAdmin.UmsRole;
import com.teaching.backend.model.vo.courses.TeacherInfVO;
@ -19,10 +15,8 @@ import com.teaching.backend.service.umsAdmin.UmsRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

@ -1,7 +1,7 @@
package com.teaching.backend.exception;
import com.teaching.backend.api.IErrorCode;
import com.teaching.backend.common.IErrorCode;
/**
* 自定义API异常

@ -1,7 +1,7 @@
package com.teaching.backend.exception;
import com.teaching.backend.api.IErrorCode;
import com.teaching.backend.common.IErrorCode;
/**
* 断言处理类用于抛出各种API异常

@ -1,18 +0,0 @@
package com.teaching.backend.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.User;
import org.apache.ibatis.annotations.Mapper;
/**
* ClassName: UserMapper
* Package: com.teaching.backend.mapper
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/3 17:47
* @Version 1.0
*/
@Mapper
public interface UserMapper extends BaseMapper<User> {
}

@ -1,7 +1,7 @@
package com.teaching.backend.mapper;
package com.teaching.backend.mapper.resource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.FileTable;
import com.teaching.backend.model.entity.CourseResources;
import org.apache.ibatis.annotations.Mapper;
/**
@ -14,5 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
* @Version 1.0
*/
@Mapper
public interface FileTableMapper extends BaseMapper<FileTable> {
public interface CourseResourcesMapper extends BaseMapper<CourseResources> {
}

@ -0,0 +1,19 @@
package com.teaching.backend.mapper.resource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teaching.backend.model.entity.ResourceRelationship;
import org.apache.ibatis.annotations.Mapper;
import org.apache.tomcat.websocket.BackgroundProcess;
/**
* ClassName: ResourcesRelationshipMapper
* Package: com.teaching.backend.mapper
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/12 21:07
* @Version 1.0
*/
@Mapper
public interface ResourcesRelationshipMapper extends BaseMapper<ResourceRelationship> {
}

@ -2,7 +2,7 @@ package com.teaching.backend.model.dto.favour.courseFavour;
import com.teaching.backend.common.PageRequest;
import com.teaching.backend.constant.CommonConstant;
import lombok.Data;
import lombok.*;
import java.io.Serializable;
@ -10,6 +10,9 @@ import java.io.Serializable;
* 课程点赞请求
*/
@Data
@Getter
@Setter
@ToString(callSuper = true)
public class CourseFavourQueryRequest extends PageRequest implements Serializable {
/**
@ -19,4 +22,5 @@ public class CourseFavourQueryRequest extends PageRequest implements Serializabl
private static final long serialVersionUID = 1L;
}

@ -10,15 +10,11 @@ import java.io.Serializable;
@Data
public class ResourceFavourAddRequest implements Serializable {
/**
* 课程 id
*/
private String courseId;
/**
* 知识点 id
*/
private String resourceId;
private Integer resourceId;
/**
* user id

@ -0,0 +1,28 @@
package com.teaching.backend.model.dto.favour.resourceFavour;
import com.teaching.backend.common.PageRequest;
import lombok.Data;
import java.io.Serializable;
/**
* 资源收藏请求
*/
@Data
public class ResourceFavourQueryRequest extends PageRequest implements Serializable {
/**
* 用户 id
*/
private String userId;
/**
* type
*/
private Integer type;
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,48 @@
package com.teaching.backend.model.dto.know;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 知识点请求
*/
@Data
public class KnowAddRequest implements Serializable {
/**
* 知识点名称
*/
private String name;
/**
* 简介
*/
private String info;
/**
* 知识点内容
*/
private String content;
/**
* 知识点图片
*/
private String img;
/**
* 知识点学时
*/
private BigDecimal hour;
/**
* 资源id 运用json
*/
private String resourceid;
}

@ -10,15 +10,11 @@ import java.io.Serializable;
@Data
public class KnowThumbAddRequest implements Serializable {
/**
* 课程 id
*/
private String courseId;
/**
* 知识点 id
*/
private String knowId;
private Integer knowId;
/**
* user id

@ -10,15 +10,11 @@ import java.io.Serializable;
@Data
public class ResourceThumbAddRequest implements Serializable {
/**
* 课程 id
*/
private String courseId;
/**
* 知识点 id
* 资源 id
*/
private String resourceId;
private Integer resourceId;
/**
* user id

@ -1,5 +1,7 @@
package com.teaching.backend.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -21,12 +23,23 @@ import java.util.stream.Stream;
@ToString
@NoArgsConstructor
@AllArgsConstructor
@TableName("filetable")
public class FileTable {
@TableName("Resource")
public class CourseResources {
@TableId(value = "id", type = IdType.AUTO)
private int id;
private String courseId;
private String fileName;
private String filePath;
private String name;
private int type;
private int status;
private String tags;
private String path;
/**
* 简介
*/
private String description;
/**
* 封面
*/
private String img;
}

@ -6,21 +6,24 @@ import lombok.NoArgsConstructor;
import lombok.ToString;
/**
* ClassName: User
* ClassName: ResourcesRelationship
* Package: com.teaching.backend.model.entity
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/3 17:42
* @Create 2024/6/12 21:03
* @Version 1.0
*/
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class User {
private int id;
private int userid;
private int bokeid;
private int type;
public class ResourceRelationship {
private String Id;
private String courseid;
private String chapterid;
private String knowid;
private String resourceid;
}

@ -17,7 +17,7 @@ public class SeCourseFavour implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@TableId(type = IdType.AUTO)
private Long id;
/**

@ -17,13 +17,10 @@ public class SeKnowFavour implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@TableId(type = IdType.AUTO)
private Long id;
/**
* 课程 id
*/
private String courseId;
/**
* 创建知识点 id

@ -17,18 +17,14 @@ public class SeResourceFavour implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@TableId(type = IdType.AUTO)
private Long id;
/**
* 课程 id
*/
private String courseId;
/**
* 创建知识点 id
*/
private String resourceId;
private Integer resourceId;
/**
* 创建用户 id

@ -17,7 +17,6 @@ import java.time.LocalDateTime;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("know")
public class Know implements Serializable {
@ -26,8 +25,8 @@ public class Know implements Serializable {
/**
* id
*/
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 知识点名称
@ -54,10 +53,12 @@ public class Know implements Serializable {
*/
private BigDecimal hour;
/**
* 知识点类型
* 资源id 运用json
*/
private String type;
private String resourceid;
}

@ -60,7 +60,7 @@ public class LearningRecords {
private String download;
/**
*视频学习时长
*/
*
private String videoDuration;
/**

@ -18,7 +18,7 @@ public class SeCourseThumb implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@TableId(type = IdType.AUTO)
private Long id;
/**

@ -17,18 +17,14 @@ public class SeKnowThumb implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@TableId(type = IdType.AUTO)
private Long id;
/**
* 课程 id
*/
private String courseId;
/**
* 创建知识点 id
*/
private String knowId;
private Integer knowId;
/**
* 创建用户 id

@ -17,18 +17,14 @@ public class SeResourceThumb implements Serializable {
/**
* id
*/
@TableId(type = IdType.ASSIGN_ID)
@TableId(type = IdType.AUTO)
private Long id;
/**
* 课程 id
*/
private String courseId;
/**
* 创建知识点 id
*/
private String resourceId;
private Integer resourceId;
/**
* 创建用户 id

@ -1,23 +0,0 @@
package com.teaching.backend.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.FileTable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* ClassName: FileTableService
* Package: com.teaching.backend.service
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/4 11:49
* @Version 1.0
*/
public interface FileTableService extends IService<FileTable> {
void updateFile(String courseId, String fileName, String filePath);
void download(String courseId, String path, HttpServletResponse response, String endpoint, String accessKeyId, String accessKeySecret, String bucketName) throws IOException;
}

@ -1,16 +0,0 @@
package com.teaching.backend.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.User;
/**
* ClassName: UserService
* Package: com.teaching.backend.service
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/3 17:48
* @Version 1.0
*/
public interface UserService extends IService<User> {
}

@ -1,69 +1,65 @@
package com.teaching.backend.service.favour;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourQueryRequest;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeCourseFavourService extends IService<SeCourseFavour> {
/**
* 收藏/取消收藏
*
* @param courseId
* @param userId
* @return
*/
boolean doCourseFavour(String courseId, String userId);
/**
* 收藏总数
*
* @param courseId
* @return
*/
long favourCount(String courseId);
/**
* 课程下资源和知识点的收藏总数
*
* @param courseId
* @return
*/
long courseCount(String courseId);
/**
* 某个用户课程列表
*
* @param userId
* @return
*/
List<String> courseList(String userId);
/**
* 某个用户课程列表全部信息
*
* @param page
* @param queryWrapper
* @return
*/
public Page<CourseFavourDetailVO> listCourseFavourByPage(Page<Courses> page, Wrapper<Courses> queryWrapper);
}
package com.teaching.backend.service.favour;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import java.util.List;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeCourseFavourService extends IService<SeCourseFavour> {
/**
* 收藏/取消收藏
*
* @param courseId
* @param userId
* @return
*/
BaseResponse<Boolean> doCourseFavour(String courseId, String userId);
/**
* 收藏总数
*
* @param courseId
* @return
*/
BaseResponse<Long> favourCount(String courseId);
/**
* 课程下资源和知识点的收藏总数
*
* @param courseId
* @return
*/
BaseResponse<Long> courseCount(String courseId);
/**
* 某个用户课程列表
*
* @param userId
* @return
*/
List<String> courseList(String userId);
/**
* 某个用户课程列表全部信息
*
* @param page
* @param queryWrapper
* @return
*/
public Page<CourseFavourDetailVO> listCourseFavourByPage(Page<Courses> page, Wrapper<Courses> queryWrapper);
}

@ -1,22 +1,22 @@
package com.teaching.backend.service.favour;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeKnowFavourService extends IService<SeKnowFavour> {
/**
* 收藏
*
* @param courseId
* @param userId
* @return
*/
boolean doKnowFavour(String courseId, String resourceId, String userId);
}
package com.teaching.backend.service.favour;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeKnowFavourService extends IService<SeKnowFavour> {
/**
* 收藏
*
* @param userId
* @return
*/
BaseResponse<Boolean> doKnowFavour(String resourceId, String userId);
}

@ -1,22 +1,28 @@
package com.teaching.backend.service.favour;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeResourceFavourService extends IService<SeResourceFavour> {
/**
* 收藏
*
* @param courseId
* @param userId
* @return
*/
boolean doResourceFavour(String courseId, String resourceId, String userId);
}
package com.teaching.backend.service.favour;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.CourseResources;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeResourceFavourService extends IService<SeResourceFavour> {
/**
* 收藏
*
* @param userId
* @return
*/
BaseResponse<Boolean> doResourceFavour( Integer resourceId, String userId);
public Page<CourseResources> listCourseFavourByPage(String userId, Integer type, Integer page, Integer pageSize);
}

@ -0,0 +1,146 @@
package com.teaching.backend.service.impl;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.OSSObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.resource.CourseResourcesMapper;
import com.teaching.backend.model.entity.CourseResources;
import com.teaching.backend.model.entity.ResourceRelationship;
import com.teaching.backend.service.resource.CourseResourcesService;
import com.teaching.backend.service.resource.ResourcesRelationshipService;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* ClassName: FileTableImpl
* Package: com.teaching.backend.service.impl
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/4 11:50
* @Version 1.0
*/
@Service
public class CourseResourcesServiceImpl extends ServiceImpl<CourseResourcesMapper, CourseResources> implements CourseResourcesService {
@Resource
ResourcesRelationshipService resourcesRelationshipService;
@Autowired
private CourseResourcesMapper courseResourcesMapper;
@Override
public void updateFile(Integer type, String fileName, String filePath) {
CourseResources courseResources = new CourseResources();
courseResources.setName(fileName);
courseResources.setPath(filePath);
courseResources.setType(type);
this.save(courseResources);
int resourceId=courseResources.getId();
System.out.println(resourceId);
ResourceRelationship resourcesRelationship=new ResourceRelationship();
resourcesRelationship.setResourceid(String.valueOf(resourceId));
resourcesRelationshipService.save(resourcesRelationship);
}
@Override
public void download(String Id, String path, HttpServletResponse response, String endpoint, String accessKeyId, String accessKeySecret, String bucketName) throws IOException {
CourseResources courseResources=getById(Id);
System.out.println(courseResources);
// 创建OSS客户端
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
String key = extractKeyFromFullPath(courseResources.getPath());
OSSObject object = ossClient.getObject(bucketName, key);
String fileName = courseResources.getName();
// 设置保存文件的路径
String savePath = path + "/" + fileName;
// 获取文件的输入流
InputStream inputStream = object.getObjectContent();
// 设置响应头
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
// 创建保存文件
File saveFile = new File(savePath);
// 将文件内容复制到保存文件中
FileUtils.copyInputStreamToFile(inputStream, saveFile);
// 关闭输入流和OSS客户端
inputStream.close();
ossClient.shutdown();
}
@Override
public Page<CourseResources> getresourceRecords(Integer type, List<Integer> resourceIdList, int page, int pageSize) {
Page <CourseResources> pageInfo=new Page<>(page,pageSize);
LambdaQueryWrapper<CourseResources>lambdaQueryWrapper=new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CourseResources::getId,resourceIdList);
lambdaQueryWrapper.eq(CourseResources::getType,type);
return this.page(pageInfo,lambdaQueryWrapper);
}
private String extractKeyFromFullPath(String filePath) {
// 提取存储桶名称
String key = filePath.substring(filePath.indexOf("com") + 4, filePath.indexOf("?"));
return key;
}
@Override
public List<CourseResources> getByType(String type) {
LambdaQueryWrapper<CourseResources> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CourseResources::getType, type);
List<CourseResources> list = this.list(lambdaQueryWrapper);
return list;
}
@Override
public void removeCourseResources(List<Long> ids) {
LambdaQueryWrapper<CourseResources> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CourseResources::getId, ids);
List<CourseResources> list = this.list(lambdaQueryWrapper);
courseResourcesMapper.deleteBatchIds(list);
// System.out.println(this.updateBatchById(list));
// this.remove(lambdaQueryWrapper);
}
}

@ -1,97 +0,0 @@
package com.teaching.backend.service.impl;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.OSSObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.FileTableMapper;
import com.teaching.backend.model.entity.FileTable;
import com.teaching.backend.service.FileTableService;
import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
* ClassName: FileTableImpl
* Package: com.teaching.backend.service.impl
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/4 11:50
* @Version 1.0
*/
@Service
public class FileTableServiceImpl extends ServiceImpl<FileTableMapper,FileTable> implements FileTableService {
@Override
public void updateFile(String courseId, String fileName, String filePath) {
System.out.println("执行了service中的方法");
System.out.println(courseId);
System.out.println(fileName);
System.out.println(filePath);
FileTable fileTable = new FileTable();
fileTable.setFileName(fileName);
fileTable.setFilePath(filePath);
// fileTable.setCourseId(courseId); // 设置主键值
//
// this.save(fileTable); // 使用save方法来添加新的记录
UpdateWrapper<FileTable> fileTableUpdateWrapper = new UpdateWrapper<>();
fileTableUpdateWrapper.eq("course_id", courseId);
this.update(fileTable, fileTableUpdateWrapper);
}
@Override
public void download(String courseId, String path, HttpServletResponse response, String endpoint, String accessKeyId, String accessKeySecret, String bucketName) throws IOException {
FileTable fileTable = this.getById(courseId);
System.out.println(fileTable);
// 创建OSS客户端
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
String key = extractKeyFromFullPath(fileTable.getFilePath());
OSSObject object = ossClient.getObject(bucketName, key);
String fileName = fileTable.getFileName();
// 设置保存文件的路径
String savePath = path + "/" + fileName;
// 获取文件的输入流
InputStream inputStream = object.getObjectContent();
// 设置响应头
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
// 创建保存文件
File saveFile = new File(savePath);
// 将文件内容复制到保存文件中
FileUtils.copyInputStreamToFile(inputStream, saveFile);
// 关闭输入流和OSS客户端
inputStream.close();
ossClient.shutdown();
}
private String extractKeyFromFullPath(String filePath) {
// 提取存储桶名称
String key = filePath.substring(filePath.indexOf("com") + 4, filePath.indexOf("?"));
return key;
}
}

@ -0,0 +1,21 @@
package com.teaching.backend.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.resource.ResourcesRelationshipMapper;
import com.teaching.backend.model.entity.ResourceRelationship;
import com.teaching.backend.service.resource.ResourcesRelationshipService;
import org.springframework.stereotype.Service;
/**
* ClassName: ResourcesRelationshipServiceImpl
* Package: com.teaching.backend.service.impl
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/12 21:05
* @Version 1.0
*/
@Service
public class ResourcesRelationshipServiceImpl extends ServiceImpl<ResourcesRelationshipMapper, ResourceRelationship> implements ResourcesRelationshipService {
}

@ -1,24 +0,0 @@
package com.teaching.backend.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.UserMapper;
import com.teaching.backend.model.entity.User;
import com.teaching.backend.service.UserService;
import org.springframework.stereotype.Service;
/**
* ClassName: UserServiceImpl
* Package: com.teaching.backend.service.impl
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/3 17:48
* @Version 1.0
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
}

@ -26,6 +26,8 @@ import com.teaching.backend.model.vo.courses.CoursesVO;
import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.utils.CourseCode;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -123,7 +125,6 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
} else {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "这个课程已经存在了!请联系系统相关人员为您导入课程数据!");
}
}
@Override
@ -324,7 +325,7 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
//准备导出数据
//查询课程通过课程id查--课程简介
Courses courses = this.getById(id);
System.out.println("课程:"+courses);
// System.out.println("课程:"+courses);
//准备数据
String course_name = courses.getName();
String course_code = courses.getCode();
@ -336,12 +337,12 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
//查询课程目标
List<CourseObjectivesTreeVO> courseObjectivesTreeVO = objectivesService.queryCourseObjectivesTree(id);
System.out.println("课程目标:"+courseObjectivesTreeVO);
// System.out.println("课程目标:"+courseObjectivesTreeVO);
//准备数据
//总目标
StringBuilder overall_goal = new StringBuilder();
for (ObjectiveContents content : courseObjectivesTreeVO.get(0).getContents()) {
overall_goal.append(content.getContent());
overall_goal.append("\r\n ").append(content.getContent());
}
System.out.println(overall_goal);
@ -350,24 +351,26 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
StringBuilder knowledge_goals = new StringBuilder();
StringBuilder political_goals = new StringBuilder();
StringBuilder value_goals = new StringBuilder();
for (int i = 0; i < courseObjectivesTreeVO.get(0).getCourseObjectivesTrees().size(); i++){
CourseObjectivesTreeVO content = courseObjectivesTreeVO.get(0).getCourseObjectivesTrees().get(i);
//知识目标
if (i == 0){
for (ObjectiveContents c : content.getContents()) {
knowledge_goals.append(c.getContent()).append("\n");
knowledge_goals.append("\r\n ").append(c.getContent());
}
}
//思政目标
if (i == 1){
for (ObjectiveContents c : content.getContents()) {
political_goals.append(c.getContent()).append("\n");
political_goals.append("\r\n ").append(c.getContent());
}
}
//价值目标
if (i == 2){
for (ObjectiveContents c : content.getContents()) {
value_goals.append(c.getContent()).append("\n");
value_goals.append("\r\n ").append(c.getContent());
}
}
}
@ -389,8 +392,13 @@ public class CoursesServiceImpl extends ServiceImpl<CoursesMapper, Courses> impl
params.put("political_goals", political_goals);
params.put("value_goals", value_goals);
//导出图片
params.put("img","wyii\t");
//根据模板+数据 导出文档
XWPFDocument xwpfDocument = WordExportUtil.exportWord07(templatePath.getPath(), params);

@ -1,155 +1,165 @@
package com.teaching.backend.service.impl.favour;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.favour.SeCourseFavourMapper;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.service.favour.SeCourseFavourService;
import com.teaching.backend.service.favour.SeKnowFavourService;
import com.teaching.backend.service.favour.SeResourceFavourService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeCourseFavourServiceImpl extends ServiceImpl<SeCourseFavourMapper, SeCourseFavour> implements SeCourseFavourService {
@Resource
private SeResourceFavourService seResourceFavourService;
@Resource
SeKnowFavourService seKnowFavourService;
@Autowired
ICoursesService coursesService;
@Override
public boolean doCourseFavour(String courseId, String userId) {
System.out.println("进入点赞" + courseId + userId);
// todo 先查询数据库记录,该用户是否点赞
SeCourseFavour seCourseFavour = new SeCourseFavour();
seCourseFavour.setCourseId(courseId);
seCourseFavour.setUserId(userId);
QueryWrapper<SeCourseFavour> favourQueryWrapper = new QueryWrapper<>(seCourseFavour);
SeCourseFavour oldSeCourseFavour = this.getOne(favourQueryWrapper);
boolean result = false;
//已点赞
if (oldSeCourseFavour != null) {
// 取消点赞 删除记录
result = this.remove(favourQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return result;
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seCourseFavour);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return result;
}
}
}
@Override
public long favourCount(String courseId) {
System.out.println("进入课程点赞统计" + courseId);
QueryWrapper<SeCourseFavour> favourQueryWrapper = new QueryWrapper<>();
favourQueryWrapper.eq("course_id", courseId);
long result = this.count(favourQueryWrapper);
if (result == 0) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询参数不存在");
} else {
return result;
}
}
@Override
public long courseCount(String courseId) {
System.out.println("进入课程下资源和知识点的点赞统计" + courseId);
QueryWrapper<SeResourceFavour> ResourceQueryWrapper = new QueryWrapper<>();
ResourceQueryWrapper.eq("course_id", courseId);
long result1 = seResourceFavourService.count(ResourceQueryWrapper);
QueryWrapper<SeKnowFavour> KnowQueryWrapper = new QueryWrapper<>();
KnowQueryWrapper.eq("course_id", courseId);
long result2 = seKnowFavourService.count(KnowQueryWrapper);
long result = result1 + result2;
if (result == 0) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询参数不存在");
} else {
return result;
}
}
/**
* 某个用户课程列表
*
* @param userId
* @return
*/
@Override
public List<String> courseList(String userId) {
QueryWrapper<SeCourseFavour> courseQueryWrapper = new QueryWrapper<>();
courseQueryWrapper.eq("user_id", userId);
List<String> list = this.list(courseQueryWrapper).stream().map(SeCourseFavour::getCourseId).collect(Collectors.toList());
return list;
}
@Override
public Page<CourseFavourDetailVO> listCourseFavourByPage(Page<Courses> page, Wrapper<Courses> queryWrapper) {
Page<Courses> coursePage = coursesService.page(page, queryWrapper);
Page<CourseFavourDetailVO> courseFavourVOPage = new Page<>(coursePage.getCurrent(), coursePage.getSize(), coursePage.getTotal());
List<Courses> courseFavourList = coursePage.getRecords();
//若数据为空,直接返回
if (CollUtil.isEmpty(courseFavourList)) {
return courseFavourVOPage;
}
//过滤字段
List<CourseFavourDetailVO> courseFavourDetailVOList = new ArrayList<>();
for (int i = 0; i < courseFavourList.size(); i++) {
CourseFavourDetailVO courseFavourDetailVO = new CourseFavourDetailVO();
BeanUtils.copyProperties(courseFavourList.get(i), courseFavourDetailVO);
courseFavourDetailVOList.add(courseFavourDetailVO);
}
courseFavourVOPage.setRecords(courseFavourDetailVOList);
return courseFavourVOPage;
}
}
package com.teaching.backend.service.impl.favour;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.favour.SeCourseFavourMapper;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeCourseFavour;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
import com.teaching.backend.model.vo.favour.CourseFavourDetailVO;
import com.teaching.backend.service.courses.ICoursesService;
import com.teaching.backend.service.favour.SeCourseFavourService;
import com.teaching.backend.service.favour.SeKnowFavourService;
import com.teaching.backend.service.favour.SeResourceFavourService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeCourseFavourServiceImpl extends ServiceImpl<SeCourseFavourMapper, SeCourseFavour> implements SeCourseFavourService {
@Resource
private SeResourceFavourService seResourceFavourService;
@Resource
SeKnowFavourService seKnowFavourService;
@Autowired
CoursesMapper coursesMapper;
@Autowired
ICoursesService coursesService;
@Override
public BaseResponse<Boolean> doCourseFavour(String courseId, String userId) {
System.out.println("进入点赞" + courseId + userId);
//从数据库中校验是否存在courseid
Courses courses = coursesMapper.selectById(courseId);
boolean result = false;
if(courses == null){
return ResultUtils.error(ErrorCode.NOT_FOUND_ERROR,"课程不存在");
}
//查询数据库记录,该用户是否点赞
SeCourseFavour seCourseFavour = new SeCourseFavour();
seCourseFavour.setCourseId(courseId);
seCourseFavour.setUserId(userId);
QueryWrapper<SeCourseFavour> favourQueryWrapper = new QueryWrapper<>(seCourseFavour);
SeCourseFavour oldSeCourseFavour = this.getOne(favourQueryWrapper);
//已点赞
if (oldSeCourseFavour != null) {
// 取消点赞 删除记录
result = this.remove(favourQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return ResultUtils.success(result);
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seCourseFavour);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return ResultUtils.success(result);
}
}
}
@Override
public BaseResponse<Long>favourCount(String courseId) {
//从数据库中校验是否存在courseid
QueryWrapper<SeCourseFavour> favourQueryWrapper = new QueryWrapper<>();
favourQueryWrapper.eq("course_id", courseId);
long result = this.count(favourQueryWrapper);
if (result == 0) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询参数不存在");
} else {
return ResultUtils.success(result);
}
}
@Override
public BaseResponse<Long> courseCount(String courseId) {
QueryWrapper<SeResourceFavour> ResourceQueryWrapper = new QueryWrapper<>();
ResourceQueryWrapper.eq("course_id", courseId);
long result1 = seResourceFavourService.count(ResourceQueryWrapper);
QueryWrapper<SeKnowFavour> KnowQueryWrapper = new QueryWrapper<>();
KnowQueryWrapper.eq("course_id", courseId);
long result2 = seKnowFavourService.count(KnowQueryWrapper);
long result = result1 + result2;
if (result == 0) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询参数不存在");
} else {
return ResultUtils.success(result);
}
}
/**
* 某个用户课程列表
*
* @param userId
* @return
*/
@Override
public List<String> courseList(String userId) {
QueryWrapper<SeCourseFavour> courseQueryWrapper = new QueryWrapper<>();
courseQueryWrapper.eq("user_id", userId);
List<String> list = this.list(courseQueryWrapper).stream().map(SeCourseFavour::getCourseId).collect(Collectors.toList());
return list;
}
@Override
public Page<CourseFavourDetailVO> listCourseFavourByPage(Page<Courses> page, Wrapper<Courses> queryWrapper) {
Page<Courses> coursePage = coursesService.page(page, queryWrapper);
Page<CourseFavourDetailVO> courseFavourVOPage = new Page<>(coursePage.getCurrent(), coursePage.getSize(), coursePage.getTotal());
List<Courses> courseFavourList = coursePage.getRecords();
//若数据为空,直接返回
if (CollUtil.isEmpty(courseFavourList)) {
return courseFavourVOPage;
}
//过滤字段
List<CourseFavourDetailVO> courseFavourDetailVOList = new ArrayList<>();
for (int i = 0; i < courseFavourList.size(); i++) {
CourseFavourDetailVO courseFavourDetailVO = new CourseFavourDetailVO();
BeanUtils.copyProperties(courseFavourList.get(i), courseFavourDetailVO);
courseFavourDetailVOList.add(courseFavourDetailVO);
}
courseFavourVOPage.setRecords(courseFavourDetailVOList);
return courseFavourVOPage;
}
}

@ -1,64 +1,71 @@
package com.teaching.backend.service.impl.favour;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.favour.SeKnowFavourMapper;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
import com.teaching.backend.service.favour.SeKnowFavourService;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeKnowFavourServiceImpl extends ServiceImpl<SeKnowFavourMapper, SeKnowFavour> implements SeKnowFavourService {
@Override
public boolean doKnowFavour(String courseId, String knowId, String userId) {
System.out.println("进入知识点点赞" + knowId + userId);
// 先查询数据库记录,该用户是否点赞
SeKnowFavour seKnowFavour = new SeKnowFavour();
seKnowFavour.setKnowId(knowId);
seKnowFavour.setUserId(userId);
seKnowFavour.setCourseId(courseId);
QueryWrapper<SeKnowFavour> favourQueryWrapper = new QueryWrapper<>(seKnowFavour);
SeKnowFavour oldSeKnowFavour = this.getOne(favourQueryWrapper);
boolean result = false;
//已点赞
if (oldSeKnowFavour != null) {
// 取消点赞 删除记录
result = this.remove(favourQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return result;
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seKnowFavour);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return result;
}
}
}
}
package com.teaching.backend.service.impl.favour;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.favour.SeKnowFavourMapper;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeKnowFavour;
import com.teaching.backend.service.favour.SeKnowFavourService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeKnowFavourServiceImpl extends ServiceImpl<SeKnowFavourMapper, SeKnowFavour> implements SeKnowFavourService {
@Autowired
CoursesMapper coursesMapper;
@Override
public BaseResponse<Boolean> doKnowFavour( String knowId, String userId) {
// todo 判断知识点id是否存在
boolean result = false;
// 先查询数据库记录,该用户是否收藏
SeKnowFavour seKnowFavour = new SeKnowFavour();
seKnowFavour.setKnowId(knowId);
seKnowFavour.setUserId(userId);
QueryWrapper<SeKnowFavour> favourQueryWrapper = new QueryWrapper<>(seKnowFavour);
SeKnowFavour oldSeKnowFavour = this.getOne(favourQueryWrapper);
//已收藏
if (oldSeKnowFavour != null) {
// 取消收藏 删除记录
result = this.remove(favourQueryWrapper);
if (result) {
System.out.println("取消收藏成功");
return ResultUtils.success(result);
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行收藏
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seKnowFavour);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
// System.out.println("收藏成功");
return ResultUtils.success(result);
}
}
}
}

@ -1,65 +1,104 @@
package com.teaching.backend.service.impl.favour;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.favour.SeResourceFavourMapper;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
import com.teaching.backend.service.favour.SeResourceFavourService;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeResourceFavourServiceImpl extends ServiceImpl<SeResourceFavourMapper, SeResourceFavour> implements SeResourceFavourService {
@Override
public boolean doResourceFavour(String courseId, String resourceId, String userId) {
System.out.println("进入知识点点赞" + resourceId + userId);
// 先查询数据库记录,该用户是否点赞
SeResourceFavour seResourceFavour = new SeResourceFavour();
seResourceFavour.setResourceId(resourceId);
seResourceFavour.setUserId(userId);
seResourceFavour.setCourseId(courseId);
QueryWrapper<SeResourceFavour> thumbQueryWrapper = new QueryWrapper<>(seResourceFavour);
SeResourceFavour oldSeResourceFavour = this.getOne(thumbQueryWrapper);
boolean result = false;
//已点赞
if (oldSeResourceFavour != null) {
// 取消点赞 删除记录
result = this.remove(thumbQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return result;
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seResourceFavour);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return result;
}
}
}
}
package com.teaching.backend.service.impl.favour;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.favour.SeResourceFavourMapper;
import com.teaching.backend.mapper.resource.CourseResourcesMapper;
import com.teaching.backend.mapper.umsAdmin.UmsAdminMapper;
import com.teaching.backend.model.entity.CourseResources;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.favour.SeResourceFavour;
import com.teaching.backend.model.entity.umsAdmin.UmsAdmin;
import com.teaching.backend.service.resource.CourseResourcesService;
import com.teaching.backend.service.favour.SeResourceFavourService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeResourceFavourServiceImpl extends ServiceImpl<SeResourceFavourMapper, SeResourceFavour> implements SeResourceFavourService {
@Autowired
CoursesMapper coursesMapper;
@Autowired
private CourseResourcesService courseResourcesService;
@Autowired
private UmsAdminMapper umsAdminMapper;
@Autowired
private CourseResourcesMapper courseResourcesMapper;
@Override
public BaseResponse<Boolean> doResourceFavour(Integer resourceId, String userId) {
boolean result = false;
CourseResources courseResources = courseResourcesMapper.selectById(resourceId);
if(courseResources == null){
throw new BusinessException(ErrorCode.PARAMS_RESOURCE_NOTEXISTS);
}
// 先查询数据库记录,该用户是否收藏
SeResourceFavour seResourceFavour = new SeResourceFavour();
seResourceFavour.setResourceId(resourceId);
seResourceFavour.setUserId(userId);
QueryWrapper<SeResourceFavour> thumbQueryWrapper = new QueryWrapper<>(seResourceFavour);
SeResourceFavour oldSeResourceFavour = this.getOne(thumbQueryWrapper);
//已收藏
if (oldSeResourceFavour != null) {
// 取消收藏 删除记录
result = this.remove(thumbQueryWrapper);
if (result) {
System.out.println("取消收藏成功");
return ResultUtils.success(result);
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行收藏
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seResourceFavour);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("收藏成功");
return ResultUtils.success(result);
}
}
}
@Override
public Page<CourseResources> listCourseFavourByPage(String userId, Integer type, Integer page, Integer pageSize) {
UmsAdmin umsAdmin = umsAdminMapper.selectById(userId);
if(umsAdmin == null){
throw new BusinessException(ErrorCode.PARAMS_USER_NOTEXISTS);
}
QueryWrapper<SeResourceFavour> resourceQueryWrapper = new QueryWrapper<>();
resourceQueryWrapper.eq("user_id",userId);
List<Integer> ids = this.list(resourceQueryWrapper).stream().map(SeResourceFavour::getResourceId).collect(Collectors.toList());
return courseResourcesService.getresourceRecords(type,ids,page,pageSize);
}
}

@ -1,12 +0,0 @@
package com.teaching.backend.service.impl.know;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.know.KnowMapper;
import com.teaching.backend.model.entity.know.Know;
import com.teaching.backend.service.know.IknowService;
import org.springframework.stereotype.Service;
@Service
public class IknowServiceimpl extends ServiceImpl<KnowMapper,Know> implements IknowService {
}

@ -0,0 +1,23 @@
package com.teaching.backend.service.impl.know;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.mapper.know.KnowMapper;
import com.teaching.backend.model.dto.favour.knowFavour.KnowFavourAddRequest;
import com.teaching.backend.model.dto.know.KnowAddRequest;
import com.teaching.backend.model.entity.know.Know;
import com.teaching.backend.service.know.KnowService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class KnowServiceimpl extends ServiceImpl<KnowMapper,Know> implements KnowService {
@Autowired
private KnowMapper knowMapper;
@Override
public Boolean add(KnowAddRequest knowAddRequest) {
Know know = new Know();
BeanUtils.copyProperties(knowAddRequest,know);
return (save(know));
}
}

@ -11,7 +11,7 @@ import com.teaching.backend.model.entity.records.LearningRecords;
import com.teaching.backend.model.vo.records.LearningRecordsVo;
import com.teaching.backend.service.impl.chapter.ChapterServiceImpl;
import com.teaching.backend.service.impl.courses.CoursesServiceImpl;
import com.teaching.backend.service.impl.know.IknowServiceimpl;
import com.teaching.backend.service.impl.know.KnowServiceimpl;
import com.teaching.backend.service.records.LearningRecordsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -34,7 +34,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
// @Autowired
// private LearningResourceServiceImpl learningResourceService;
@Autowired
private IknowServiceimpl knowledgePointService;
private KnowServiceimpl knowledgePointService;
@Autowired
private ChapterServiceImpl chapterService;
@ -103,9 +103,10 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
break;
case "1": //如果是课程学习记录
System.out.println();
learningRecordsVo.setCoursesName(coursesService.getById(learningRecords.getCoursesId()).getName());
System.out.println(coursesService.getById(learningRecords.getCoursesId()).getName());
break;
}
//添加观看人数
//统计记录表里有多少人查看过这门资源
@ -142,7 +143,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl<LearningRecordsMappe
learningRecords.setAccessTime(LocalDateTime.now());
//设置默认封面
if (learningRecords.getContent() == null || learningRecords.getContent().equals("")){
learningRecords.setContent("https://teaching-edu123.oss-cn-beijing.aliyuncs.com/Borovets_ZH-CN5914681811_UHD.jpg");
learningRecords.setContent("img/v2-c57eb7863ec4233f503176ca3f90f8d5_1440w.png");
}
// //添加记录封面
// switch (learningRecords.getType()) {

@ -1,105 +1,108 @@
package com.teaching.backend.service.impl.thumb;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.thumb.SeCourseThumbMapper;
import com.teaching.backend.model.entity.thumb.SeCourseThumb;
import com.teaching.backend.model.entity.thumb.SeKnowThumb;
import com.teaching.backend.model.entity.thumb.SeResourceThumb;
import com.teaching.backend.service.thumb.SeCourseThumbService;
import com.teaching.backend.service.thumb.SeKnowThumbService;
import com.teaching.backend.service.thumb.SeResourceThumbService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeCourseThumbServiceImpl extends ServiceImpl<SeCourseThumbMapper, SeCourseThumb> implements SeCourseThumbService {
@Resource
private SeResourceThumbService seResourceThumbService;
@Resource
SeKnowThumbService seKnowThumbService;
@Override
public boolean doCourseThumb(String courseId, String userId) {
System.out.println("进入点赞" + courseId + userId);
// 先查询数据库记录,该用户是否点赞
SeCourseThumb seCourseThumb = new SeCourseThumb();
seCourseThumb.setCourseId(courseId);
seCourseThumb.setUserId(userId);
QueryWrapper<SeCourseThumb> thumbQueryWrapper = new QueryWrapper<>(seCourseThumb);
SeCourseThumb oldSeCourseThumb = this.getOne(thumbQueryWrapper);
boolean result = false;
//已点赞
if (oldSeCourseThumb != null) {
// 取消点赞 删除记录
result = this.remove(thumbQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return result;
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seCourseThumb);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return result;
}
}
}
@Override
public long thumbCount(String courseId) {
System.out.println("进入课程点赞统计" + courseId);
QueryWrapper<SeCourseThumb> thumbQueryWrapper = new QueryWrapper<>();
thumbQueryWrapper.eq("course_id", courseId);
long result = this.count(thumbQueryWrapper);
if (result == 0) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询参数不存在");
} else {
return result;
}
}
@Override
public long courseCount(String courseId) {
System.out.println("进入课程下资源和知识点的点赞统计" + courseId);
QueryWrapper<SeResourceThumb> ResourceQueryWrapper = new QueryWrapper<>();
ResourceQueryWrapper.eq("course_id", courseId);
long result1 = seResourceThumbService.count(ResourceQueryWrapper);
QueryWrapper<SeKnowThumb> KnowQueryWrapper = new QueryWrapper<>();
KnowQueryWrapper.eq("course_id", courseId);
long result2 = seKnowThumbService.count(KnowQueryWrapper);
long result = result1 + result2;
if (result == 0) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询参数不存在");
} else {
return result;
}
}
}
package com.teaching.backend.service.impl.thumb;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.thumb.SeCourseThumbMapper;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.thumb.SeCourseThumb;
import com.teaching.backend.model.entity.thumb.SeKnowThumb;
import com.teaching.backend.model.entity.thumb.SeResourceThumb;
import com.teaching.backend.service.thumb.SeCourseThumbService;
import com.teaching.backend.service.thumb.SeKnowThumbService;
import com.teaching.backend.service.thumb.SeResourceThumbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeCourseThumbServiceImpl extends ServiceImpl<SeCourseThumbMapper, SeCourseThumb> implements SeCourseThumbService {
@Resource
private SeResourceThumbService seResourceThumbService;
@Resource
SeKnowThumbService seKnowThumbService;
@Autowired
CoursesMapper coursesMapper;
@Override
public BaseResponse<Boolean> doCourseThumb(String courseId, String userId) {
//从数据库中校验是否存在courseid
Courses courses = coursesMapper.selectById(courseId);
boolean result = false;
if(courses == null){
return ResultUtils.error(ErrorCode.PARAMS_COURSE_NOTEXISTS);
}
// 先查询数据库记录,该用户是否点赞
SeCourseThumb seCourseThumb = new SeCourseThumb();
seCourseThumb.setCourseId(courseId);
seCourseThumb.setUserId(userId);
QueryWrapper<SeCourseThumb> thumbQueryWrapper = new QueryWrapper<>(seCourseThumb);
SeCourseThumb oldSeCourseThumb = this.getOne(thumbQueryWrapper);
//已点赞
if (oldSeCourseThumb != null) {
// 取消点赞 删除记录
result = this.remove(thumbQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return ResultUtils.success(result);
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seCourseThumb);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return ResultUtils.success(result);
}
}
}
@Override
public BaseResponse<Long> thumbCount(String courseId) {
//从数据库中校验是否存在courseid
Courses courses = coursesMapper.selectById(courseId);
if(courses == null){
return ResultUtils.error(ErrorCode.PARAMS_COURSE_NOTEXISTS);
}
QueryWrapper<SeCourseThumb> thumbQueryWrapper = new QueryWrapper<>();
thumbQueryWrapper.eq("course_id", courseId);
long count = this.count(thumbQueryWrapper);
if (count == 0) {
throw new BusinessException(ErrorCode.SYSTEM_ERROR, "查询参数不存在");
} else {
return ResultUtils.success(count);
}
}
}

@ -1,63 +1,68 @@
package com.teaching.backend.service.impl.thumb;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.thumb.SeKnowThumbMapper;
import com.teaching.backend.model.entity.thumb.SeKnowThumb;
import com.teaching.backend.service.thumb.SeKnowThumbService;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeKnowThumbServiceImpl extends ServiceImpl<SeKnowThumbMapper, SeKnowThumb> implements SeKnowThumbService {
@Override
public boolean doKnowThumb(String courseId, String knowId, String userId) {
System.out.println("进入知识点点赞" + knowId + userId);
// 先查询数据库记录,该用户是否点赞
SeKnowThumb seKnowThumb = new SeKnowThumb();
seKnowThumb.setKnowId(knowId);
seKnowThumb.setUserId(userId);
seKnowThumb.setCourseId(courseId);
QueryWrapper<SeKnowThumb> thumbQueryWrapper = new QueryWrapper<>(seKnowThumb);
SeKnowThumb oldSeKnowThumb = this.getOne(thumbQueryWrapper);
boolean result = false;
//已点赞
if (oldSeKnowThumb != null) {
// 取消点赞 删除记录
result = this.remove(thumbQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return result;
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seKnowThumb);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return result;
}
}
}
}
package com.teaching.backend.service.impl.thumb;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.thumb.SeKnowThumbMapper;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.thumb.SeKnowThumb;
import com.teaching.backend.service.thumb.SeKnowThumbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeKnowThumbServiceImpl extends ServiceImpl<SeKnowThumbMapper, SeKnowThumb> implements SeKnowThumbService {
@Autowired
CoursesMapper coursesMapper;
@Override
public BaseResponse<Boolean> doKnowThumb(Integer knowId, String userId) {
boolean result = false;
// todo 查询知识点
// 先查询数据库记录,该用户是否点赞
SeKnowThumb seKnowThumb = new SeKnowThumb();
seKnowThumb.setKnowId(knowId);
seKnowThumb.setUserId(userId);
QueryWrapper<SeKnowThumb> thumbQueryWrapper = new QueryWrapper<>(seKnowThumb);
SeKnowThumb oldSeKnowThumb = this.getOne(thumbQueryWrapper);
//已点赞
if (oldSeKnowThumb != null) {
// 取消点赞 删除记录
result = this.remove(thumbQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return ResultUtils.success(result);
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seKnowThumb);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return ResultUtils.success(result);
}
}
}
}

@ -1,63 +1,82 @@
package com.teaching.backend.service.impl.thumb;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.thumb.SeResourceThumbMapper;
import com.teaching.backend.model.entity.thumb.SeResourceThumb;
import com.teaching.backend.service.thumb.SeResourceThumbService;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeResourceThumbServiceImpl extends ServiceImpl<SeResourceThumbMapper, SeResourceThumb> implements SeResourceThumbService {
@Override
public boolean doResourceThumb(String courseId, String resourceId, String userId) {
System.out.println("进入知识点点赞" + resourceId + userId);
// 先查询数据库记录,该用户是否点赞
SeResourceThumb seResourceThumb = new SeResourceThumb();
seResourceThumb.setResourceId(resourceId);
seResourceThumb.setUserId(userId);
seResourceThumb.setCourseId(courseId);
QueryWrapper<SeResourceThumb> thumbQueryWrapper = new QueryWrapper<>(seResourceThumb);
SeResourceThumb oldSeResourceThumb = this.getOne(thumbQueryWrapper);
boolean result = false;
//已点赞
if (oldSeResourceThumb != null) {
// 取消点赞 删除记录
result = this.remove(thumbQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return result;
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seResourceThumb);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return result;
}
}
}
}
package com.teaching.backend.service.impl.thumb;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.common.ErrorCode;
import com.teaching.backend.common.ResultUtils;
import com.teaching.backend.exception.BusinessException;
import com.teaching.backend.mapper.courses.CoursesMapper;
import com.teaching.backend.mapper.resource.CourseResourcesMapper;
import com.teaching.backend.mapper.thumb.SeResourceThumbMapper;
import com.teaching.backend.model.entity.CourseResources;
import com.teaching.backend.model.entity.courses.Courses;
import com.teaching.backend.model.entity.thumb.SeResourceThumb;
import com.teaching.backend.service.thumb.SeResourceThumbService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* @Author:youhang
* @Date:2024-05-30-20:23
* @Description:
*/
@Service
public class SeResourceThumbServiceImpl extends ServiceImpl<SeResourceThumbMapper, SeResourceThumb> implements SeResourceThumbService {
@Autowired
CoursesMapper coursesMapper;
@Autowired
private CourseResourcesMapper courseResourcesMapper;
@Override
public BaseResponse<Boolean> doResourceThumb(Integer resourceId, String userId) {
boolean result = false;
//查询是否有资源
CourseResources courseResources = courseResourcesMapper.selectById(resourceId);
if(courseResources == null){
throw new BusinessException(ErrorCode.PARAMS_RESOURCE_NOTEXISTS);
}
// 先查询数据库记录,该用户是否点赞
SeResourceThumb seResourceThumb = new SeResourceThumb();
seResourceThumb.setResourceId(resourceId);
seResourceThumb.setUserId(userId);
QueryWrapper<SeResourceThumb> thumbQueryWrapper = new QueryWrapper<>(seResourceThumb);
SeResourceThumb oldSeResourceThumb = this.getOne(thumbQueryWrapper);
//已点赞
if (oldSeResourceThumb != null) {
// 取消点赞 删除记录
result = this.remove(thumbQueryWrapper);
if (result) {
System.out.println("取消点赞成功");
return ResultUtils.success(result);
} else {
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
}
} else {
// 每个用户串行点赞
// 锁必须要包裹住事务方法
Lock lock = new ReentrantLock();
lock.lock();
try {
result = this.save(seResourceThumb);
} catch (Exception e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR);
} finally {
lock.unlock();
System.out.println("点赞成功");
return ResultUtils.success(result);
}
}
}
}

@ -1,10 +0,0 @@
package com.teaching.backend.service.know;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.know.Know;
public interface IknowService extends IService<Know> {
}

@ -0,0 +1,12 @@
package com.teaching.backend.service.know;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.dto.favour.knowFavour.KnowFavourAddRequest;
import com.teaching.backend.model.dto.know.KnowAddRequest;
import com.teaching.backend.model.entity.know.Know;
public interface KnowService extends IService<Know> {
public Boolean add(KnowAddRequest knowAddRequest);
}

@ -0,0 +1,31 @@
package com.teaching.backend.service.resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.CourseResources;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* ClassName: FileTableService
* Package: com.teaching.backend.service
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/4 11:49
* @Version 1.0
*/
public interface CourseResourcesService extends IService<CourseResources> {
void updateFile(Integer type, String fileName, String filePath);
void download(String id, String path, HttpServletResponse response, String endpoint, String accessKeyId, String accessKeySecret, String bucketName) throws IOException;
Page<CourseResources> getresourceRecords(Integer type, List<Integer> resourceIdList, int page, int pageSize);
public List<CourseResources> getByType(String type);
public void removeCourseResources(List<Long> ids);
}

@ -0,0 +1,17 @@
package com.teaching.backend.service.resource;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.ResourceRelationship;
/**
* ClassName: ResourcesRelationshipService
* Package: com.teaching.backend.service
* Description:
*
* @Author 姜钧瀚
* @Create 2024/6/12 21:04
* @Version 1.0
*/
public interface ResourcesRelationshipService extends IService<ResourceRelationship> {
}

@ -1,40 +1,33 @@
package com.teaching.backend.service.thumb;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.thumb.SeCourseThumb;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeCourseThumbService extends IService<SeCourseThumb> {
/**
* 点赞
*
* @param courseId
* @param userId
* @return
*/
boolean doCourseThumb(String courseId, String userId);
/**
* 点赞总数
*
* @param courseId
* @return
*/
long thumbCount(String courseId);
/**
* 课程下资源和知识点的点赞总数
*
* @param courseId
* @return
*/
long courseCount(String courseId);
}
package com.teaching.backend.service.thumb;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.thumb.SeCourseThumb;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeCourseThumbService extends IService<SeCourseThumb> {
/**
* 点赞
*
* @param courseId
* @param userId
* @return
*/
BaseResponse<Boolean> doCourseThumb(String courseId, String userId);
/**
* 点赞总数
*
* @param courseId
* @return
*/
BaseResponse<Long> thumbCount(String courseId);
}

@ -1,22 +1,23 @@
package com.teaching.backend.service.thumb;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.thumb.SeKnowThumb;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeKnowThumbService extends IService<SeKnowThumb> {
/**
* 点赞
*
* @param courseId
* @param userId
* @return
*/
boolean doKnowThumb(String courseId, String resourceId, String userId);
}
package com.teaching.backend.service.thumb;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.thumb.SeKnowThumb;
import io.swagger.models.auth.In;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeKnowThumbService extends IService<SeKnowThumb> {
/**
* 点赞
*
* @return
*/
BaseResponse<Boolean> doKnowThumb(Integer knowId, String userId);
}

@ -1,22 +1,22 @@
package com.teaching.backend.service.thumb;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.model.entity.thumb.SeResourceThumb;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeResourceThumbService extends IService<SeResourceThumb> {
/**
* 点赞
*
* @param courseId
* @param userId
* @return
*/
boolean doResourceThumb(String courseId, String resourceId, String userId);
}
package com.teaching.backend.service.thumb;
import com.baomidou.mybatisplus.extension.service.IService;
import com.teaching.backend.common.BaseResponse;
import com.teaching.backend.model.entity.thumb.SeResourceThumb;
/**
* @Author:youhang
* @Date:2024-05-30-20:22
* @Description:
*/
public interface SeResourceThumbService extends IService<SeResourceThumb> {
/**
* 点赞
*
* @param userId
* @return
*/
BaseResponse<Boolean> doResourceThumb(Integer resourceId, String userId);
}

@ -0,0 +1,80 @@
//package com.teaching.backend.utils;
//
///**
// * @Author:youhang
// * @Date:2024-06-17-23:15
// * @Description:
// */
//
//
//
//import cn.hutool.json.JSONObject;
//import cn.hutool.json.JSONUtil;
//import com.teaching.backend.common.ErrorCode;
//import com.teaching.backend.exception.BusinessException;
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.lang.reflect.Method;
//import java.util.Arrays;
//import java.util.List;
//import java.util.stream.Collectors;
//
//
//@Component
//@Aspect
//public class ParamOutAspect {
//
//
// //对包下所有的controller结尾的类的所有方法增强
// private final String executeExpr = "execution(public * com.teaching.backend.controller..*.*(..))";
//
// @Before(executeExpr)
// public void processLog(JoinPoint joinPoint) {
// Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
// //获取方法名称
// String methodName = method.getName();
// //获取参数名称
// LocalVariableTableParameterNameDiscoverer paramNames = new LocalVariableTableParameterNameDiscoverer();
// String[] params = paramNames.getParameterNames(method);
//
//
// //获取参数f
// Object[] args = joinPoint.getArgs();
// //过滤掉request和response,不能序列化
// List<Object> filteredArgs = Arrays.stream(args)
// .filter(arg -> (!(arg instanceof HttpServletRequest) && !(arg instanceof HttpServletResponse))).collect(Collectors.toList());
// final Object[] array = filteredArgs.stream().toArray();
//
// for (int i = 0; i < array.length; i++) {
// System.out.println(array[i]);
// String jsonStr = JSONUtil.toJsonStr(array[i]);
// System.out.println(jsonStr);
// Class<?> myClass = array[i].getClass(); // 获取类的 Class 对象
// System.out.println("class "+myClass);
// JSONObject entries = JSONUtil.parseObj(jsonStr);
// System.out.println(entries);
// // 遍历JSONObject的属性
// entries.forEach((key, value) -> {
// if(value == null || "".equals(value)){
// //可以设置为空的字段
// if(key.equals( "sortField")||key.equals( "sortOrder")){
// }else{
// throw new BusinessException(ErrorCode.PARAMS_NULL);
// }
//
// }
// System.out.println(key + ": " + value);
// });
// }
// }
// }
//
//
//

@ -1,84 +0,0 @@
package com.teaching.backend.utils;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import lombok.Data;
import java.io.*;
import java.net.URLDecoder;
import java.util.Map;
import java.util.Random;
/**
* @Author:youhang
* @Date:2024-05-30-18:20
* @Description:
*/
@Data
public class WordUtil {
private Configuration configuration = null;
/*
* 模板文件存放的目录
*/
private String baseDir;
/*
* 模板文件名称
*/
private String templateFile;
/*
* word生成的输出目录
*/
private String outputDir;
public WordUtil(){
configuration = new Configuration();
configuration.setDefaultEncoding("UTF-8");
}
/*
* <p>转换成word<br>
*/
public String createWord(Map<String,Object> dataMap){
configuration.setClassForTemplateLoading(this.getClass(), "");//模板文件所在路径
Template t = null;
try {
//得到模板文件
configuration.setDirectoryForTemplateLoading(new File(baseDir));
t = configuration.getTemplate(templateFile);
} catch (IOException e) {
e.printStackTrace();
}
//随机生成
Random random=new Random();
File outFile = new File(outputDir+ random.nextInt(200) + ".docx"); //导出文件
Writer out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile)));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
try {
t.process(dataMap, out); //将填充数据填入模板文件并输出到目标文件
return outFile.getPath();
} catch (TemplateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "文档生成失败";
}
}

@ -1,5 +0,0 @@
aliyun.oss.endpoint=oss-cn-wuhan-lr.aliyuncs.com
aliyun.oss.accessKeyId=LTAI5tFkdu3y5WddxbjgaG2F
aliyun.oss.accessKeySecret=1xUchxUTlmUBoTV5JQIrKsVjSkmsLF
aliyun.oss.bucketName=ceshi132132

@ -3,33 +3,36 @@ server:
spring:
application:
name: teaching-backend
servlet:
multipart:
max-file-size: 10MB
max-request-size: 10MB
mvc:
pathmatch:
matching-strategy: ant_path_matcher
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/teaching_db
# url: jdbc:mysql://39.106.16.162:3306/teaching_db
username: root
password: root
url: jdbc:mysql://rm-bp189rd5595301145do.mysql.rds.aliyuncs.com:3306/teaching_db
username: root123
password: Zjh@111111
mybatis:
configuration:
map-underscore-to-camel-case: true
mapper-locations:
- classpath:mapper/*.xml
- classpath*:com/**/mapper/*.xml
# 自定义jwt key
jwt:
tokenHeader: Authorization #JWT存储的请求头
secret: mySecret #JWT加解密使用的密钥
expiration: 604800 #JWT的超期限时间(60*60*24)一天
tokenHead: Bearer #JWT负载中拿到开头
tokenHeader: Authorization
secret: mySecret
expiration: 604800
tokenHead: Bearer
knife4j:
enable: true
openapi:
title: 用户管理接口文档
description: "用户管理接口文档"
title: 111
description: "123"
concat: zjh
version: v1.0.0
group:
@ -40,24 +43,31 @@ knife4j:
- com.teaching.backend.controller
secure:
ignored:
urls: #安全路径白名单
#- /swagger-ui/
- /**
# - /swagger-resources/**
# - /**/v2/api-docs
# - /**/*.html
# - /**/*.js
# - /**/*.css
# - /**/*.png
# - /**/*.map
# - /favicon.ico
# - /actuator/**
# - /druid/**
# - /user/**
# - /user/login
# - /user/register
# - /user/info
# - /user/logout
# - /minio/upload
urls:
- /swagger-ui/
# - /**
- /swagger-resources/**
- /**/v2/api-docs
- /**/*.html
- /**/*.js
- /**/*.css
- /**/*.png
- /**/*.map
- /favicon.ico
- /actuator/**
- /druid/**
- /user/**
- /user/login
- /user/register
- /user/info
- /user/logout
- /minio/upload
aliyun:
oss:
endpoint: oss-cn-wuhan-lr.aliyuncs.com
accessKeyId: LTAI5tFkdu3y5WddxbjgaG2F
accessKeySecret: 1xUchxUTlmUBoTV5JQIrKsVjSkmsLF
bucketName: ceshi132132

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

@ -1,76 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文件上传下载示例</title>
</head>
<body>
<div id="app">
<h1>文件上传</h1>
<form @submit.prevent="upload" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit">上传文件</button>
</form>
<h1>文件下载</h1>
<button @click="download">点击下载文件</button>
</div>
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<script src="../../plugins/vue/vue.js"></script>
<!-- 引入组件库 -->
<script src="../../plugins/element-ui/index.js"></script>
<!-- 引入axios -->
<script src="../../plugins/axios/axios.min.js"></script>
<script>
new Vue({
el: '#app',
data: {
fileName: ''
},
methods: {
download() {
axios.get('/download?fileName=' + this.fileName, { responseType: 'blob' })
.then(response => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', this.fileName);
document.body.appendChild(link);
link.click();
window.URL.revokeObjectURL(url);
})
.catch(error => {
console.error("出错了", error);
});
},
upload(event) {
let formData = new FormData();
formData.append('file', event.target.elements.file.files[0]);
axios.post('/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
console.log("上传成功,文件名为:" + response.data.data);
this.fileName = response.data.data;
})
.catch(error => {
console.error('上传失败', error);
});
}
}
});
</script>
</body>
</html>

@ -1,54 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>视频上传和下载</title>
</head>
<body>
<div id="app2">
<input type="file" ref="fileInput" @change="handleFileChange">
<button @click="uploadFile">上传</button>
</div>
<!-- 开发环境版本,包含了有帮助的命令行警告 -->
<script src="../../plugins/vue/vue.js"></script>
<!-- 引入组件库 -->
<script src="../../plugins/element-ui/index.js"></script>
<!-- 引入axios -->
<script src="../../plugins/axios/axios.min.js"></script>
<script>
new Vue({
el: '#app2',
data: {
selectedFile:''
},
methods: {
handleFileChange(event) {
this.selectedFile = event.target.files[0];
},
uploadFile() {
const formData = new FormData();
formData.append('file', this.selectedFile);
// 发送文件上传请求
axios.post('/video/upload', formData)
.then(response => {
// 处理上传成功的响应
console.log(response.data);
})
.catch(error => {
// 处理上传失败的错误
console.error(error);
});
}
}
});
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

@ -1,9 +1,14 @@
package com.teaching;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.*;
@SpringBootTest
class TeachingBackendApplicationTests {
Map<String, List<String>> userLearningRecords = new HashMap<>();
}

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save