diff --git a/src/main/java/com/teaching/backend/controller/know/KnowController.java b/src/main/java/com/teaching/backend/controller/know/KnowController.java new file mode 100644 index 0000000..a546c8d --- /dev/null +++ b/src/main/java/com/teaching/backend/controller/know/KnowController.java @@ -0,0 +1,51 @@ +package com.teaching.backend.controller.know; + +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.know.KnowAddRequest; + +import com.teaching.backend.service.know.KnowService; + +import org.springframework.beans.factory.annotation.Autowired; +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; + + +/** + * @Author:youhang + * @Date:2024-06-17-11:57 + * @Description: + */ +@RestController +@RequestMapping("/konw") +public class KnowController { + + @Autowired + private KnowService knowService; + + + /** + * 知识点添加 + * + */ + @PostMapping("/add") + // 加上 HttpServletRequest request 在一个fitter里面进行鉴权操作 + public BaseResponse doFavour(@RequestBody KnowAddRequest knowAddRequest) { + // todo 字段判空 合法 + + // todo 字段是否存在 + + Boolean result = knowService.add(knowAddRequest); + + if(!result) { + throw new BusinessException(ErrorCode.SYSTEM_ERROR); + } + + return ResultUtils.success(result); + } +} diff --git a/src/main/java/com/teaching/backend/model/dto/know/KnowAddRequest.java b/src/main/java/com/teaching/backend/model/dto/know/KnowAddRequest.java new file mode 100644 index 0000000..9f093ee --- /dev/null +++ b/src/main/java/com/teaching/backend/model/dto/know/KnowAddRequest.java @@ -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; + + +} diff --git a/src/main/java/com/teaching/backend/model/entity/know/Know.java b/src/main/java/com/teaching/backend/model/entity/know/Know.java index 9d2fbf5..131561f 100644 --- a/src/main/java/com/teaching/backend/model/entity/know/Know.java +++ b/src/main/java/com/teaching/backend/model/entity/know/Know.java @@ -17,7 +17,6 @@ import java.time.LocalDateTime; @Data @EqualsAndHashCode(callSuper = false) -@Accessors(chain = true) @TableName("know") public class Know implements Serializable { @@ -26,8 +25,8 @@ public class Know implements Serializable { /** * id */ - @TableId(value = "id", type = IdType.ASSIGN_UUID) - private String id; + @TableId(value = "id", type = IdType.AUTO) + private Long id; /** * 知识点名称 @@ -54,10 +53,12 @@ public class Know implements Serializable { */ private BigDecimal hour; + + /** - * 知识点类型 + * 资源id 运用json */ - private String type; + private String resourceid; } diff --git a/src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java b/src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java index b6d7b1f..20a763c 100644 --- a/src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java +++ b/src/main/java/com/teaching/backend/service/favour/SeResourceFavourService.java @@ -1,8 +1,12 @@ 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.SeResourceFavour; +import com.teaching.backend.model.vo.favour.CourseFavourDetailVO; /** * @Author:youhang @@ -20,4 +24,14 @@ public interface SeResourceFavourService extends IService { */ BaseResponse doResourceFavour(String courseId, String resourceId, String userId); + + /** + * 某个用户资源列表全部信息 + * + * @param page + * @param queryWrapper + * @return + */ + public Page listCourseFavourByPage(Page page, Wrapper queryWrapper); + } diff --git a/src/main/java/com/teaching/backend/service/impl/know/IknowServiceimpl.java b/src/main/java/com/teaching/backend/service/impl/know/IknowServiceimpl.java deleted file mode 100644 index fb99ff7..0000000 --- a/src/main/java/com/teaching/backend/service/impl/know/IknowServiceimpl.java +++ /dev/null @@ -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 implements IknowService { - -} diff --git a/src/main/java/com/teaching/backend/service/impl/know/KnowServiceimpl.java b/src/main/java/com/teaching/backend/service/impl/know/KnowServiceimpl.java new file mode 100644 index 0000000..d3952e7 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/impl/know/KnowServiceimpl.java @@ -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 implements KnowService { + @Autowired + private KnowMapper knowMapper; + @Override + public Boolean add(KnowAddRequest knowAddRequest) { + Know know = new Know(); + BeanUtils.copyProperties(knowAddRequest,know); + return (save(know)); + } +} diff --git a/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java b/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java index 52da01f..9da33fe 100644 --- a/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java +++ b/src/main/java/com/teaching/backend/service/impl/records/LearningRecordsServiceImpl.java @@ -11,7 +11,7 @@ import com.teaching.backend.model.entity.records.LearningRecords; import com.teaching.backend.model.vo.records.LearningRecordsVo; import com.teaching.backend.service.impl.chapter.ChapterServiceImpl; import com.teaching.backend.service.impl.courses.CoursesServiceImpl; -import com.teaching.backend.service.impl.know.IknowServiceimpl; +import com.teaching.backend.service.impl.know.KnowServiceimpl; import com.teaching.backend.service.records.LearningRecordsService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -34,7 +34,7 @@ public class LearningRecordsServiceImpl extends ServiceImpl { - -} - diff --git a/src/main/java/com/teaching/backend/service/know/KnowService.java b/src/main/java/com/teaching/backend/service/know/KnowService.java new file mode 100644 index 0000000..ab07327 --- /dev/null +++ b/src/main/java/com/teaching/backend/service/know/KnowService.java @@ -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 { + public Boolean add(KnowAddRequest knowAddRequest); +} + diff --git a/src/main/java/com/teaching/backend/utils/ParamOutAspect.java b/src/main/java/com/teaching/backend/utils/ParamOutAspect.java new file mode 100644 index 0000000..535b45b --- /dev/null +++ b/src/main/java/com/teaching/backend/utils/ParamOutAspect.java @@ -0,0 +1,9 @@ +package com.teaching.backend.utils; + +/** + * @Author:youhang + * @Date:2024-06-17-23:15 + * @Description: + */ +public class ParamOutAspect { +}