吴门医述-首页

This commit is contained in:
wuchunlei
2024-05-17 09:58:34 +08:00
parent 4c8fff6bc0
commit b50293835b
16 changed files with 396 additions and 13 deletions

View File

@@ -1,11 +1,21 @@
package com.peanut.modules.medical.controller;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@RestController("medicalCourse")
@RequestMapping("medical/course")
public class CourseController {
}

View File

@@ -1,11 +0,0 @@
package com.peanut.modules.medical.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController("medicalCourseMedical")
@RequestMapping("medical/courseMedical")
public class CourseMedicalController {
}

View File

@@ -0,0 +1,74 @@
package com.peanut.modules.medical.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.entity.CourseMarketEntity;
import com.peanut.modules.common.entity.CourseMedical;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.medical.service.CourseMarketService;
import com.peanut.modules.medical.service.CourseMedicalService;
import com.peanut.modules.medical.service.CourseService;
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;
import java.util.List;
@Slf4j
@RestController("medicalHome")
@RequestMapping("medical/home")
public class HomeController {
@Autowired
private CourseService courseService;
@Autowired
private CourseMedicalService medicalService;
@Autowired
private CourseMarketService courseMarketService;
//获取医学标签列表
@RequestMapping("/getMedicalLabels")
public R getMedicalLabels(@RequestBody ParamTo param){
List<CourseMedical> sociologyLabels = medicalService.getMedicalLabels(param.getId());
return R.ok().put("labels",sociologyLabels);
}
//获取医学标签下的课程列表
@RequestMapping("/getMedicalCourseList")
public R getMedicalCourseList(@RequestBody ParamTo param){
Page medicalCourseList = courseService.getMedicalCourseList(param);
return R.ok().put("courses",medicalCourseList);
}
/**
* 营销标签树
*/
@RequestMapping(path = "/courseMarketTree")
public R courseMarketTree() {
List<CourseMarketEntity> labelsTree = courseMarketService.courseMarketTree();
return R.ok().put("result", labelsTree);
}
//获取营销标签下的课程列表
@RequestMapping("/getMarketCourseList")
public R getMarketCourseList(@RequestBody ParamTo param){
Page<CourseEntity> marketCourseList = courseService.getMarketCourseList(param);
return R.ok().put("courseList",marketCourseList);
}
/**
* 获取用户最近学习课程列表
* @return
*/
@RequestMapping("/getUserLateCourseList")
public R getUserLateCourseList(){
ParamTo param = new ParamTo();
Integer userId = ShiroUtils.getUId();
param.setId(userId);
List<CourseEntity> userLateCourseList = courseService.getUserLateCourseList(param);
return R.ok().put("page",userLateCourseList);
}
}

View File

@@ -1,14 +1,67 @@
package com.peanut.modules.medical.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.medical.service.ShopProductMedicineLabelService;
import com.peanut.modules.medical.service.ShopProductMedicineMarketService;
import com.peanut.modules.medical.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;
import java.util.List;
import java.util.Map;
/**
* 医学课程和营销标签
*/
@Slf4j
@RestController
@RequestMapping("book/labelAndMarket")
@RequestMapping("medical/labelAndMarket")
public class MedicalLabelAndMarketController {
@Autowired
private ShopProductMedicineLabelService labelService;
@Autowired
private ShopProductMedicineMarketService marketService;
@Autowired
private ShopProductService productService;
/**
* 分类标签树
*/
@RequestMapping(path = "/labelTree")
public R labelTree() {
List<ShopProductMedicineLabel> labelsTree = labelService.labelTree();
return R.ok().put("result", labelsTree);
}
/**
* 营销标签树
*/
@RequestMapping(path = "/marketTree")
public R marketTree() {
List<ShopProductMedicineMarket> marketsTree = marketService.marketTree();
return R.ok().put("result", marketsTree);
}
/**
* 营销标签下商品列表
*/
@RequestMapping("/getMarketShopProductList")
public R getToLabelList(@RequestBody Map params){
MPJLambdaWrapper<ShopProduct> wrapper = new MPJLambdaWrapper();
wrapper.selectAll(ShopProduct.class);
wrapper.rightJoin(ShopProductToMedicineMarket.class,ShopProductToMedicineMarket::getProductId,ShopProduct::getProductId);
if (params.containsKey("medicineMarketId")&&!"".equals(params.get("medicineMarketId").toString())){
wrapper.eq(ShopProductToMedicineMarket::getMedicineMarketId,params.get("medicineMarketId").toString());
}
Page<ShopProduct> page = productService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("result", page);
}
}

View File

@@ -0,0 +1,11 @@
package com.peanut.modules.medical.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.CourseMarketEntity;
import java.util.List;
public interface CourseMarketService extends IService<CourseMarketEntity> {
List<CourseMarketEntity> courseMarketTree();
}

View File

@@ -0,0 +1,11 @@
package com.peanut.modules.medical.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.CourseMedical;
import java.util.List;
public interface CourseMedicalService extends IService<CourseMedical> {
List<CourseMedical> getMedicalLabels(Integer id);
}

View File

@@ -1,4 +1,18 @@
package com.peanut.modules.medical.service;
public interface CourseService {
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.CourseEntity;
import com.peanut.modules.common.to.ParamTo;
import java.util.List;
public interface CourseService extends IService<CourseEntity> {
Page<CourseEntity> getMedicalCourseList(ParamTo param);
Page<CourseEntity> getMarketCourseList(ParamTo param);
List<CourseEntity> getUserLateCourseList(ParamTo param);
}

View File

@@ -3,5 +3,9 @@ package com.peanut.modules.medical.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
import java.util.List;
public interface ShopProductMedicineLabelService extends IService<ShopProductMedicineLabel> {
List<ShopProductMedicineLabel> labelTree();
}

View File

@@ -3,5 +3,9 @@ package com.peanut.modules.medical.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
import java.util.List;
public interface ShopProductMedicineMarketService extends IService<ShopProductMedicineMarket> {
List<ShopProductMedicineMarket> marketTree();
}

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.medical.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.ShopProduct;
public interface ShopProductService extends IService<ShopProduct> {
}

View File

@@ -0,0 +1,47 @@
package com.peanut.modules.medical.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.CourseMarketDao;
import com.peanut.modules.common.entity.CourseMarketEntity;
import com.peanut.modules.medical.service.CourseMarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service("medicalCourseMarketService")
public class CourseMarketServiceImpl extends ServiceImpl<CourseMarketDao, CourseMarketEntity> implements CourseMarketService {
@Autowired
private CourseMarketDao courseMarketDao;
@Override
public List<CourseMarketEntity> courseMarketTree() {
List<CourseMarketEntity> markets = courseMarketDao.selectList(new QueryWrapper<>());
List<CourseMarketEntity> marketsTree = markets.stream().filter((courseMarketEntity) ->
courseMarketEntity.getPid() == 0
).map((market)->{
market.setChildren(getMarketChildrens(market,markets));
return market;
}).sorted((sort1,sort2)->{
return (sort1.getSort() == null? 0 : sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
}).collect(Collectors.toList());
return marketsTree;
}
private List<CourseMarketEntity> getMarketChildrens(CourseMarketEntity root,List<CourseMarketEntity> all){
List<CourseMarketEntity> children = all.stream().filter(courseMarketEntity -> {
return root.getId().equals(courseMarketEntity.getPid());
}).map(courseMarketEntity -> {
courseMarketEntity.setChildren(getMarketChildrens(courseMarketEntity, all));
return courseMarketEntity;
}).sorted((sort1,sort2)->{
return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
}).collect(Collectors.toList());
return children;
}
}

View File

@@ -0,0 +1,24 @@
package com.peanut.modules.medical.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.CourseMedicalDao;
import com.peanut.modules.common.entity.CourseMedical;
import com.peanut.modules.medical.service.CourseMedicalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service("medicineCourseMedicalService")
public class CourseMedicalServiceImpl extends ServiceImpl<CourseMedicalDao, CourseMedical> implements CourseMedicalService {
@Override
public List<CourseMedical> getMedicalLabels(Integer id) {
LambdaQueryWrapper<CourseMedical> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CourseMedical::getPid,id);
wrapper.orderByAsc(CourseMedical::getSort);
List<CourseMedical> list = this.list(wrapper);
return list;
}
}

View File

@@ -0,0 +1,54 @@
package com.peanut.modules.medical.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.CourseDao;
import com.peanut.modules.common.entity.CourseEntity;
import com.peanut.modules.common.entity.CourseToMarketEntity;
import com.peanut.modules.common.entity.CourseToMedical;
import com.peanut.modules.common.entity.UserToCourseEntity;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.medical.service.CourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service("medicalCourseService")
public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> implements CourseService {
@Override
public Page<CourseEntity> getMedicalCourseList(ParamTo param) {
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(CourseEntity.class);
wrapper.leftJoin(CourseToMedical.class,CourseToMedical::getCourseId,CourseEntity::getId);
wrapper.eq(CourseToMedical::getMedicalId,param.getId());
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()),CourseEntity.class, wrapper);
return courseEntityPage;
}
@Override
public Page<CourseEntity> getMarketCourseList(ParamTo param) {
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(CourseEntity.class);
wrapper.leftJoin(CourseToMarketEntity.class,CourseToMarketEntity::getCourseId,CourseEntity::getId);
wrapper.eq(CourseToMarketEntity::getMarketId,param.getId());
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()), CourseEntity.class, wrapper);
return courseEntityPage;
}
@Override
public List<CourseEntity> getUserLateCourseList(ParamTo param) {
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(CourseEntity.class);
wrapper.rightJoin(CourseToMedical.class,CourseToMedical::getCourseId,CourseEntity::getId);
wrapper.leftJoin(UserToCourseEntity.class,UserToCourseEntity::getCourseId,CourseEntity::getId);
wrapper.eq(UserToCourseEntity::getUserId,param.getId());
wrapper.orderByDesc(UserToCourseEntity::getUpdateTime);
wrapper.last("Limit 4");
List<CourseEntity> courseEntities = this.getBaseMapper().selectJoinList(CourseEntity.class, wrapper);
return courseEntities;
}
}

View File

@@ -1,13 +1,47 @@
package com.peanut.modules.medical.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductMedicineLabelDao;
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
import com.peanut.modules.medical.service.ShopProductMedicineLabelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service("medicineShopProductMedicineLabelService")
public class ShopProductMedicineLabelServiceImpl extends ServiceImpl<ShopProductMedicineLabelDao, ShopProductMedicineLabel> implements ShopProductMedicineLabelService {
@Autowired
private ShopProductMedicineLabelDao labelDao;
@Override
public List<ShopProductMedicineLabel> labelTree() {
List<ShopProductMedicineLabel> labels = labelDao.selectList(new QueryWrapper<>());
List<ShopProductMedicineLabel> labelsTree = labels.stream().filter((shopProductMedicineLabel) ->
shopProductMedicineLabel.getPid() == 0
).map((label)->{
label.setChildren(getLabelChildrens(label,labels));
return label;
}).sorted((label1,label2)->{
return (label1.getSort() == null? 0 : label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
}).collect(Collectors.toList());
return labelsTree;
}
private List<ShopProductMedicineLabel> getLabelChildrens(ShopProductMedicineLabel root,List<ShopProductMedicineLabel> all){
List<ShopProductMedicineLabel> children = all.stream().filter(shopProductMedicineLabel -> {
return root.getId().equals(shopProductMedicineLabel.getPid());
}).map(shopProductMedicineLabel -> {
shopProductMedicineLabel.setChildren(getLabelChildrens(shopProductMedicineLabel, all));
return shopProductMedicineLabel;
}).sorted((label1,label2)->{
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
}).collect(Collectors.toList());
return children;
}
}

View File

@@ -1,13 +1,47 @@
package com.peanut.modules.medical.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductMedicineMarketDao;
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
import com.peanut.modules.medical.service.ShopProductMedicineMarketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service("medicineShopProductMedicineMarketService")
public class ShopProductMedicineMarketServiceImpl extends ServiceImpl<ShopProductMedicineMarketDao, ShopProductMedicineMarket> implements ShopProductMedicineMarketService {
@Autowired
private ShopProductMedicineMarketDao marketDao;
@Override
public List<ShopProductMedicineMarket> marketTree() {
List<ShopProductMedicineMarket> markets = marketDao.selectList(new QueryWrapper<>());
List<ShopProductMedicineMarket> marketsTree = markets.stream().filter((shopProductMedicineMarket) ->
shopProductMedicineMarket.getPid() == 0
).map((market)->{
market.setChildren(getMarketChildrens(market,markets));
return market;
}).sorted((sort1,sort2)->{
return (sort1.getSort() == null? 0 : sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
}).collect(Collectors.toList());
return marketsTree;
}
private List<ShopProductMedicineMarket> getMarketChildrens(ShopProductMedicineMarket root,List<ShopProductMedicineMarket> all){
List<ShopProductMedicineMarket> children = all.stream().filter(shopProductMedicineMarket -> {
return root.getId().equals(shopProductMedicineMarket.getPid());
}).map(shopProductMedicineMarket -> {
shopProductMedicineMarket.setChildren(getMarketChildrens(shopProductMedicineMarket, all));
return shopProductMedicineMarket;
}).sorted((sort1,sort2)->{
return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
}).collect(Collectors.toList());
return children;
}
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.medical.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.ShopProductDao;
import com.peanut.modules.common.entity.ShopProduct;
import com.peanut.modules.medical.service.ShopProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("medicalShopProductService")
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProduct> implements ShopProductService {
}