From ce4355d2b1eda887db24189a23ac6b8d291dce80 Mon Sep 17 00:00:00 2001 From: wangjinlei <751475802@qq.com> Date: Thu, 11 Apr 2024 17:33:14 +0800 Subject: [PATCH] 1 --- .../modules/common/dao/CourseMarketDao.java | 9 ++++++ .../modules/common/dao/CourseToMarketDao.java | 9 ++++++ .../modules/common/dao/ShopProductDao.java | 3 +- .../common/entity/CourseMarketEntity.java | 28 +++++++++++++++++++ .../common/entity/CourseToMarketEntity.java | 25 +++++++++++++++++ .../controller/CourseController.java | 28 +++++++++++++++++++ .../sociology/controller/HomeController.java | 13 ++++----- .../controller/ProductController.java | 14 ---------- .../controller/ShopProductController.java | 27 ++++++++++++++++++ .../sociology/service/CourseService.java | 2 ++ .../sociology/service/ShopProductService.java | 11 ++++++++ .../service/impl/CourseServiceImpl.java | 12 ++++++++ .../service/impl/ShopProductServiceImpl.java | 27 ++++++++++++++++++ 13 files changed, 185 insertions(+), 23 deletions(-) create mode 100644 src/main/java/com/peanut/modules/common/dao/CourseMarketDao.java create mode 100644 src/main/java/com/peanut/modules/common/dao/CourseToMarketDao.java create mode 100644 src/main/java/com/peanut/modules/common/entity/CourseMarketEntity.java create mode 100644 src/main/java/com/peanut/modules/common/entity/CourseToMarketEntity.java delete mode 100644 src/main/java/com/peanut/modules/sociology/controller/ProductController.java create mode 100644 src/main/java/com/peanut/modules/sociology/controller/ShopProductController.java create mode 100644 src/main/java/com/peanut/modules/sociology/service/ShopProductService.java create mode 100644 src/main/java/com/peanut/modules/sociology/service/impl/ShopProductServiceImpl.java diff --git a/src/main/java/com/peanut/modules/common/dao/CourseMarketDao.java b/src/main/java/com/peanut/modules/common/dao/CourseMarketDao.java new file mode 100644 index 00000000..b0443f02 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/dao/CourseMarketDao.java @@ -0,0 +1,9 @@ +package com.peanut.modules.common.dao; + +import com.github.yulichang.base.MPJBaseMapper; +import com.peanut.modules.common.entity.CourseMarketEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CourseMarketDao extends MPJBaseMapper { +} diff --git a/src/main/java/com/peanut/modules/common/dao/CourseToMarketDao.java b/src/main/java/com/peanut/modules/common/dao/CourseToMarketDao.java new file mode 100644 index 00000000..f08c4659 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/dao/CourseToMarketDao.java @@ -0,0 +1,9 @@ +package com.peanut.modules.common.dao; + +import com.github.yulichang.base.MPJBaseMapper; +import com.peanut.modules.common.entity.CourseToMarketEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CourseToMarketDao extends MPJBaseMapper { +} diff --git a/src/main/java/com/peanut/modules/common/dao/ShopProductDao.java b/src/main/java/com/peanut/modules/common/dao/ShopProductDao.java index 5cbf9a9d..21081724 100644 --- a/src/main/java/com/peanut/modules/common/dao/ShopProductDao.java +++ b/src/main/java/com/peanut/modules/common/dao/ShopProductDao.java @@ -1,5 +1,6 @@ package com.peanut.modules.common.dao; +import com.github.yulichang.base.MPJBaseMapper; import com.peanut.modules.common.entity.ShopProduct; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -14,7 +15,7 @@ import java.util.List; * @date 2022-10-28 09:43:14 */ @Mapper -public interface ShopProductDao extends BaseMapper { +public interface ShopProductDao extends MPJBaseMapper { List appGetCategoryList(Integer catId); diff --git a/src/main/java/com/peanut/modules/common/entity/CourseMarketEntity.java b/src/main/java/com/peanut/modules/common/entity/CourseMarketEntity.java new file mode 100644 index 00000000..fe176fa0 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/entity/CourseMarketEntity.java @@ -0,0 +1,28 @@ +package com.peanut.modules.common.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +@Data +@TableName("course_market") +public class CourseMarketEntity { + @TableId + private Integer id; + + private Integer pid; + + private Integer isLast; + + private String title; + + private Integer sort; + + private Date createTime; + + @TableLogic + private Integer delFlag; +} diff --git a/src/main/java/com/peanut/modules/common/entity/CourseToMarketEntity.java b/src/main/java/com/peanut/modules/common/entity/CourseToMarketEntity.java new file mode 100644 index 00000000..0cf4f244 --- /dev/null +++ b/src/main/java/com/peanut/modules/common/entity/CourseToMarketEntity.java @@ -0,0 +1,25 @@ +package com.peanut.modules.common.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +@Data +@TableName("course_to_market") +public class CourseToMarketEntity { + + @TableId + private Integer id; + + private Integer courseId; + + private Integer sociologyId; + + private Date createTime; + + @TableLogic + private Integer delFlag; +} diff --git a/src/main/java/com/peanut/modules/sociology/controller/CourseController.java b/src/main/java/com/peanut/modules/sociology/controller/CourseController.java index dede07e6..149a5215 100644 --- a/src/main/java/com/peanut/modules/sociology/controller/CourseController.java +++ b/src/main/java/com/peanut/modules/sociology/controller/CourseController.java @@ -3,6 +3,7 @@ package com.peanut.modules.sociology.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.peanut.common.utils.R; import com.peanut.common.utils.ShiroUtils; +import com.peanut.modules.common.entity.CourseEntity; import com.peanut.modules.common.to.ParamTo; import com.peanut.modules.sociology.service.CourseService; import lombok.extern.slf4j.Slf4j; @@ -19,6 +20,11 @@ public class CourseController { @Autowired private CourseService courseService; + /** + * 获取用户最近学习课程列表 + * @param param + * @return + */ @RequestMapping("/getUserLateCourseList") public R getUserLateCourseList(@RequestBody ParamTo param){ Integer userId = ShiroUtils.getUId(); @@ -27,4 +33,26 @@ public class CourseController { return R.ok().put("page",userLateCourseList); } + /** + * 获取营销标签下的课程列表 + * @param param + * @return + */ + @RequestMapping("/getMarketCourseList") + public R getMarketCourseList(@RequestBody ParamTo param){ + Page marketCourseList = courseService.getMarketCourseList(param); + return R.ok().put("courseList",marketCourseList); + } + + /** + * 获取国学标签下的课程列表 + * @param param + * @return + */ + @RequestMapping("/getSociologyCourseList") + public R getSociologyCourseList(@RequestBody ParamTo param){ + Page sociologyCourseList = courseService.getSociologyCourseList(param); + return R.ok().put("courses",sociologyCourseList); + } + } diff --git a/src/main/java/com/peanut/modules/sociology/controller/HomeController.java b/src/main/java/com/peanut/modules/sociology/controller/HomeController.java index 413b09fe..6908073e 100644 --- a/src/main/java/com/peanut/modules/sociology/controller/HomeController.java +++ b/src/main/java/com/peanut/modules/sociology/controller/HomeController.java @@ -33,19 +33,16 @@ public class HomeController { return R.ok().put("myCourse",courseList); } + /** + *获取国学标签列表 + * @param param + * @return + */ @RequestMapping("/getSociologyLabels") public R getSociologyLabels(@RequestBody ParamTo param){ List sociologyLabels = courseSociologyService.getSociologyLabels(param.getId()); return R.ok().put("labels",sociologyLabels); } - @RequestMapping("/getSociologyCourseList") - public R getSociologyCourseList(@RequestBody ParamTo param){ - Page sociologyCourseList = courseService.getSociologyCourseList(param); - return R.ok().put("courses",sociologyCourseList); - } - - - } diff --git a/src/main/java/com/peanut/modules/sociology/controller/ProductController.java b/src/main/java/com/peanut/modules/sociology/controller/ProductController.java deleted file mode 100644 index 7f539ae8..00000000 --- a/src/main/java/com/peanut/modules/sociology/controller/ProductController.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.peanut.modules.sociology.controller; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@Slf4j -@RestController("sociologyProduct") -@RequestMapping("sociology/product") -public class ProductController { - - - -} diff --git a/src/main/java/com/peanut/modules/sociology/controller/ShopProductController.java b/src/main/java/com/peanut/modules/sociology/controller/ShopProductController.java new file mode 100644 index 00000000..c50aef59 --- /dev/null +++ b/src/main/java/com/peanut/modules/sociology/controller/ShopProductController.java @@ -0,0 +1,27 @@ +package com.peanut.modules.sociology.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.peanut.common.utils.R; +import com.peanut.modules.common.to.ParamTo; +import com.peanut.modules.sociology.service.ShopProductService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@RestController("sociologyProduct") +@RequestMapping("sociology/product") +public class ShopProductController { + @Autowired + private ShopProductService shopProductService; + + @RequestMapping("/getMarketProductList") + public R getMarketProductList(@RequestBody ParamTo param){ + Page marketProductList = shopProductService.getMarketProductList(param); + return R.ok().put("products",marketProductList); + } + + +} diff --git a/src/main/java/com/peanut/modules/sociology/service/CourseService.java b/src/main/java/com/peanut/modules/sociology/service/CourseService.java index 8117a7f5..ab8f0a84 100644 --- a/src/main/java/com/peanut/modules/sociology/service/CourseService.java +++ b/src/main/java/com/peanut/modules/sociology/service/CourseService.java @@ -17,4 +17,6 @@ public interface CourseService extends IService { Page getUserLateCourseList(ParamTo param); + Page getMarketCourseList(ParamTo param); + } diff --git a/src/main/java/com/peanut/modules/sociology/service/ShopProductService.java b/src/main/java/com/peanut/modules/sociology/service/ShopProductService.java new file mode 100644 index 00000000..f6f27ff7 --- /dev/null +++ b/src/main/java/com/peanut/modules/sociology/service/ShopProductService.java @@ -0,0 +1,11 @@ +package com.peanut.modules.sociology.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.modules.common.entity.ShopProduct; +import com.peanut.modules.common.to.ParamTo; + +public interface ShopProductService extends IService { + + Page getMarketProductList(ParamTo param); +} diff --git a/src/main/java/com/peanut/modules/sociology/service/impl/CourseServiceImpl.java b/src/main/java/com/peanut/modules/sociology/service/impl/CourseServiceImpl.java index 3a7592d7..4447f5fc 100644 --- a/src/main/java/com/peanut/modules/sociology/service/impl/CourseServiceImpl.java +++ b/src/main/java/com/peanut/modules/sociology/service/impl/CourseServiceImpl.java @@ -8,6 +8,7 @@ import com.peanut.modules.common.dao.CourseDao; import com.peanut.modules.common.dao.CourseToSociologyDao; import com.peanut.modules.common.dao.UserToCourseDao; import com.peanut.modules.common.entity.CourseEntity; +import com.peanut.modules.common.entity.CourseToMarketEntity; import com.peanut.modules.common.entity.CourseToSociologyEntity; import com.peanut.modules.common.entity.UserToCourseEntity; import com.peanut.modules.common.to.ParamTo; @@ -65,6 +66,17 @@ public class CourseServiceImpl extends ServiceImpl impl wrapper.selectAll(CourseEntity.class); wrapper.leftJoin(UserToCourseEntity.class,UserToCourseEntity::getCourseId,CourseEntity::getId); wrapper.eq(UserToCourseEntity::getUserId,param.getId()); + wrapper.orderByDesc(UserToCourseEntity::getUpdateTime); + Page courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()), CourseEntity.class, wrapper); + return courseEntityPage; + } + + @Override + public Page getMarketCourseList(ParamTo param) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.selectAll(CourseEntity.class); + wrapper.leftJoin(CourseToMarketEntity.class,CourseToMarketEntity::getCourseId,CourseEntity::getId); + wrapper.eq(CourseToMarketEntity::getId,param.getId()); Page courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()), CourseEntity.class, wrapper); return courseEntityPage; } diff --git a/src/main/java/com/peanut/modules/sociology/service/impl/ShopProductServiceImpl.java b/src/main/java/com/peanut/modules/sociology/service/impl/ShopProductServiceImpl.java new file mode 100644 index 00000000..2a478b97 --- /dev/null +++ b/src/main/java/com/peanut/modules/sociology/service/impl/ShopProductServiceImpl.java @@ -0,0 +1,27 @@ +package com.peanut.modules.sociology.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import com.peanut.modules.common.dao.ShopProductDao; +import com.peanut.modules.common.entity.ShopProduct; +import com.peanut.modules.common.entity.ShopProductToSociologyMarket; +import com.peanut.modules.common.to.ParamTo; +import com.peanut.modules.sociology.service.ShopProductService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service("sociologyShopProduct") +public class ShopProductServiceImpl extends ServiceImpl implements ShopProductService { + + @Override + public Page getMarketProductList(ParamTo param) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.selectAll(ShopProduct.class); + wrapper.leftJoin(ShopProductToSociologyMarket.class,ShopProductToSociologyMarket::getProductId,ShopProduct::getProductId); + wrapper.eq(ShopProductToSociologyMarket::getSociologyMarketId,param.getId()); + Page shopProductPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()), ShopProduct.class, wrapper); + return shopProductPage; + } +}