commit
ab87285e83
85 changed files with 1930 additions and 13695 deletions
@ -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 |
@ -1,4 +1,4 @@ |
||||
package com.teaching.backend.api; |
||||
package com.teaching.backend.common; |
||||
|
||||
/** |
||||
* @auther macrozheng |
@ -1,4 +1,4 @@ |
||||
package com.teaching.backend.api; |
||||
package com.teaching.backend.common; |
||||
|
||||
/** |
||||
* @auther macrozheng |
@ -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("添加成功!"); |
||||
} |
||||
} |
@ -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)); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
@ -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,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> { |
||||
} |
@ -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> { |
||||
} |
@ -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; |
||||
|
||||
|
||||
} |
@ -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 { |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -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)); |
||||
} |
||||
} |
@ -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 |
||||
|
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
Binary file not shown.
@ -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…
Reference in new issue