Merge remote-tracking branch 'origin/zcc'
This commit is contained in:
@@ -352,7 +352,33 @@ public class BookLabelAndMarketController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分类标签下得商品列表
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getShopProductListByLabelId")
|
||||||
|
public R getShopProductListByLabelId(String labelId){
|
||||||
|
MPJLambdaWrapper<ShopProductToBookLabel> wrapper = new MPJLambdaWrapper();
|
||||||
|
wrapper.eq(ShopProductToBookLabel::getBookLabelId,labelId);
|
||||||
|
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToBookLabel::getProductId);
|
||||||
|
wrapper.selectAll(ShopProduct.class);
|
||||||
|
wrapper.orderByAsc(ShopProductToBookLabel::getSort);
|
||||||
|
List list = toLabelService.listMaps(wrapper);
|
||||||
|
return R.ok().put("result", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取营销标签下得商品列表
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getShopProductListByMarketId")
|
||||||
|
public R getShopProductListByMarketId(String marketId){
|
||||||
|
MPJLambdaWrapper<ShopProductToBookMarket> wrapper = new MPJLambdaWrapper();
|
||||||
|
wrapper.eq(ShopProductToBookMarket::getBookMarketId,marketId);
|
||||||
|
wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToBookMarket::getProductId);
|
||||||
|
wrapper.selectAll(ShopProduct.class);
|
||||||
|
wrapper.orderByAsc(ShopProductToBookMarket::getSort);
|
||||||
|
List list = toMarketService.listMaps(wrapper);
|
||||||
|
return R.ok().put("result", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.peanut.modules.common.dao;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.peanut.modules.common.entity.CourseMedical;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CourseMedicalDao extends MPJBaseMapper<CourseMedical> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.peanut.modules.common.dao;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.peanut.modules.common.entity.CourseToMedical;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CourseToMedicalDao extends MPJBaseMapper<CourseToMedical> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.peanut.modules.common.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
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;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("course_medical")
|
||||||
|
public class CourseMedical {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer pid;
|
||||||
|
|
||||||
|
private Integer isLast;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<CourseMedical> children;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
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_medical")
|
||||||
|
public class CourseToMedical {
|
||||||
|
@TableId
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer courseId;
|
||||||
|
|
||||||
|
private Integer medicalId;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
|
private Integer delFlag;
|
||||||
|
}
|
||||||
@@ -23,6 +23,8 @@ public class ShopProductToBookLabel implements Serializable {
|
|||||||
|
|
||||||
private Integer bookLabelId;
|
private Integer bookLabelId;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public class ShopProductToBookMarket implements Serializable {
|
|||||||
|
|
||||||
private Integer bookMarketId;
|
private Integer bookMarketId;
|
||||||
|
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package com.peanut.modules.master.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.common.entity.CourseEntity;
|
||||||
|
import com.peanut.modules.common.entity.CourseMedical;
|
||||||
|
import com.peanut.modules.common.entity.CourseToMedical;
|
||||||
|
import com.peanut.modules.common.to.ParamTo;
|
||||||
|
import com.peanut.modules.master.service.CourseMedicalService;
|
||||||
|
import com.peanut.modules.master.service.CourseService;
|
||||||
|
import com.peanut.modules.master.service.CourseToMedicalService;
|
||||||
|
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("masterCourseMedical")
|
||||||
|
@RequestMapping("master/courseMedical")
|
||||||
|
public class CourseMedicalController {
|
||||||
|
@Autowired
|
||||||
|
private CourseMedicalService medicalService;
|
||||||
|
@Autowired
|
||||||
|
private CourseToMedicalService toMedicalService;
|
||||||
|
@Autowired
|
||||||
|
private CourseService courseService;
|
||||||
|
|
||||||
|
@RequestMapping("/getCourseMedicalList")
|
||||||
|
public R getCourseMedicalList(){
|
||||||
|
List<CourseMedical> courseMedicalList = medicalService.getCourseMedicalList();
|
||||||
|
return R.ok().put("Medicals",courseMedicalList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/addCourseMedical")
|
||||||
|
public R addCourseMedical(@RequestBody CourseMedical courseMedical){
|
||||||
|
medicalService.save(courseMedical);
|
||||||
|
return R.ok().put("Medical",courseMedical);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/delCourseMedical")
|
||||||
|
public R delCourseMedical(@RequestBody ParamTo param){
|
||||||
|
return medicalService.delCourseMedical(param.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/editCourseMedical")
|
||||||
|
public R editCourseMedical(@RequestBody CourseMedical courseMedical){
|
||||||
|
return medicalService.editCourseMedical(courseMedical);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getCourseListForMedical")
|
||||||
|
public R getCourseListForMedical(@RequestBody ParamTo param){
|
||||||
|
List<CourseEntity> courseListForMedical = courseService.getCourseListForMedical(param.getId());
|
||||||
|
return R.ok().put("courseList",courseListForMedical);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getCourseListCanMedical")
|
||||||
|
public R getCourseListCanMedical(@RequestBody ParamTo param){
|
||||||
|
Page courseListCanMedical = courseService.getCourseListCanMedical(param);
|
||||||
|
return R.ok().put("page",courseListCanMedical);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/bindCourseAndMedical")
|
||||||
|
public R bindCourseAndMedical(@RequestBody CourseToMedical toMedical){
|
||||||
|
return toMedicalService.bindCourseAndMedical(toMedical);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/unbindCourseAndMedical")
|
||||||
|
public R unbindCourseAndMedical(@RequestBody CourseToMedical toMedical){
|
||||||
|
boolean b = toMedicalService.removeById(toMedical.getId());
|
||||||
|
if(b){
|
||||||
|
return R.ok();
|
||||||
|
}else {
|
||||||
|
return R.error("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/updateCourseToMedicalSort")
|
||||||
|
public R updateCourseToMedicalSort(@RequestBody CourseToMedical toMedical){
|
||||||
|
toMedicalService.updateById(toMedical);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.peanut.modules.master.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.common.entity.CourseMedical;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CourseMedicalService extends IService<CourseMedical> {
|
||||||
|
List<CourseMedical> getCourseMedicalList();
|
||||||
|
|
||||||
|
R delCourseMedical(int id);
|
||||||
|
|
||||||
|
R editCourseMedical(CourseMedical courseMedical);
|
||||||
|
}
|
||||||
@@ -19,5 +19,9 @@ public interface CourseService extends IService<CourseEntity> {
|
|||||||
|
|
||||||
Page getCourseListCanSociology(ParamTo param);
|
Page getCourseListCanSociology(ParamTo param);
|
||||||
|
|
||||||
|
List<CourseEntity> getCourseListForMedical(int medicalId);
|
||||||
|
|
||||||
|
Page getCourseListCanMedical(ParamTo param);
|
||||||
|
|
||||||
void testCourse();
|
void testCourse();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.peanut.modules.master.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.common.entity.CourseToMedical;
|
||||||
|
|
||||||
|
public interface CourseToMedicalService extends IService<CourseToMedical> {
|
||||||
|
|
||||||
|
R bindCourseAndMedical(CourseToMedical toMedical);
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.peanut.modules.master.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.common.dao.CourseMedicalDao;
|
||||||
|
import com.peanut.modules.common.dao.CourseToMedicalDao;
|
||||||
|
import com.peanut.modules.common.entity.CourseMedical;
|
||||||
|
import com.peanut.modules.common.entity.CourseToMedical;
|
||||||
|
import com.peanut.modules.master.service.CourseMedicalService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service("masterCourseMedicalService")
|
||||||
|
public class CourseMedicalServiceImpl extends ServiceImpl<CourseMedicalDao, CourseMedical> implements CourseMedicalService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CourseToMedicalDao toMedicalDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CourseMedical> getCourseMedicalList() {
|
||||||
|
return this.medicals(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R delCourseMedical(int id) {
|
||||||
|
//查看下一级是否存在
|
||||||
|
int count = this.count(new LambdaQueryWrapper<CourseMedical>().eq(CourseMedical::getPid, id));
|
||||||
|
if(count>0){
|
||||||
|
return R.error(501,"删除失败,请先删除子项目后再尝试");
|
||||||
|
}
|
||||||
|
//查看绑定关系是否存在
|
||||||
|
Integer integer = toMedicalDao.selectCount(new LambdaQueryWrapper<CourseToMedical>().eq(CourseToMedical::getMedicalId, id));
|
||||||
|
if(integer>0){
|
||||||
|
return R.error(502,"删除失败,请先解绑课程与国学标签的绑定关系");
|
||||||
|
}
|
||||||
|
this.removeById(id);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R editCourseMedical(CourseMedical courseMedical) {
|
||||||
|
CourseMedical old = this.getById(courseMedical.getId());
|
||||||
|
if(old.getIsLast()==0&&courseMedical.getIsLast()==1){
|
||||||
|
CourseMedical one = this.getOne(new LambdaQueryWrapper<CourseMedical>().eq(CourseMedical::getPid, courseMedical.getId()));
|
||||||
|
if(one!=null){
|
||||||
|
return R.error(501,"更新失败,请先清空此项的下级标签,才能将此标签变成终极标签");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(old.getIsLast()==1&&courseMedical.getIsLast()==0){
|
||||||
|
CourseToMedical courseToSociologyEntity = toMedicalDao.selectOne(new LambdaQueryWrapper<CourseToMedical>().eq(CourseToMedical::getMedicalId, courseMedical.getId()));
|
||||||
|
if(courseToSociologyEntity!=null){
|
||||||
|
return R.error(502,"更新失败,请先把此项与课程的关联关系清空后才可把此标签变成普通标签");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.updateById(courseMedical);
|
||||||
|
return R.ok().put("sociology",courseMedical);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CourseMedical> medicals(int id){
|
||||||
|
List<CourseMedical> list = this.list(new LambdaQueryWrapper<CourseMedical>().eq(CourseMedical::getPid, id));
|
||||||
|
for (CourseMedical c : list){
|
||||||
|
if(c.getIsLast()!=1){
|
||||||
|
List<CourseMedical> so = this.medicals(c.getId());
|
||||||
|
c.setChildren(so);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CourseToSociologyDao courseToSociologyDao;
|
private CourseToSociologyDao courseToSociologyDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private CourseMedicalDao medicalDao;
|
||||||
|
@Autowired
|
||||||
|
private CourseToMedicalDao toMedicalDao;
|
||||||
|
@Autowired
|
||||||
private CourseCatalogueDao courseCatalogueDao;
|
private CourseCatalogueDao courseCatalogueDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ShopProductDao shopProductDao;
|
private ShopProductDao shopProductDao;
|
||||||
@@ -123,6 +127,31 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CourseEntity> getCourseListForMedical(int medicalId) {
|
||||||
|
MPJLambdaWrapper<CourseToMedical> wrapper = new MPJLambdaWrapper<>();
|
||||||
|
wrapper.selectAll(CourseEntity.class);
|
||||||
|
wrapper.selectAs(CourseToMedical::getId,"bindId");
|
||||||
|
wrapper.selectAs(CourseToMedical::getSort,"toSociologySort");
|
||||||
|
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,CourseToMedical::getCourseId);
|
||||||
|
wrapper.eq(CourseToMedical::getMedicalId,medicalId);
|
||||||
|
wrapper.orderByAsc(CourseToMedical::getSort);
|
||||||
|
List<CourseEntity> courseEntities = toMedicalDao.selectJoinList(CourseEntity.class, wrapper);
|
||||||
|
return courseEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page getCourseListCanMedical(ParamTo param) {
|
||||||
|
List<Integer> collect = toMedicalDao.selectList(new LambdaQueryWrapper<CourseToMedical>().eq(CourseToMedical::getMedicalId, param.getId())).stream().map(CourseToMedical::getCourseId).collect(Collectors.toList());
|
||||||
|
LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (collect.size() != 0){
|
||||||
|
wrapper.notIn(CourseEntity::getId,collect);
|
||||||
|
}
|
||||||
|
wrapper.like(StringUtils.isNotBlank(param.getKeywords()),CourseEntity::getTitle,param.getKeywords());
|
||||||
|
Page<CourseEntity> page = this.page(new Page<>(param.getPage(), param.getLimit()), wrapper);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testCourse() {
|
public void testCourse() {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.peanut.modules.master.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.common.dao.CourseToMedicalDao;
|
||||||
|
import com.peanut.modules.common.entity.CourseToMedical;
|
||||||
|
import com.peanut.modules.master.service.CourseToMedicalService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service("masterCourseToMedicalService")
|
||||||
|
public class CourseToMedicalServiceImpl extends ServiceImpl<CourseToMedicalDao, CourseToMedical> implements CourseToMedicalService {
|
||||||
|
@Override
|
||||||
|
public R bindCourseAndMedical(CourseToMedical toMedical) {
|
||||||
|
//去重
|
||||||
|
CourseToMedical one = this.getOne(new LambdaQueryWrapper<CourseToMedical>().eq(CourseToMedical::getCourseId, toMedical.getCourseId()).eq(CourseToMedical::getMedicalId, toMedical.getMedicalId()));
|
||||||
|
if(one != null){
|
||||||
|
return R.error(501,"绑定失败,绑定关系已将存在");
|
||||||
|
}
|
||||||
|
this.save(toMedical);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,21 @@
|
|||||||
package com.peanut.modules.medical.controller;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController("medicalCourse")
|
@RestController("medicalCourse")
|
||||||
@RequestMapping("medical/course")
|
@RequestMapping("medical/course")
|
||||||
public class CourseController {
|
public class CourseController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +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("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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -1,4 +1,18 @@
|
|||||||
package com.peanut.modules.medical.service;
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,9 @@ package com.peanut.modules.medical.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
|
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ShopProductMedicineLabelService extends IService<ShopProductMedicineLabel> {
|
public interface ShopProductMedicineLabelService extends IService<ShopProductMedicineLabel> {
|
||||||
|
|
||||||
|
List<ShopProductMedicineLabel> labelTree();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,9 @@ package com.peanut.modules.medical.service;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
|
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ShopProductMedicineMarketService extends IService<ShopProductMedicineMarket> {
|
public interface ShopProductMedicineMarketService extends IService<ShopProductMedicineMarket> {
|
||||||
|
|
||||||
|
List<ShopProductMedicineMarket> marketTree();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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> {
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,47 @@
|
|||||||
package com.peanut.modules.medical.service.impl;
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.peanut.modules.common.dao.ShopProductMedicineLabelDao;
|
import com.peanut.modules.common.dao.ShopProductMedicineLabelDao;
|
||||||
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
|
import com.peanut.modules.common.entity.ShopProductMedicineLabel;
|
||||||
import com.peanut.modules.medical.service.ShopProductMedicineLabelService;
|
import com.peanut.modules.medical.service.ShopProductMedicineLabelService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service("medicineShopProductMedicineLabelService")
|
@Service("medicineShopProductMedicineLabelService")
|
||||||
public class ShopProductMedicineLabelServiceImpl extends ServiceImpl<ShopProductMedicineLabelDao, ShopProductMedicineLabel> implements ShopProductMedicineLabelService {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,47 @@
|
|||||||
package com.peanut.modules.medical.service.impl;
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.peanut.modules.common.dao.ShopProductMedicineMarketDao;
|
import com.peanut.modules.common.dao.ShopProductMedicineMarketDao;
|
||||||
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
|
import com.peanut.modules.common.entity.ShopProductMedicineMarket;
|
||||||
import com.peanut.modules.medical.service.ShopProductMedicineMarketService;
|
import com.peanut.modules.medical.service.ShopProductMedicineMarketService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service("medicineShopProductMedicineMarketService")
|
@Service("medicineShopProductMedicineMarketService")
|
||||||
public class ShopProductMedicineMarketServiceImpl extends ServiceImpl<ShopProductMedicineMarketDao, ShopProductMedicineMarket> implements ShopProductMedicineMarketService {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user