From 600d1ea0960c004f8081ce99dd875a2e1f2d5a10 Mon Sep 17 00:00:00 2001 From: wenyu441069198 <14186472+wenyu441069198@user.noreply.gitee.com> Date: Fri, 31 May 2024 15:46:56 +0800 Subject: [PATCH] yh 2 --- pom.xml | 13 +++ .../teaching/TeachingBackendApplication.java | 2 + .../teaching/backend/common/BaseResponse.java | 34 ++++++ .../teaching/backend/common/ErrorCode.java | 43 +++++++ .../teaching/backend/common/ResultUtils.java | 52 +++++++++ .../com/teaching/backend/common/test1.java | 9 -- .../backend/config/MyBatisPlusConfig.java | 30 +++++ .../backend/controller/UserController.java | 21 ---- .../favour/SeCourseFavourController.java | 89 +++++++++++++++ .../favour/SeKnowFavourController.java | 50 ++++++++ .../favour/SeResourceFavourController.java | 50 ++++++++ .../thumb/SeCourseThumbController.java | 87 ++++++++++++++ .../thumb/SeKnowThumbController.java | 49 ++++++++ .../thumb/SeResourceThumbController.java | 49 ++++++++ .../backend/exception/BusinessException.java | 37 ++++++ .../com/teaching/backend/exception/test1.java | 9 -- .../mapper/favour/SeCourseFavourMapper.java | 16 +++ .../mapper/favour/SeKnowFavourMapper.java | 17 +++ .../mapper/favour/SeResourceFavourMapper.java | 18 +++ .../com/teaching/backend/mapper/test1.java | 9 -- .../mapper/thumb/SeCourseThumbMapper.java | 16 +++ .../mapper/thumb/SeKnowThumbMapper.java | 17 +++ .../mapper/thumb/SeResourceThumbMapper.java | 18 +++ .../courseFavour/CourseFavourAddRequest.java | 25 ++++ .../courseFavour/CourseFavourAllRequest.java | 21 ++++ .../knowFavour/KnowFavourAddRequest.java | 30 +++++ .../ResourceFavourAddRequest.java | 30 +++++ .../com/teaching/backend/model/dto/test1.java | 9 -- .../coursethumb/CourseThumbAddRequest.java | 25 ++++ .../coursethumb/CourseThumbAllRequest.java | 21 ++++ .../thumb/knowthumb/KnowThumbAddRequest.java | 30 +++++ .../ResourceThumbAddRequest.java | 30 +++++ .../model/entity/favour/SeCourseFavour.java | 36 ++++++ .../model/entity/favour/SeKnowFavour.java | 41 +++++++ .../model/entity/favour/SeResourceFavour.java | 41 +++++++ .../teaching/backend/model/entity/test1.java | 9 -- .../model/entity/thumb/SeCourseThumb.java | 37 ++++++ .../model/entity/thumb/SeKnowThumb.java | 41 +++++++ .../model/entity/thumb/SeResourceThumb.java | 41 +++++++ .../com/teaching/backend/model/test1.java | 9 -- .../service/favour/SeCourseFavourService.java | 41 +++++++ .../service/favour/SeKnowFavourService.java | 22 ++++ .../favour/SeResourceFavourService.java | 22 ++++ .../favour/SeCourseFavourServiceImpl.java | 108 ++++++++++++++++++ .../impl/favour/SeKnowFavourServiceImpl.java | 66 +++++++++++ .../favour/SeResourceFavourServiceImpl.java | 67 +++++++++++ .../impl/thumb/SeCourseThumbServiceImpl.java | 106 +++++++++++++++++ .../impl/thumb/SeKnowThumbServiceImpl.java | 65 +++++++++++ .../thumb/SeResourceThumbServiceImpl.java | 65 +++++++++++ .../com/teaching/backend/service/test1.java | 9 -- .../service/thumb/SeCourseThumbService.java | 41 +++++++ .../service/thumb/SeKnowThumbService.java | 22 ++++ .../service/thumb/SeResourceThumbService.java | 22 ++++ src/main/resources/application.yml | 18 ++- .../resources/mapper/SeCourseThumbMapper.xml | 17 +++ 55 files changed, 1817 insertions(+), 85 deletions(-) create mode 100644 src/main/java/com/teaching/backend/common/BaseResponse.java create mode 100644 src/main/java/com/teaching/backend/common/ErrorCode.java create mode 100644 src/main/java/com/teaching/backend/common/ResultUtils.java delete mode 100644 src/main/java/com/teaching/backend/common/test1.java create mode 100644 src/main/java/com/teaching/backend/config/MyBatisPlusConfig.java delete mode 100644 src/main/java/com/teaching/backend/controller/UserController.java create mode 100644 src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java create mode 100644 src/main/java/com/teaching/backend/controller/favour/SeKnowFavourController.java create mode 100644 src/main/java/com/teaching/backend/controller/favour/SeResourceFavourController.java create mode 100644 src/main/java/com/teaching/backend/controller/thumb/SeCourseThumbController.java create mode 100644 src/main/java/com/teaching/backend/controller/thumb/SeKnowThumbController.java create mode 100644 src/main/java/com/teaching/backend/controller/thumb/SeResourceThumbController.java create mode 100644 src/main/java/com/teaching/backend/exception/BusinessException.java delete mode 100644 src/main/java/com/teaching/backend/exception/test1.java create mode 100644 src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java create mode 100644 src/main/java/com/teaching/backend/mapper/favour/SeKnowFavourMapper.java create mode 100644 src/main/java/com/teaching/backend/mapper/favour/SeResourceFavourMapper.java delete mode 100644 src/main/java/com/teaching/backend/mapper/test1.java create mode 100644 src/main/java/com/teaching/backend/mapper/thumb/SeCourseThumbMapper.java create mode 100644 src/main/java/com/teaching/backend/mapper/thumb/SeKnowThumbMapper.java create mode 100644 src/main/java/com/teaching/backend/mapper/thumb/SeResourceThumbMapper.java create mode 100644 src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourAddRequest.java create mode 100644 src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourAllRequest.java create mode 100644 src/main/java/com/teaching/backend/model/dto/favour/knowFavour/KnowFavourAddRequest.java create mode 100644 src/main/java/com/teaching/backend/model/dto/favour/resourceFavour/ResourceFavourAddRequest.java delete mode 100644 src/main/java/com/teaching/backend/model/dto/test1.java create mode 100644 src/main/java/com/teaching/backend/model/dto/thumb/coursethumb/CourseThumbAddRequest.java create mode 100644 src/main/java/com/teaching/backend/model/dto/thumb/coursethumb/CourseThumbAllRequest.java create mode 100644 src/main/java/com/teaching/backend/model/dto/thumb/knowthumb/KnowThumbAddRequest.java create mode 100644 src/main/java/com/teaching/backend/model/dto/thumb/resourcethumb/ResourceThumbAddRequest.java create mode 100644 src/main/java/com/teaching/backend/model/entity/favour/SeCourseFavour.java create mode 100644 src/main/java/com/teaching/backend/model/entity/favour/SeKnowFavour.java create mode 100644 src/main/java/com/teaching/backend/model/entity/favour/SeResourceFavour.java delete mode 100644 src/main/java/com/teaching/backend/model/entity/test1.java create mode 100644 src/main/java/com/teaching/backend/model/entity/thumb/SeCourseThumb.java create mode 100644 src/main/java/com/teaching/backend/model/entity/thumb/SeKnowThumb.java create mode 100644 src/main/java/com/teaching/backend/model/entity/thumb/SeResourceThumb.java delete mode 100644 src/main/java/com/teaching/backend/model/test1.java create mode 100644 src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java create mode 100644 src/main/java/com/teaching/backend/service/favour/SeKnowFavourService.java create mode 100644 src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java create mode 100644 src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java create mode 100644 src/main/java/com/teaching/backend/service/impl/favour/SeKnowFavourServiceImpl.java create mode 100644 src/main/java/com/teaching/backend/service/impl/favour/SeResourceFavourServiceImpl.java create mode 100644 src/main/java/com/teaching/backend/service/impl/thumb/SeCourseThumbServiceImpl.java create mode 100644 src/main/java/com/teaching/backend/service/impl/thumb/SeKnowThumbServiceImpl.java create mode 100644 src/main/java/com/teaching/backend/service/impl/thumb/SeResourceThumbServiceImpl.java delete mode 100644 src/main/java/com/teaching/backend/service/test1.java create mode 100644 src/main/java/com/teaching/backend/service/thumb/SeCourseThumbService.java create mode 100644 src/main/java/com/teaching/backend/service/thumb/SeKnowThumbService.java create mode 100644 src/main/java/com/teaching/backend/service/thumb/SeResourceThumbService.java create mode 100644 src/main/resources/mapper/SeCourseThumbMapper.xml diff --git a/pom.xml b/pom.xml index a0963d6..fdb7d41 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,7 @@ mybatis-spring-boot-starter 2.2.2 + com.baomidou @@ -63,6 +64,18 @@ spring-boot-starter-test test + + + + com.github.xiaoymin + knife4j-openapi2-spring-boot-starter + 4.4.0 + + + + org.apache.commons + commons-lang3 + diff --git a/src/main/java/com/teaching/TeachingBackendApplication.java b/src/main/java/com/teaching/TeachingBackendApplication.java index 242c819..814a59c 100644 --- a/src/main/java/com/teaching/TeachingBackendApplication.java +++ b/src/main/java/com/teaching/TeachingBackendApplication.java @@ -1,9 +1,11 @@ package com.teaching; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication +@MapperScan("com.teaching.backend.mapper") public class TeachingBackendApplication { public static void main(String[] args) { diff --git a/src/main/java/com/teaching/backend/common/BaseResponse.java b/src/main/java/com/teaching/backend/common/BaseResponse.java new file mode 100644 index 0000000..e562b52 --- /dev/null +++ b/src/main/java/com/teaching/backend/common/BaseResponse.java @@ -0,0 +1,34 @@ +package com.teaching.backend.common; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 通用返回类 + * + * @param + */ +@Data +public class BaseResponse implements Serializable { + + private int code; + + private T data; + + private String message; + + public BaseResponse(int code, T data, String message) { + this.code = code; + this.data = data; + this.message = message; + } + + public BaseResponse(int code, T data) { + this(code, data, ""); + } + + public BaseResponse(ErrorCode errorCode) { + this(errorCode.getCode(), null, errorCode.getMessage()); + } +} diff --git a/src/main/java/com/teaching/backend/common/ErrorCode.java b/src/main/java/com/teaching/backend/common/ErrorCode.java new file mode 100644 index 0000000..84ddc09 --- /dev/null +++ b/src/main/java/com/teaching/backend/common/ErrorCode.java @@ -0,0 +1,43 @@ +package com.teaching.backend.common; + +/** + * 自定义错误码 + * + * @author 程序员鱼皮 + * @from 编程导航知识星球 + */ +public enum ErrorCode { + + SUCCESS(0, "ok"), + PARAMS_ERROR(40000, "请求参数错误"), + NOT_LOGIN_ERROR(40100, "未登录"), + NO_AUTH_ERROR(40101, "无权限"), + NOT_FOUND_ERROR(40400, "请求数据不存在"), + FORBIDDEN_ERROR(40300, "禁止访问"), + SYSTEM_ERROR(50000, "系统内部异常"), + OPERATION_ERROR(50001, "操作失败"); + + /** + * 状态码 + */ + private final int code; + + /** + * 信息 + */ + private final String message; + + ErrorCode(int code, String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + +} diff --git a/src/main/java/com/teaching/backend/common/ResultUtils.java b/src/main/java/com/teaching/backend/common/ResultUtils.java new file mode 100644 index 0000000..1cd695a --- /dev/null +++ b/src/main/java/com/teaching/backend/common/ResultUtils.java @@ -0,0 +1,52 @@ +package com.teaching.backend.common; + +/** + * 返回工具类 + * + * @author 程序员鱼皮 + * @from 编程导航知识星球 + */ +public class ResultUtils { + + /** + * 成功 + * + * @param data + * @param + * @return + */ + public static BaseResponse success(T data) { + return new BaseResponse<>(0, data, "ok"); + } + + /** + * 失败 + * + * @param errorCode + * @return + */ + public static BaseResponse error(ErrorCode errorCode) { + return new BaseResponse<>(errorCode); + } + + /** + * 失败 + * + * @param code + * @param message + * @return + */ + public static BaseResponse error(int code, String message) { + return new BaseResponse(code, null, message); + } + + /** + * 失败 + * + * @param errorCode + * @return + */ + public static BaseResponse error(ErrorCode errorCode, String message) { + return new BaseResponse(errorCode.getCode(), null, message); + } +} diff --git a/src/main/java/com/teaching/backend/common/test1.java b/src/main/java/com/teaching/backend/common/test1.java deleted file mode 100644 index 99ae8b7..0000000 --- a/src/main/java/com/teaching/backend/common/test1.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.teaching.backend.common; - -/** - * @Author:youhang - * @Date:2024-05-30-18:20 - * @Description: - */ -public class test1 { -} diff --git a/src/main/java/com/teaching/backend/config/MyBatisPlusConfig.java b/src/main/java/com/teaching/backend/config/MyBatisPlusConfig.java new file mode 100644 index 0000000..f9d8990 --- /dev/null +++ b/src/main/java/com/teaching/backend/config/MyBatisPlusConfig.java @@ -0,0 +1,30 @@ +package com.teaching.backend.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * MyBatis Plus 配置 + * + */ +@Configuration +@MapperScan("com.teaching.backend.mapper") +public class MyBatisPlusConfig { + + /** + * 拦截器配置 + * + * @return + */ + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + // 分页插件 + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; + } +} diff --git a/src/main/java/com/teaching/backend/controller/UserController.java b/src/main/java/com/teaching/backend/controller/UserController.java deleted file mode 100644 index ec1b0f8..0000000 --- a/src/main/java/com/teaching/backend/controller/UserController.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.teaching.backend.controller; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * @Author:youhang - * @Date:2024-05-30-18:15 - * @Description: - */ -@Controller -public class UserController { - - @RequestMapping(value = "/1",method = RequestMethod.GET) - @ResponseBody - public String add(){ - return "yh"; - } -} diff --git a/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java b/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java new file mode 100644 index 0000000..282a903 --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/favour/SeCourseFavourController.java @@ -0,0 +1,89 @@ +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.courseFavour.CourseFavourAddRequest; +import com.teaching.backend.model.dto.favour.courseFavour.CourseFavourAllRequest; +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; + +/** + * @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 doFavour(@RequestBody CourseFavourAddRequest 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 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 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); + } + +} diff --git a/src/main/java/com/teaching/backend/controller/favour/SeKnowFavourController.java b/src/main/java/com/teaching/backend/controller/favour/SeKnowFavourController.java new file mode 100644 index 0000000..2854949 --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/favour/SeKnowFavourController.java @@ -0,0 +1,50 @@ +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 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); + } + +} diff --git a/src/main/java/com/teaching/backend/controller/favour/SeResourceFavourController.java b/src/main/java/com/teaching/backend/controller/favour/SeResourceFavourController.java new file mode 100644 index 0000000..7c0bad1 --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/favour/SeResourceFavourController.java @@ -0,0 +1,50 @@ +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 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); + } + +} diff --git a/src/main/java/com/teaching/backend/controller/thumb/SeCourseThumbController.java b/src/main/java/com/teaching/backend/controller/thumb/SeCourseThumbController.java new file mode 100644 index 0000000..0392a80 --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/thumb/SeCourseThumbController.java @@ -0,0 +1,87 @@ +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("/add") + // todo 后期加上 HttpServletRequest request 在一个fitter里面进行鉴权操作 + public BaseResponse 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 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 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); + } + +} diff --git a/src/main/java/com/teaching/backend/controller/thumb/SeKnowThumbController.java b/src/main/java/com/teaching/backend/controller/thumb/SeKnowThumbController.java new file mode 100644 index 0000000..48215c3 --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/thumb/SeKnowThumbController.java @@ -0,0 +1,49 @@ +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 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); + } + +} diff --git a/src/main/java/com/teaching/backend/controller/thumb/SeResourceThumbController.java b/src/main/java/com/teaching/backend/controller/thumb/SeResourceThumbController.java new file mode 100644 index 0000000..48e282b --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/thumb/SeResourceThumbController.java @@ -0,0 +1,49 @@ +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 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); + } + +} diff --git a/src/main/java/com/teaching/backend/exception/BusinessException.java b/src/main/java/com/teaching/backend/exception/BusinessException.java new file mode 100644 index 0000000..152ac4b --- /dev/null +++ b/src/main/java/com/teaching/backend/exception/BusinessException.java @@ -0,0 +1,37 @@ +package com.teaching.backend.exception; + + +import com.teaching.backend.common.ErrorCode; + +/** + * 自定义异常类 + * + * @author 程序员鱼皮 + * @from 编程导航知识星球 + */ +public class BusinessException extends RuntimeException { + + /** + * 错误码 + */ + private final int code; + + public BusinessException(int code, String message) { + super(message); + this.code = code; + } + + public BusinessException(ErrorCode errorCode) { + super(errorCode.getMessage()); + this.code = errorCode.getCode(); + } + + public BusinessException(ErrorCode errorCode, String message) { + super(message); + this.code = errorCode.getCode(); + } + + public int getCode() { + return code; + } +} diff --git a/src/main/java/com/teaching/backend/exception/test1.java b/src/main/java/com/teaching/backend/exception/test1.java deleted file mode 100644 index bb8ef3c..0000000 --- a/src/main/java/com/teaching/backend/exception/test1.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.teaching.backend.exception; - -/** - * @Author:youhang - * @Date:2024-05-30-18:20 - * @Description: - */ -public class test1 { -} diff --git a/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java b/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java new file mode 100644 index 0000000..c11a8b8 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/favour/SeCourseFavourMapper.java @@ -0,0 +1,16 @@ +package com.teaching.backend.mapper.favour; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.favour.SeCourseFavour; + +/** + * 课程点赞数据库操作 + * + */ +public interface SeCourseFavourMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/teaching/backend/mapper/favour/SeKnowFavourMapper.java b/src/main/java/com/teaching/backend/mapper/favour/SeKnowFavourMapper.java new file mode 100644 index 0000000..3e0faf7 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/favour/SeKnowFavourMapper.java @@ -0,0 +1,17 @@ +package com.teaching.backend.mapper.favour; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.favour.SeKnowFavour; + +/** + * 知识点赞数据库操作 + * + */ +public interface SeKnowFavourMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/teaching/backend/mapper/favour/SeResourceFavourMapper.java b/src/main/java/com/teaching/backend/mapper/favour/SeResourceFavourMapper.java new file mode 100644 index 0000000..f6b5664 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/favour/SeResourceFavourMapper.java @@ -0,0 +1,18 @@ +package com.teaching.backend.mapper.favour; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.favour.SeResourceFavour; + + +/** + * 课程资源点赞数据库操作 + * + */ +public interface SeResourceFavourMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/teaching/backend/mapper/test1.java b/src/main/java/com/teaching/backend/mapper/test1.java deleted file mode 100644 index 61714bc..0000000 --- a/src/main/java/com/teaching/backend/mapper/test1.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.teaching.backend.mapper; - -/** - * @Author:youhang - * @Date:2024-05-30-18:20 - * @Description: - */ -public class test1 { -} diff --git a/src/main/java/com/teaching/backend/mapper/thumb/SeCourseThumbMapper.java b/src/main/java/com/teaching/backend/mapper/thumb/SeCourseThumbMapper.java new file mode 100644 index 0000000..95c70bd --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/thumb/SeCourseThumbMapper.java @@ -0,0 +1,16 @@ +package com.teaching.backend.mapper.thumb; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.thumb.SeCourseThumb; + +/** + * 课程点赞数据库操作 + * + */ +public interface SeCourseThumbMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/teaching/backend/mapper/thumb/SeKnowThumbMapper.java b/src/main/java/com/teaching/backend/mapper/thumb/SeKnowThumbMapper.java new file mode 100644 index 0000000..34421b7 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/thumb/SeKnowThumbMapper.java @@ -0,0 +1,17 @@ +package com.teaching.backend.mapper.thumb; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.thumb.SeKnowThumb; + +/** + * 知识点赞数据库操作 + * + */ +public interface SeKnowThumbMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/teaching/backend/mapper/thumb/SeResourceThumbMapper.java b/src/main/java/com/teaching/backend/mapper/thumb/SeResourceThumbMapper.java new file mode 100644 index 0000000..e73abf2 --- /dev/null +++ b/src/main/java/com/teaching/backend/mapper/thumb/SeResourceThumbMapper.java @@ -0,0 +1,18 @@ +package com.teaching.backend.mapper.thumb; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.teaching.backend.model.entity.thumb.SeResourceThumb; + + +/** + * 课程资源点赞数据库操作 + * + */ +public interface SeResourceThumbMapper extends BaseMapper { + +} + + + + diff --git a/src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourAddRequest.java b/src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourAddRequest.java new file mode 100644 index 0000000..9ea1200 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourAddRequest.java @@ -0,0 +1,25 @@ +package com.teaching.backend.model.dto.favour.courseFavour; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 课程点赞请求 + * + */ +@Data +public class CourseFavourAddRequest implements Serializable { + + /** + * 帖子 id + */ + private String courseId; + + /** + * user id + */ + private String userId; + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourAllRequest.java b/src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourAllRequest.java new file mode 100644 index 0000000..205612f --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/favour/courseFavour/CourseFavourAllRequest.java @@ -0,0 +1,21 @@ +package com.teaching.backend.model.dto.favour.courseFavour; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 课程点赞请求 + * + */ +@Data +public class CourseFavourAllRequest implements Serializable { + + /** + * 课程 id + */ + private String courseId; + + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/dto/favour/knowFavour/KnowFavourAddRequest.java b/src/main/java/com/teaching/backend/model/dto/favour/knowFavour/KnowFavourAddRequest.java new file mode 100644 index 0000000..7a0b279 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/favour/knowFavour/KnowFavourAddRequest.java @@ -0,0 +1,30 @@ +package com.teaching.backend.model.dto.favour.knowFavour; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 知识点点赞请求 + * + */ +@Data +public class KnowFavourAddRequest implements Serializable { + + /** + * 课程 id + */ + private String courseId; + + /** + * 知识点 id + */ + private String knowId; + + /** + * user id + */ + private String userId; + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/dto/favour/resourceFavour/ResourceFavourAddRequest.java b/src/main/java/com/teaching/backend/model/dto/favour/resourceFavour/ResourceFavourAddRequest.java new file mode 100644 index 0000000..61e3643 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/favour/resourceFavour/ResourceFavourAddRequest.java @@ -0,0 +1,30 @@ +package com.teaching.backend.model.dto.favour.resourceFavour; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 资源点赞请求 + * + */ +@Data +public class ResourceFavourAddRequest implements Serializable { + + /** + * 课程 id + */ + private String courseId; + + /** + * 知识点 id + */ + private String resourceId; + + /** + * user id + */ + private String userId; + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/dto/test1.java b/src/main/java/com/teaching/backend/model/dto/test1.java deleted file mode 100644 index 4a85daf..0000000 --- a/src/main/java/com/teaching/backend/model/dto/test1.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.teaching.backend.model.dto; - -/** - * @Author:youhang - * @Date:2024-05-30-18:20 - * @Description: - */ -public class test1 { -} diff --git a/src/main/java/com/teaching/backend/model/dto/thumb/coursethumb/CourseThumbAddRequest.java b/src/main/java/com/teaching/backend/model/dto/thumb/coursethumb/CourseThumbAddRequest.java new file mode 100644 index 0000000..2ffd32d --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/thumb/coursethumb/CourseThumbAddRequest.java @@ -0,0 +1,25 @@ +package com.teaching.backend.model.dto.thumb.coursethumb; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 课程点赞请求 + * + */ +@Data +public class CourseThumbAddRequest implements Serializable { + + /** + * 帖子 id + */ + private String courseId; + + /** + * user id + */ + private String userId; + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/dto/thumb/coursethumb/CourseThumbAllRequest.java b/src/main/java/com/teaching/backend/model/dto/thumb/coursethumb/CourseThumbAllRequest.java new file mode 100644 index 0000000..d41af7d --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/thumb/coursethumb/CourseThumbAllRequest.java @@ -0,0 +1,21 @@ +package com.teaching.backend.model.dto.thumb.coursethumb; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 课程点赞请求 + * + */ +@Data +public class CourseThumbAllRequest implements Serializable { + + /** + * 课程 id + */ + private String courseId; + + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/dto/thumb/knowthumb/KnowThumbAddRequest.java b/src/main/java/com/teaching/backend/model/dto/thumb/knowthumb/KnowThumbAddRequest.java new file mode 100644 index 0000000..e18db65 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/thumb/knowthumb/KnowThumbAddRequest.java @@ -0,0 +1,30 @@ +package com.teaching.backend.model.dto.thumb.knowthumb; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 知识点点赞请求 + * + */ +@Data +public class KnowThumbAddRequest implements Serializable { + + /** + * 课程 id + */ + private String courseId; + + /** + * 知识点 id + */ + private String knowId; + + /** + * user id + */ + private String userId; + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/dto/thumb/resourcethumb/ResourceThumbAddRequest.java b/src/main/java/com/teaching/backend/model/dto/thumb/resourcethumb/ResourceThumbAddRequest.java new file mode 100644 index 0000000..660db4f --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/thumb/resourcethumb/ResourceThumbAddRequest.java @@ -0,0 +1,30 @@ +package com.teaching.backend.model.dto.thumb.resourcethumb; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 资源点赞请求 + * + */ +@Data +public class ResourceThumbAddRequest implements Serializable { + + /** + * 课程 id + */ + private String courseId; + + /** + * 知识点 id + */ + private String resourceId; + + /** + * user id + */ + private String userId; + + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/entity/favour/SeCourseFavour.java b/src/main/java/com/teaching/backend/model/entity/favour/SeCourseFavour.java new file mode 100644 index 0000000..7c2ec1c --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/favour/SeCourseFavour.java @@ -0,0 +1,36 @@ +package com.teaching.backend.model.entity.favour; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 课程点赞 + * + */ +@TableName(value = "se_course_favour") +@Data +public class SeCourseFavour implements Serializable { + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 课程 id + */ + private String courseId; + + /** + * 创建用户 id + */ + private String userId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/entity/favour/SeKnowFavour.java b/src/main/java/com/teaching/backend/model/entity/favour/SeKnowFavour.java new file mode 100644 index 0000000..d391551 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/favour/SeKnowFavour.java @@ -0,0 +1,41 @@ +package com.teaching.backend.model.entity.favour; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 知识点点赞 + * + */ +@TableName(value = "se_know_favour") +@Data +public class SeKnowFavour implements Serializable { + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 课程 id + */ + private String courseId; + + /** + * 创建知识点 id + */ + private String knowId; + + /** + * 创建用户 id + */ + private String userId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/entity/favour/SeResourceFavour.java b/src/main/java/com/teaching/backend/model/entity/favour/SeResourceFavour.java new file mode 100644 index 0000000..5d36182 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/favour/SeResourceFavour.java @@ -0,0 +1,41 @@ +package com.teaching.backend.model.entity.favour; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 资源点赞 + * + */ +@TableName(value = "se_resource_favour") +@Data +public class SeResourceFavour implements Serializable { + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 课程 id + */ + private String courseId; + + /** + * 创建知识点 id + */ + private String resourceId; + + /** + * 创建用户 id + */ + private String userId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/entity/test1.java b/src/main/java/com/teaching/backend/model/entity/test1.java deleted file mode 100644 index fa16819..0000000 --- a/src/main/java/com/teaching/backend/model/entity/test1.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.teaching.backend.model.entity; - -/** - * @Author:youhang - * @Date:2024-05-30-18:20 - * @Description: - */ -public class test1 { -} diff --git a/src/main/java/com/teaching/backend/model/entity/thumb/SeCourseThumb.java b/src/main/java/com/teaching/backend/model/entity/thumb/SeCourseThumb.java new file mode 100644 index 0000000..f5006ce --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/thumb/SeCourseThumb.java @@ -0,0 +1,37 @@ +package com.teaching.backend.model.entity.thumb; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 课程点赞 + * + */ +@TableName(value = "se_course_thumb") +@Data +public class SeCourseThumb implements Serializable { + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 课程 id + */ + private String courseId; + + /** + * 创建用户 id + */ + private String userId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/entity/thumb/SeKnowThumb.java b/src/main/java/com/teaching/backend/model/entity/thumb/SeKnowThumb.java new file mode 100644 index 0000000..df54f81 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/thumb/SeKnowThumb.java @@ -0,0 +1,41 @@ +package com.teaching.backend.model.entity.thumb; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 知识点点赞 + * + */ +@TableName(value = "se_know_thumb") +@Data +public class SeKnowThumb implements Serializable { + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 课程 id + */ + private String courseId; + + /** + * 创建知识点 id + */ + private String knowId; + + /** + * 创建用户 id + */ + private String userId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/entity/thumb/SeResourceThumb.java b/src/main/java/com/teaching/backend/model/entity/thumb/SeResourceThumb.java new file mode 100644 index 0000000..5155da5 --- /dev/null +++ b/src/main/java/com/teaching/backend/model/entity/thumb/SeResourceThumb.java @@ -0,0 +1,41 @@ +package com.teaching.backend.model.entity.thumb; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.io.Serializable; + +/** + * 资源点赞 + * + */ +@TableName(value = "se_resource_thumb") +@Data +public class SeResourceThumb implements Serializable { + /** + * id + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 课程 id + */ + private String courseId; + + /** + * 创建知识点 id + */ + private String resourceId; + + /** + * 创建用户 id + */ + private String userId; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} diff --git a/src/main/java/com/teaching/backend/model/test1.java b/src/main/java/com/teaching/backend/model/test1.java deleted file mode 100644 index 716b9fe..0000000 --- a/src/main/java/com/teaching/backend/model/test1.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.teaching.backend.model; - -/** - * @Author:youhang - * @Date:2024-05-30-18:20 - * @Description: - */ -public class test1 { -} diff --git a/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java b/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java new file mode 100644 index 0000000..3ba4032 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/favour/SeCourseFavourService.java @@ -0,0 +1,41 @@ +package com.teaching.backend.service.favour; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.teaching.backend.model.entity.favour.SeCourseFavour; + +/** + * @Author:youhang + * @Date:2024-05-30-20:22 + * @Description: + */ +public interface SeCourseFavourService extends IService { + + /** + * 收藏/取消收藏 + * + * @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); + +} diff --git a/src/main/java/com/teaching/backend/service/favour/SeKnowFavourService.java b/src/main/java/com/teaching/backend/service/favour/SeKnowFavourService.java new file mode 100644 index 0000000..a007f72 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/favour/SeKnowFavourService.java @@ -0,0 +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 { + + /** + * 收藏 + * + * @param courseId + * @param userId + * @return + */ + boolean doKnowFavour( String courseId,String resourceId, String userId); + +} diff --git a/src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java b/src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java new file mode 100644 index 0000000..9043f08 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java @@ -0,0 +1,22 @@ +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 { + + /** + * 收藏 + * + * @param courseId + * @param userId + * @return + */ + boolean doResourceFavour( String courseId,String resourceId, String userId); + +} diff --git a/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java new file mode 100644 index 0000000..946bd5f --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/favour/SeCourseFavourServiceImpl.java @@ -0,0 +1,108 @@ +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.SeCourseFavourMapper; +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.service.favour.SeCourseFavourService; +import com.teaching.backend.service.favour.SeKnowFavourService; +import com.teaching.backend.service.favour.SeResourceFavourService; + +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 SeCourseFavourServiceImpl extends ServiceImpl implements SeCourseFavourService { + + + @Resource + private SeResourceFavourService seResourceFavourService; + + @Resource + SeKnowFavourService seKnowFavourService; + + + @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 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 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 ResourceQueryWrapper = new QueryWrapper<>(); + ResourceQueryWrapper.eq("course_id",courseId); + long result1 = seResourceFavourService.count(ResourceQueryWrapper); + QueryWrapper 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; + } + } + + +} diff --git a/src/main/java/com/teaching/backend/service/impl/favour/SeKnowFavourServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/favour/SeKnowFavourServiceImpl.java new file mode 100644 index 0000000..22214b1 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/favour/SeKnowFavourServiceImpl.java @@ -0,0 +1,66 @@ +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 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 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; + } + } + } + + + +} diff --git a/src/main/java/com/teaching/backend/service/impl/favour/SeResourceFavourServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/favour/SeResourceFavourServiceImpl.java new file mode 100644 index 0000000..4868884 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/favour/SeResourceFavourServiceImpl.java @@ -0,0 +1,67 @@ +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 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 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; + } + } + } + + + +} diff --git a/src/main/java/com/teaching/backend/service/impl/thumb/SeCourseThumbServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/thumb/SeCourseThumbServiceImpl.java new file mode 100644 index 0000000..258c826 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/thumb/SeCourseThumbServiceImpl.java @@ -0,0 +1,106 @@ +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 implements SeCourseThumbService { + + + @Resource + private SeResourceThumbService seResourceThumbService; + + @Resource + SeKnowThumbService seKnowThumbService; + + + @Override + public boolean doCourseThumb(String courseId, String userId) { + System.out.println("进入点赞" + courseId + userId); + // todo 先查询数据库记录,该用户是否点赞 + SeCourseThumb seCourseThumb = new SeCourseThumb(); + seCourseThumb.setCourseId(courseId); + seCourseThumb.setUserId(userId); + QueryWrapper 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 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 ResourceQueryWrapper = new QueryWrapper<>(); + ResourceQueryWrapper.eq("course_id",courseId); + long result1 = seResourceThumbService.count(ResourceQueryWrapper); + QueryWrapper 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; + } + } + + +} diff --git a/src/main/java/com/teaching/backend/service/impl/thumb/SeKnowThumbServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/thumb/SeKnowThumbServiceImpl.java new file mode 100644 index 0000000..27493d6 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/thumb/SeKnowThumbServiceImpl.java @@ -0,0 +1,65 @@ +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 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 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; + } + } + } + + + +} diff --git a/src/main/java/com/teaching/backend/service/impl/thumb/SeResourceThumbServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/thumb/SeResourceThumbServiceImpl.java new file mode 100644 index 0000000..7175b6f --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/thumb/SeResourceThumbServiceImpl.java @@ -0,0 +1,65 @@ +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 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 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; + } + } + } + + + +} diff --git a/src/main/java/com/teaching/backend/service/test1.java b/src/main/java/com/teaching/backend/service/test1.java deleted file mode 100644 index 1508af5..0000000 --- a/src/main/java/com/teaching/backend/service/test1.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.teaching.backend.service; - -/** - * @Author:youhang - * @Date:2024-05-30-18:20 - * @Description: - */ -public class test1 { -} diff --git a/src/main/java/com/teaching/backend/service/thumb/SeCourseThumbService.java b/src/main/java/com/teaching/backend/service/thumb/SeCourseThumbService.java new file mode 100644 index 0000000..0da3a14 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/thumb/SeCourseThumbService.java @@ -0,0 +1,41 @@ +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 { + + /** + * 点赞 + * + * @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); + +} diff --git a/src/main/java/com/teaching/backend/service/thumb/SeKnowThumbService.java b/src/main/java/com/teaching/backend/service/thumb/SeKnowThumbService.java new file mode 100644 index 0000000..f151924 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/thumb/SeKnowThumbService.java @@ -0,0 +1,22 @@ +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 { + + /** + * 点赞 + * + * @param courseId + * @param userId + * @return + */ + boolean doKnowThumb( String courseId,String resourceId, String userId); + +} diff --git a/src/main/java/com/teaching/backend/service/thumb/SeResourceThumbService.java b/src/main/java/com/teaching/backend/service/thumb/SeResourceThumbService.java new file mode 100644 index 0000000..73aff9c --- /dev/null +++ b/src/main/java/com/teaching/backend/service/thumb/SeResourceThumbService.java @@ -0,0 +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 { + + /** + * 点赞 + * + * @param courseId + * @param userId + * @return + */ + boolean doResourceThumb( String courseId,String resourceId, String userId); + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7f1e8c0..51061c8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,4 +13,20 @@ spring: password: root mybatis: configuration: - map-underscore-to-camel-case: true \ No newline at end of file + map-underscore-to-camel-case: true + mapper-locations: + - classpath:dao/*.xml + - classpath*:com/**/mapper/*.xml + + +# 接口文档配置 +knife4j: + enable: true + openapi: + title: "接口文档" + version: 1.0 + group: + default: + api-rule: package + api-rule-resources: + - com.teaching.backend.controller diff --git a/src/main/resources/mapper/SeCourseThumbMapper.xml b/src/main/resources/mapper/SeCourseThumbMapper.xml new file mode 100644 index 0000000..e376fed --- /dev/null +++ b/src/main/resources/mapper/SeCourseThumbMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + id,courseId, + userId + +