diff --git a/src/main/java/com/peanut/modules/common/controller/MessageController.java b/src/main/java/com/peanut/modules/common/controller/MessageController.java index 4e54bd68..ac38212f 100644 --- a/src/main/java/com/peanut/modules/common/controller/MessageController.java +++ b/src/main/java/com/peanut/modules/common/controller/MessageController.java @@ -32,6 +32,7 @@ public class MessageController { wrapper.eq(message.getIsBook()==1,Message::getIsBook,1); wrapper.eq(message.getIsMedical()==1,Message::getIsMedical,1); wrapper.eq(message.getIsSociology()==1,Message::getIsSociology,1); + wrapper.eq(message.getIsPsyche()==1,Message::getIsPsyche,1); wrapper.orderByDesc(Message::getCreateTime); List messages = messageService.getBaseMapper().selectList(wrapper); return R.ok().put("messages", messages); diff --git a/src/main/java/com/peanut/modules/common/entity/Message.java b/src/main/java/com/peanut/modules/common/entity/Message.java index 483c4241..f919e116 100644 --- a/src/main/java/com/peanut/modules/common/entity/Message.java +++ b/src/main/java/com/peanut/modules/common/entity/Message.java @@ -50,6 +50,11 @@ public class Message { */ private Integer isSociology; + /** + * 是否在心灵空间显示0否1是 + */ + private Integer isPsyche; + private Date createTime; @TableLogic diff --git a/src/main/java/com/peanut/modules/common/service/CoursePsycheMarketService.java b/src/main/java/com/peanut/modules/common/service/CoursePsycheMarketService.java index 69763497..8466b69e 100644 --- a/src/main/java/com/peanut/modules/common/service/CoursePsycheMarketService.java +++ b/src/main/java/com/peanut/modules/common/service/CoursePsycheMarketService.java @@ -2,6 +2,9 @@ package com.peanut.modules.common.service; import com.baomidou.mybatisplus.extension.service.IService; import com.peanut.modules.common.entity.CoursePsycheMarket; +import java.util.List; public interface CoursePsycheMarketService extends IService { + + List marketTree(); } diff --git a/src/main/java/com/peanut/modules/common/service/CoursePsycheService.java b/src/main/java/com/peanut/modules/common/service/CoursePsycheService.java index 227f428b..5cf60e08 100644 --- a/src/main/java/com/peanut/modules/common/service/CoursePsycheService.java +++ b/src/main/java/com/peanut/modules/common/service/CoursePsycheService.java @@ -1,7 +1,18 @@ package com.peanut.modules.common.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.common.utils.R; import com.peanut.modules.common.entity.CoursePsyche; +import java.util.List; public interface CoursePsycheService extends IService { + + List getCoursePsycheTree(); + + List getCoursePsycheList(); + + R delCoursePsyche(int id); + + R editCoursePsyche(CoursePsyche coursePsyche); + } diff --git a/src/main/java/com/peanut/modules/common/service/CourseToPsycheMarketService.java b/src/main/java/com/peanut/modules/common/service/CourseToPsycheMarketService.java index 70154bf9..2ac91f50 100644 --- a/src/main/java/com/peanut/modules/common/service/CourseToPsycheMarketService.java +++ b/src/main/java/com/peanut/modules/common/service/CourseToPsycheMarketService.java @@ -3,5 +3,9 @@ package com.peanut.modules.common.service; import com.baomidou.mybatisplus.extension.service.IService; import com.peanut.modules.common.entity.CourseToPsycheMarket; +import java.util.List; + public interface CourseToPsycheMarketService extends IService { + + List getCourseListByMarketId(int marketId); } diff --git a/src/main/java/com/peanut/modules/common/service/CourseToPsycheService.java b/src/main/java/com/peanut/modules/common/service/CourseToPsycheService.java index a921fdbc..19dec021 100644 --- a/src/main/java/com/peanut/modules/common/service/CourseToPsycheService.java +++ b/src/main/java/com/peanut/modules/common/service/CourseToPsycheService.java @@ -1,7 +1,10 @@ package com.peanut.modules.common.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.peanut.common.utils.R; import com.peanut.modules.common.entity.CourseToPsyche; public interface CourseToPsycheService extends IService { + + R bindCourseAndPsyche(CourseToPsyche toPsyche); } diff --git a/src/main/java/com/peanut/modules/common/service/ShopProductPsycheLabelService.java b/src/main/java/com/peanut/modules/common/service/ShopProductPsycheLabelService.java index 523142c8..cebbbfac 100644 --- a/src/main/java/com/peanut/modules/common/service/ShopProductPsycheLabelService.java +++ b/src/main/java/com/peanut/modules/common/service/ShopProductPsycheLabelService.java @@ -2,6 +2,9 @@ package com.peanut.modules.common.service; import com.baomidou.mybatisplus.extension.service.IService; import com.peanut.modules.common.entity.ShopProductPsycheLabel; +import java.util.List; public interface ShopProductPsycheLabelService extends IService { + + List labelTree(); } diff --git a/src/main/java/com/peanut/modules/common/service/ShopProductPsycheMarketService.java b/src/main/java/com/peanut/modules/common/service/ShopProductPsycheMarketService.java index 86354e8c..10712d22 100644 --- a/src/main/java/com/peanut/modules/common/service/ShopProductPsycheMarketService.java +++ b/src/main/java/com/peanut/modules/common/service/ShopProductPsycheMarketService.java @@ -3,5 +3,9 @@ package com.peanut.modules.common.service; import com.baomidou.mybatisplus.extension.service.IService; import com.peanut.modules.common.entity.ShopProductPsycheMarket; +import java.util.List; + public interface ShopProductPsycheMarketService extends IService { + + List marketTree(); } diff --git a/src/main/java/com/peanut/modules/common/service/ShopProductToPsycheMarketService.java b/src/main/java/com/peanut/modules/common/service/ShopProductToPsycheMarketService.java index 7be4a9fa..bd8b2213 100644 --- a/src/main/java/com/peanut/modules/common/service/ShopProductToPsycheMarketService.java +++ b/src/main/java/com/peanut/modules/common/service/ShopProductToPsycheMarketService.java @@ -3,5 +3,9 @@ package com.peanut.modules.common.service; import com.baomidou.mybatisplus.extension.service.IService; import com.peanut.modules.common.entity.ShopProductToPsycheMarket; +import java.util.Map; + public interface ShopProductToPsycheMarketService extends IService { + + void editToMarketSort(Map map); } diff --git a/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheMarketServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheMarketServiceImpl.java index b739529f..06c6ad8b 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheMarketServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheMarketServiceImpl.java @@ -1,13 +1,45 @@ package com.peanut.modules.common.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.peanut.modules.common.dao.CoursePsycheMarketDao; import com.peanut.modules.common.entity.CoursePsycheMarket; +import com.peanut.modules.common.entity.CourseSociologyMarketEntity; import com.peanut.modules.common.service.CoursePsycheMarketService; 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("commonCoursePsycheMarketService") public class CoursePsycheMarketServiceImpl extends ServiceImpl implements CoursePsycheMarketService { + @Autowired + private CoursePsycheMarketDao marketDao; + + @Override + public List marketTree() { + List markets = marketDao.selectList(new QueryWrapper<>()); + List marketsTree = markets.stream().filter((coursePsycheMarket) -> + coursePsycheMarket.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 getMarketChildrens(CoursePsycheMarket root, List all){ + List children = all.stream().filter(CoursePsycheMarket -> { + return root.getId().equals(CoursePsycheMarket.getPid()); + }).map(coursePsycheMarket -> { + coursePsycheMarket.setChildren(getMarketChildrens(coursePsycheMarket, all)); + return coursePsycheMarket; + }).sorted((sort1,sort2)->{ + return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort()); + }).collect(Collectors.toList()); + return children; + } } \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheServiceImpl.java index 3bfc5156..6acf09a0 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/CoursePsycheServiceImpl.java @@ -1,13 +1,106 @@ package com.peanut.modules.common.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.common.utils.R; import com.peanut.modules.common.dao.CoursePsycheDao; +import com.peanut.modules.common.dao.CourseToPsycheDao; import com.peanut.modules.common.entity.CoursePsyche; +import com.peanut.modules.common.entity.CourseToPsyche; import com.peanut.modules.common.service.CoursePsycheService; 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("commonCoursePsycheService") public class CoursePsycheServiceImpl extends ServiceImpl implements CoursePsycheService { + + @Autowired + private CourseToPsycheDao courseToPsycheDao; + + @Override + public List getCoursePsycheTree() { + List psyches = this.list(new QueryWrapper<>()); + List psycheTree = psyches.stream().filter((coursePsyche) -> + coursePsyche.getPid() == 0 + ).map((psyche)->{ + psyche.setChildren(getPsycheChildrens(psyche,psyches)); + return psyche; + }).sorted((sort1,sort2)->{ + return (sort1.getSort() == null? 0 : sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort()); + }).collect(Collectors.toList()); + return psycheTree; + } + private List getPsycheChildrens(CoursePsyche root, List all){ + List children = all.stream().filter(coursePsyche -> { + return root.getId().equals(coursePsyche.getPid()); + }).map(coursePsyche -> { + coursePsyche.setChildren(getPsycheChildrens(coursePsyche, all)); + return coursePsyche; + }).sorted((sort1,sort2)->{ + return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort()); + }).collect(Collectors.toList()); + return children; + } + + @Override + public List getCoursePsycheList() { + return this.Psyches(0); + } + + @Override + public R delCoursePsyche(int id) { + //查看下一级是否存在 + int count = this.count(new LambdaQueryWrapper().eq(CoursePsyche::getPid, id)); + if(count>0){ + return R.error(501,"删除失败,请先删除子项目后再尝试"); + } + //查看绑定关系是否存在 + Integer integer = courseToPsycheDao.selectCount(new LambdaQueryWrapper().eq(CourseToPsyche::getPsycheId, id)); + if(integer>0){ + return R.error(502,"删除失败,请先解绑课程与心灵空间标签的绑定关系"); + } + this.removeById(id); + return R.ok(); + } + + + @Override + public R editCoursePsyche(CoursePsyche coursePsyche) { + CoursePsyche old = this.getById(coursePsyche.getId()); + + if(old.getIsLast()==0&&coursePsyche.getIsLast()==1){ + CoursePsyche one = this.getOne(new LambdaQueryWrapper().eq(CoursePsyche::getPid, coursePsyche.getId())); + if(one!=null){ + return R.error(501,"更新失败,请先清空此项的下级标签,才能将此标签变成终极标签"); + } + } + if(old.getIsLast()==1&&coursePsyche.getIsLast()==0){ + CourseToPsyche courseToPsyche = courseToPsycheDao.selectOne(new LambdaQueryWrapper().eq(CourseToPsyche::getPsycheId, coursePsyche.getId())); + if(courseToPsyche!=null){ + return R.error(502,"更新失败,请先把此项与课程的关联关系清空后才可把此标签变成普通标签"); + } + } + this.updateById(coursePsyche); + return R.ok().put("Psyche",coursePsyche); + } + + private List Psyches(int id){ + List list = this.list(new LambdaQueryWrapper() + .eq(CoursePsyche::getPid, id).orderByAsc(CoursePsyche::getSort)); + for (CoursePsyche c : list){ + if(c.getIsLast()!=1){ + List so = this.Psyches(c.getId()); + c.setChildren(so); + } + } + return list; + } + + } \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/CourseToPsycheMarketServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CourseToPsycheMarketServiceImpl.java index a4c52246..6b2ebc6b 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/CourseToPsycheMarketServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/CourseToPsycheMarketServiceImpl.java @@ -1,13 +1,34 @@ package com.peanut.modules.common.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.peanut.modules.common.dao.CourseDao; +import com.peanut.modules.common.dao.CoursePsycheMarketDao; import com.peanut.modules.common.dao.CourseToPsycheMarketDao; import com.peanut.modules.common.entity.CourseToPsycheMarket; import com.peanut.modules.common.service.CourseToPsycheMarketService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; @Slf4j @Service("commonCourseToPsycheMarketService") public class CourseToPsycheMarketServiceImpl extends ServiceImpl implements CourseToPsycheMarketService { + @Autowired + private CoursePsycheMarketDao coursePsycheMarketDao; + @Autowired + private CourseDao courseDao; + + @Override + public List getCourseListByMarketId(int marketId) { + List courseToPsycheMarketEntities = this.getBaseMapper().selectList(new LambdaQueryWrapper() + .eq(CourseToPsycheMarket::getPsycheMarketId, marketId) + .orderByAsc(CourseToPsycheMarket::getSort)); + for (CourseToPsycheMarket c : courseToPsycheMarketEntities){ + c.setCoursePsycheMarket(coursePsycheMarketDao.selectById(c.getPsycheMarketId())); + c.setCourseEntity(courseDao.selectById(c.getCourseId())); + } + return courseToPsycheMarketEntities; + } } \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/CourseToPsycheServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/CourseToPsycheServiceImpl.java index a5380864..d592b5ec 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/CourseToPsycheServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/CourseToPsycheServiceImpl.java @@ -1,6 +1,8 @@ package com.peanut.modules.common.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.CourseToPsycheDao; import com.peanut.modules.common.entity.CourseToPsyche; import com.peanut.modules.common.service.CourseToPsycheService; @@ -10,4 +12,14 @@ import org.springframework.stereotype.Service; @Slf4j @Service("commonCourseToPsycheService") public class CourseToPsycheServiceImpl extends ServiceImpl implements CourseToPsycheService { + @Override + public R bindCourseAndPsyche(CourseToPsyche toPsyche) { + //去重 + CourseToPsyche one = this.getOne(new LambdaQueryWrapper().eq(CourseToPsyche::getCourseId, toPsyche.getCourseId()).eq(CourseToPsyche::getPsycheId, toPsyche.getPsycheId())); + if(one != null){ + return R.error(501,"绑定失败,绑定关系已将存在"); + } + this.save(toPsyche); + return R.ok(); + } } \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/ShopProductPsycheLabelServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/ShopProductPsycheLabelServiceImpl.java index 9e9b84cf..88e83c2c 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/ShopProductPsycheLabelServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/ShopProductPsycheLabelServiceImpl.java @@ -1,13 +1,48 @@ package com.peanut.modules.common.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.peanut.modules.common.dao.ShopProductPsycheLabelDao; import com.peanut.modules.common.entity.ShopProductPsycheLabel; import com.peanut.modules.common.service.ShopProductPsycheLabelService; 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("commonShopProductPsycheLabelService") public class ShopProductPsycheLabelServiceImpl extends ServiceImpl implements ShopProductPsycheLabelService { + + @Autowired + private ShopProductPsycheLabelDao labelDao; + + @Override + public List labelTree() { + List labels = labelDao.selectList(new QueryWrapper<>()); + List labelsTree = labels.stream().filter((shopProductPsycheLabel) -> + shopProductPsycheLabel.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 getLabelChildrens(ShopProductPsycheLabel root,List all){ + List children = all.stream().filter(shopProductPsycheLabel -> { + return root.getId().equals(shopProductPsycheLabel.getPid()); + }).map(shopProductPsycheLabel -> { + shopProductPsycheLabel.setChildren(getLabelChildrens(shopProductPsycheLabel, all)); + return shopProductPsycheLabel; + }).sorted((label1,label2)->{ + return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort()); + }).collect(Collectors.toList()); + return children; + } + } \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/ShopProductPsycheMarketServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/ShopProductPsycheMarketServiceImpl.java index 24db639c..1fa44db4 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/ShopProductPsycheMarketServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/ShopProductPsycheMarketServiceImpl.java @@ -1,13 +1,48 @@ package com.peanut.modules.common.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.peanut.modules.common.dao.ShopProductPsycheMarketDao; import com.peanut.modules.common.entity.ShopProductPsycheMarket; import com.peanut.modules.common.service.ShopProductPsycheMarketService; 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("commonShopProductPsycheMarketService") public class ShopProductPsycheMarketServiceImpl extends ServiceImpl implements ShopProductPsycheMarketService { + + @Autowired + private ShopProductPsycheMarketDao marketDao; + + @Override + public List marketTree() { + List markets = marketDao.selectList(new QueryWrapper<>()); + List marketsTree = markets.stream().filter((shopProductPsycheMarket) -> + shopProductPsycheMarket.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 getMarketChildrens(ShopProductPsycheMarket root,List all){ + List children = all.stream().filter(shopProductPsycheMarket -> { + return root.getId().equals(shopProductPsycheMarket.getPid()); + }).map(shopProductPsycheMarket -> { + shopProductPsycheMarket.setChildren(getMarketChildrens(shopProductPsycheMarket, all)); + return shopProductPsycheMarket; + }).sorted((sort1,sort2)->{ + return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort()); + }).collect(Collectors.toList()); + return children; + } + } \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/common/service/impl/ShopProductToPsycheMarketServiceImpl.java b/src/main/java/com/peanut/modules/common/service/impl/ShopProductToPsycheMarketServiceImpl.java index 6a93eb55..3681a63d 100644 --- a/src/main/java/com/peanut/modules/common/service/impl/ShopProductToPsycheMarketServiceImpl.java +++ b/src/main/java/com/peanut/modules/common/service/impl/ShopProductToPsycheMarketServiceImpl.java @@ -7,7 +7,15 @@ import com.peanut.modules.common.service.ShopProductToPsycheMarketService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.Map; + @Slf4j @Service("commonShopProductToPsycheMarketService") public class ShopProductToPsycheMarketServiceImpl extends ServiceImpl implements ShopProductToPsycheMarketService { + @Override + public void editToMarketSort(Map map) { + ShopProductToPsycheMarket info = this.getById(map.get("id")); + info.setSort(map.get("sort")); + this.updateById(info); + } } \ No newline at end of file diff --git a/src/main/java/com/peanut/modules/master/controller/CoursePsycheController.java b/src/main/java/com/peanut/modules/master/controller/CoursePsycheController.java new file mode 100644 index 00000000..db231629 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/controller/CoursePsycheController.java @@ -0,0 +1,88 @@ +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.CoursePsyche; +import com.peanut.modules.common.entity.CourseToPsyche; +import com.peanut.modules.common.service.CoursePsycheService; +import com.peanut.modules.common.service.CourseToPsycheService; +import com.peanut.modules.common.to.ParamTo; +import com.peanut.modules.master.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("masterCoursePsyche") +@RequestMapping("master/coursePsyche") +public class CoursePsycheController { + @Autowired + private CoursePsycheService coursePsycheService; + @Autowired + private CourseToPsycheService courseToPsycheService; + @Autowired + private CourseService courseService; + + @RequestMapping("/getCoursePsycheList") + public R getCoursePsycheList(){ + List coursePsycheList = coursePsycheService.getCoursePsycheList(); + return R.ok().put("Psyches",coursePsycheList); + } + + @RequestMapping("/addCoursePsyche") + public R addCoursePsyche(@RequestBody CoursePsyche coursePsyche){ + coursePsycheService.save(coursePsyche); + return R.ok().put("Psyche",coursePsyche); + } + + @RequestMapping("/delCoursePsyche") + public R delCoursePsyche(@RequestBody ParamTo param){ + return coursePsycheService.delCoursePsyche(param.getId()); + } + + @RequestMapping("/editCoursePsyche") + public R editCoursePsyche(@RequestBody CoursePsyche coursePsyche){ + return coursePsycheService.editCoursePsyche(coursePsyche); + } + + @RequestMapping("/getCourseListForPsyche") + public R getCourseListForPsyche(@RequestBody ParamTo param){ + List courseListForPsyche = courseService.getCourseListForPsyche(param.getId()); + return R.ok().put("courseList",courseListForPsyche); + } + + @RequestMapping("/getCourseListCanPsyche") + public R getCourseListCanPsyche(@RequestBody ParamTo param){ + Page courseListCanPsyche = courseService.getCourseListCanPsyche(param); + return R.ok().put("page",courseListCanPsyche); + } + + @RequestMapping("/bindCourseAndPsyche") + public R bindCourseAndPsyche(@RequestBody CourseToPsyche courseToPsyche){ + return courseToPsycheService.bindCourseAndPsyche(courseToPsyche); + } + + @RequestMapping("/unbindCourseAndPsyche") + public R unbindCourseAndPsyche(@RequestBody CourseToPsyche courseToPsyche){ + boolean b = courseToPsycheService.removeById(courseToPsyche.getId()); + if(b){ + return R.ok(); + }else { + return R.error("error"); + } + } + + @RequestMapping("/updateCourseToPsycheSort") + public R updateCourseToPsycheSort(@RequestBody CourseToPsyche courseToPsyche){ + courseToPsycheService.updateById(courseToPsyche); + return R.ok(); + } + + + +} diff --git a/src/main/java/com/peanut/modules/master/controller/CoursePsycheMarketController.java b/src/main/java/com/peanut/modules/master/controller/CoursePsycheMarketController.java new file mode 100644 index 00000000..0b548f44 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/controller/CoursePsycheMarketController.java @@ -0,0 +1,153 @@ +package com.peanut.modules.master.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.CourseEntity; +import com.peanut.modules.common.entity.CoursePsycheMarket; +import com.peanut.modules.common.entity.CourseToPsycheMarket; +import com.peanut.modules.common.service.CoursePsycheMarketService; +import com.peanut.modules.common.service.CourseToPsycheMarketService; +import com.peanut.modules.common.to.ParamTo; +import com.peanut.modules.master.service.CourseService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +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; +import java.util.stream.Collectors; + +@Slf4j +@RestController("masterCoursePsycheMarket") +@RequestMapping("master/coursePsycheMarket") +public class CoursePsycheMarketController { + + @Autowired + private CoursePsycheMarketService marketService; + @Autowired + private CourseToPsycheMarketService toMarketService; + @Autowired + private CourseService courseService; + + /** + * 营销标签树 + */ + @RequestMapping(path = "/marketTree") + public R marketTree() { + List coursePsycheMarketEntities = marketService.marketTree(); + return R.ok().put("result", coursePsycheMarketEntities); + } + + @RequestMapping(path = "/getMarketById") + public R getMarketById(@RequestBody Map map) { + int id = map.get("id"); + return R.ok().put("result",marketService.getById(id)); + } + + @RequestMapping("/addPsycheMarket") + public R addPsycheMarket(@RequestBody CoursePsycheMarket coursePsycheMarket){ + marketService.save(coursePsycheMarket); + return R.ok().put("market",coursePsycheMarket); + } + + @RequestMapping("/editPsycheMarket") + public R editPsycheMarket(@RequestBody CoursePsycheMarket coursePsycheMarket){ + CoursePsycheMarket old = marketService.getById(coursePsycheMarket.getId()); + if(coursePsycheMarket.getIsLast()==1&&old.getIsLast()==0){//非终节点到终结点,要排除是否存在子集 + Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CoursePsycheMarket::getPid, coursePsycheMarket.getId())); + if(integer>0){ + return R.error("请先清空子集再操作!"); + } + } + + if(coursePsycheMarket.getIsLast()==0&&old.getIsLast()==1){ + Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToPsycheMarket::getPsycheMarketId, coursePsycheMarket.getId())); + if(integer>0){ + return R.error("请先清空绑定的课程后,再操作"); + } + } + marketService.updateById(coursePsycheMarket); + return R.ok().put("market",coursePsycheMarket); + } + + @RequestMapping(path = "/delMarket") + public R delMarket(@RequestBody Map map) { + int id = map.get("id"); + CoursePsycheMarket market = marketService.getById(id); + if (market.getIsLast()==1){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.eq(CourseToPsycheMarket::getPsycheMarketId,id); + List tomarkets = toMarketService.list(wrapper); + if (tomarkets.size()>0){ + return R.error("请先移除课程"); + }else { + marketService.removeById(id); + return R.ok(); + } + }else { + List marketList = marketService.list(new LambdaQueryWrapper().eq(CoursePsycheMarket::getPid,id)); + if (marketList.size() > 0) { + return R.error("请先删除子集"); + }else { + marketService.removeById(id); + return R.ok(); + } + } + } + + @RequestMapping("/editMarketSort") + public R editMarketSort(@RequestBody Map map){ + CourseToPsycheMarket info = toMarketService.getOne(new LambdaQueryWrapper() + .eq(CourseToPsycheMarket::getPsycheMarketId, map.get("marketId")) + .eq(CourseToPsycheMarket::getCourseId, map.get("courseId")), false); + info.setSort(map.get("sort")); + toMarketService.updateById(info); + return R.ok().put("result",info); + } + + @RequestMapping("/getCourseListByMarketId") + public R getCourseListByMarketId(@RequestBody Map map){ + List marketId = toMarketService.getCourseListByMarketId(map.get("marketId")); + return R.ok().put("list",marketId); + } + + @RequestMapping("/getNotToMarketList") + public R getNotToMarketList(@RequestBody ParamTo param){ + List collect = toMarketService.getBaseMapper().selectList(new LambdaQueryWrapper().eq(CourseToPsycheMarket::getPsycheMarketId, param.getId())).stream().map(CourseToPsycheMarket::getCourseId).collect(Collectors.toList()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.notIn(collect.size()>0,CourseEntity::getId,collect); + wrapper.like(StringUtils.isNotBlank(param.getKeywords()),CourseEntity::getTitle,param.getKeywords()); + Page page = courseService.page(new Page<>(param.getPage(), param.getLimit()), wrapper); + return R.ok().put("page",page); + } + + @RequestMapping("/bindCourseAndPsycheMarket") + public R bindCourseAndPsycheMarket(@RequestBody Map map){ + int marketId = map.get("marketId"); + int courseId = map.get("courseId"); + Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper().eq(CourseToPsycheMarket::getPsycheMarketId, marketId).eq(CourseToPsycheMarket::getCourseId, courseId)); + if(integer>0){ + return R.error("不可重复绑定"); + } + CourseToPsycheMarket courseToPsycheMarket = new CourseToPsycheMarket(); + courseToPsycheMarket.setPsycheMarketId(marketId); + courseToPsycheMarket.setCourseId(courseId); + toMarketService.save(courseToPsycheMarket); + return R.ok(); + } + + @RequestMapping("/unbindCourseAndPsycheMarket") + public R unbindCourseAndPsycheMarket(@RequestBody Map map){ + int marketId = map.get("marketId"); + int courseId = map.get("courseId"); + toMarketService.getBaseMapper().delete(new LambdaQueryWrapper().eq(CourseToPsycheMarket::getPsycheMarketId,marketId).eq(CourseToPsycheMarket::getCourseId,courseId)); + return R.ok(); + } + + + +} diff --git a/src/main/java/com/peanut/modules/master/controller/MessageController.java b/src/main/java/com/peanut/modules/master/controller/MessageController.java index 60c4c2e6..dbe26102 100644 --- a/src/main/java/com/peanut/modules/master/controller/MessageController.java +++ b/src/main/java/com/peanut/modules/master/controller/MessageController.java @@ -35,10 +35,12 @@ public class MessageController { } if (StringUtils.isNotEmpty(params.get("isBook").toString())|| StringUtils.isNotEmpty(params.get("isMedical").toString())|| - StringUtils.isNotEmpty(params.get("isSociology").toString())) { + StringUtils.isNotEmpty(params.get("isSociology").toString())|| + StringUtils.isNotEmpty(params.get("isPsyche").toString())) { wrapper.and(t->t.eq("1".equals(params.get("isBook").toString()),Message::getIsBook,params.get("isBook")) .or().eq("1".equals(params.get("isMedical").toString()),Message::getIsMedical,params.get("isMedical")) - .or().eq("1".equals(params.get("isSociology").toString()),Message::getIsSociology,params.get("isSociology"))); + .or().eq("1".equals(params.get("isSociology").toString()),Message::getIsSociology,params.get("isSociology")) + .or().eq("1".equals(params.get("isPsyche").toString()),Message::getIsPsyche,params.get("isPsyche"))); } wrapper.orderByDesc(Message::getCreateTime); Page page = messageService.page(new Page<>( diff --git a/src/main/java/com/peanut/modules/master/controller/PsycheLabelAndMarketController.java b/src/main/java/com/peanut/modules/master/controller/PsycheLabelAndMarketController.java new file mode 100644 index 00000000..145a3ef2 --- /dev/null +++ b/src/main/java/com/peanut/modules/master/controller/PsycheLabelAndMarketController.java @@ -0,0 +1,371 @@ +package com.peanut.modules.master.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.common.service.ShopProductPsycheLabelService; +import com.peanut.modules.common.service.ShopProductPsycheMarketService; +import com.peanut.modules.common.service.ShopProductToPsycheLabelService; +import com.peanut.modules.common.service.ShopProductToPsycheMarketService; +import com.peanut.modules.master.service.ShopProductService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +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("masterPsycheLabelAndMarket") +@RequestMapping("master/psycheLabelAndMarket") +public class PsycheLabelAndMarketController { + + @Autowired + private ShopProductPsycheLabelService labelService; + @Autowired + private ShopProductPsycheMarketService marketService; + @Autowired + private ShopProductToPsycheLabelService toLabelService; + @Autowired + private ShopProductToPsycheMarketService toMarketService; + @Autowired + private ShopProductService productService; + + /** + * 标签树 + */ + @RequestMapping(path = "/labelTree") + public R labelTree() { + List labelsTree = labelService.labelTree(); + return R.ok().put("result", labelsTree); + } + + /** + * 获取标签列表 + */ + @RequestMapping(path = "/getLabelListByPid") + public R getLabelListByPid(String pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(ShopProductPsycheLabel::getPid,pid); + wrapper.orderByAsc(ShopProductPsycheLabel::getSort); + wrapper.orderByAsc(ShopProductPsycheLabel::getCreateTime); + List labelTopList = labelService.list(wrapper); + return R.ok().put("result", labelTopList); + } + + + /** + * 营销标签树 + */ + @RequestMapping(path = "/marketTree") + public R marketTree() { + List marketsTree = marketService.marketTree(); + return R.ok().put("result", marketsTree); + } + + /** + * 获取营销标签列表 + */ + @RequestMapping(path = "/getMakertListByPid") + public R getMakertListByPid(String pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(ShopProductPsycheMarket::getPid,pid); + wrapper.orderByAsc(ShopProductPsycheMarket::getSort); + wrapper.orderByAsc(ShopProductPsycheMarket::getCreateTime); + List marketTopList = marketService.list(wrapper); + return R.ok().put("result", marketTopList); + } + + @RequestMapping(path = "/getLabelById") + public R getLabelById(String id) { + return R.ok().put("result",labelService.getById(id)); + } + + @RequestMapping(path = "/saveOrUpdateLabel") + public R saveOrUpdateLabel(@RequestBody ShopProductPsycheLabel label) { + if (label.getId()==null){ + if(label.getPid()==0){ + labelService.save(label); + return R.ok().put("result",label); + }else { + ShopProductPsycheLabel l = labelService.getById(label.getPid()); + if (l.getIsLast()==1){ + return R.error("请将父标签设置为非最后一集"); + }else { + labelService.save(label); + return R.ok().put("result",label); + } + } + }else { + if (label.getIsLast() == 1){ + List llast = labelService.list(new LambdaQueryWrapper() + .eq(ShopProductPsycheLabel::getPid,label.getId())); + if (llast.size()>0){ + return R.error("请先删除子集,再设置为最后一集"); + }else { + labelService.saveOrUpdate(label); + return R.ok().put("result",label); + } + }else { + labelService.saveOrUpdate(label); + return R.ok().put("result",label); + } + } + } + + @RequestMapping(path = "/delLabel") + public R delLabel(String id) { + ShopProductPsycheLabel label = labelService.getById(id); + if (label.getIsLast()==1){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.eq(ShopProductToPsycheLabel::getPsycheLabelId,id); + List tolables = toLabelService.list(wrapper); + if (tolables.size()>0){ + return R.error("请先移除商品"); + }else { + labelService.removeById(id); + return R.ok(); + } + }else { + List labelList = labelService.list(new LambdaQueryWrapper().eq(ShopProductPsycheLabel::getPid,id)); + if (labelList.size() > 0) { + return R.error("请先删除子集"); + }else { + labelService.removeById(id); + return R.ok(); + } + } + } + + @RequestMapping(path = "/getMarketById") + public R getMarketById(String id) { + return R.ok().put("result",marketService.getById(id)); + } + + @RequestMapping(path = "/saveOrUpdateMarket") + public R saveOrUpdateMarket(@RequestBody ShopProductPsycheMarket market) { + if (market.getId()==null){ + if(market.getPid()==0){ + marketService.save(market); + return R.ok().put("result",market); + }else { + ShopProductPsycheMarket m = marketService.getById(market.getPid()); + if (m.getIsLast()==1){ + return R.error("请将父标签设置为非最后一集"); + }else { + marketService.save(market); + return R.ok().put("result",market); + } + } + }else { + if (market.getIsLast() == 1){ + List mList = marketService.list(new LambdaQueryWrapper() + .eq(ShopProductPsycheMarket::getPid,market.getId())); + if (mList.size()>0){ + return R.error("请先删除子集,再设置为最后一集"); + }else { + marketService.saveOrUpdate(market); + return R.ok().put("result",market); + } + }else { + marketService.saveOrUpdate(market); + return R.ok().put("result",market); + } + } + } + + @RequestMapping(path = "/delMarket") + public R delMarket(String id) { + ShopProductPsycheMarket market = marketService.getById(id); + if (market.getIsLast()==1){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.eq(ShopProductToPsycheMarket::getPsycheMarketId,id); + List tomarkets = toMarketService.list(wrapper); + if (tomarkets.size()>0){ + return R.error("请先移除商品"); + }else { + marketService.removeById(id); + return R.ok(); + } + }else { + List marketList = marketService.list(new LambdaQueryWrapper().eq(ShopProductPsycheMarket::getPid,id)); + if (marketList.size() > 0) { + return R.error("请先删除子集"); + }else { + marketService.removeById(id); + return R.ok(); + } + } + } + + /** + * 获取未关联商品列表 + */ + @RequestMapping("/getNotToLabelList") + public R getNotToLabelList(@RequestBody Map params){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){ + wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString()); + } + if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){ + wrapper.like(ShopProduct::getProductName,params.get("productName").toString()); + } + if (params.containsKey("psycheLabelId")&&!"".equals(params.get("psycheLabelId").toString())){ + String sql = "select product_id from shop_product_to_psyche_label where del_flag = 0 and psyche_label_id = "+params.get("psycheLabelId"); + wrapper.notInSql(ShopProduct::getProductId,sql); + } + if (params.containsKey("psycheMarketId")&&!"".equals(params.get("psycheMarketId").toString())){ + String sql = "select product_id from shop_product_to_psyche_market where del_flag = 0 and psyche_market_id = "+params.get("psycheMarketId"); + wrapper.notInSql(ShopProduct::getProductId,sql); + } + Page page = productService.page(new Page<>( + Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper); + return R.ok().put("result", page); + } + + @RequestMapping("/editMarketSort") + public R editMarketSort(@RequestBody Map map){ + ShopProductToPsycheMarket toMarket = toMarketService.getById(map.get("id")); + toMarket.setSort(map.get("sort")); + toMarketService.updateById(toMarket); + return R.ok().put("market",toMarket); + } + + /** + * 获取书标签列表 + */ + @RequestMapping("/getToLabelList") + public R getToLabelList(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.selectAll(ShopProductToPsycheLabel.class); + wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToPsycheLabel::getProductId); + if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){ + wrapper.like(ShopProduct::getProductName,params.get("productName").toString()); + } + if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){ + wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString()); + } + if (params.containsKey("productId")&&!"".equals(params.get("productId").toString())){ + wrapper.eq(ShopProductToPsycheLabel::getProductId,params.get("productId").toString()); + } + if (params.containsKey("psycheLabelId")&&!"".equals(params.get("psycheLabelId").toString())){ + wrapper.eq(ShopProductToPsycheLabel::getPsycheLabelId,params.get("psycheLabelId").toString()); + } + Page page = toLabelService.page(new Page<>( + Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper); + List res = page.getRecords(); + if (res.size() > 0) { + for (ShopProductToPsycheLabel item : res) { + item.setProduct(productService.getById(item.getProductId())); + item.setLabel(labelService.getById(item.getPsycheLabelId())); + } + } + page.setRecords(res); + return R.ok().put("result", page); + } + + /** + * 获取营销标签列表 + */ + @RequestMapping("/getToMarketList") + public R getToMarketList(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.selectAll(ShopProductToPsycheMarket.class); + wrapper.leftJoin(ShopProduct.class,ShopProduct::getProductId,ShopProductToPsycheMarket::getProductId); + if (params.containsKey("productName")&&!"".equals(params.get("productName").toString())){ + wrapper.like(ShopProduct::getProductName,params.get("productName").toString()); + } + if (params.containsKey("goodsType")&&!"".equals(params.get("goodsType").toString())){ + wrapper.eq(ShopProduct::getGoodsType,params.get("goodsType").toString()); + } + if (params.containsKey("productId")&&!"".equals(params.get("productId").toString())){ + wrapper.eq(ShopProductToBookMarket::getProductId,params.get("productId").toString()); + } + if (params.containsKey("psycheMarketId")&&!"".equals(params.get("psycheMarketId").toString())){ + wrapper.eq(ShopProductToPsycheMarket::getPsycheMarketId,params.get("psycheMarketId").toString()); + } + wrapper.orderByAsc(ShopProductToPsycheMarket::getSort); + Page page = toMarketService.page(new Page<>( + Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper); + List res = page.getRecords(); + if (res.size() > 0) { + for (ShopProductToPsycheMarket item : res) { + item.setProduct(productService.getById(item.getProductId())); + item.setMarket(marketService.getById(item.getPsycheMarketId())); + } + } + page.setRecords(res); + return R.ok().put("result", page); + } + + @RequestMapping("/editToMarketSort") + public R editToMarketSort(@RequestBody Map map){ + toMarketService.editToMarketSort(map); + return R.ok(); + } + + @RequestMapping(path = "/saveToLabel") + public R saveToLabel(@RequestBody Map params) { + if (!StringUtils.isEmpty(params.get("productId").toString())){ + String[] ids = params.get("productId").toString().split(","); + if (ids.length > 0) { + for (String id : ids) { + ShopProductToPsycheLabel toLabel = new ShopProductToPsycheLabel(); + toLabel.setPsycheLabelId(Integer.parseInt(params.get("psycheLabelId").toString())); + toLabel.setProductId(Integer.parseInt(id)); + toLabelService.save(toLabel); + } + } + } + return R.ok(); + } + + @RequestMapping(path = "/saveToMarket") + public R saveToMarket(@RequestBody Map params) { + if (!StringUtils.isEmpty(params.get("productId").toString())){ + String[] ids = params.get("productId").toString().split(","); + if (ids.length > 0) { + for (String id : ids) { + ShopProductToPsycheMarket toMarket = new ShopProductToPsycheMarket(); + toMarket.setPsycheMarketId(Integer.parseInt(params.get("psycheMarketId").toString())); + toMarket.setProductId(Integer.parseInt(id)); + toMarketService.save(toMarket); + } + } + } + return R.ok(); + } + + @RequestMapping(path = "/delToLable") + public R delToLable(String lableId,String productId) { + if(StringUtils.isNotEmpty(productId)){ + String[] productIds = productId.split(","); + for(String id : productIds){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(ShopProductToPsycheLabel::getPsycheLabelId,lableId); + wrapper.eq(ShopProductToPsycheLabel::getProductId,id); + toLabelService.remove(wrapper); + } + } + return R.ok(); + } + + @RequestMapping(path = "/delToMarket") + public R delToMarket(String marketId,String productId) { + if(StringUtils.isNotEmpty(productId)){ + String[] productIds = productId.split(","); + for(String id : productIds){ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper(); + wrapper.eq(ShopProductToPsycheMarket::getPsycheMarketId,marketId); + wrapper.eq(ShopProductToPsycheMarket::getProductId,id); + toMarketService.remove(wrapper); + } + } + return R.ok(); + } + +} diff --git a/src/main/java/com/peanut/modules/master/service/CourseService.java b/src/main/java/com/peanut/modules/master/service/CourseService.java index 0c9f67aa..dd5c4894 100644 --- a/src/main/java/com/peanut/modules/master/service/CourseService.java +++ b/src/main/java/com/peanut/modules/master/service/CourseService.java @@ -23,6 +23,10 @@ public interface CourseService extends IService { Page getCourseListCanMedical(ParamTo param); + List getCourseListForPsyche(int medicalId); + + Page getCourseListCanPsyche(ParamTo param); + void testCourse(); List courseAndChildrenList(Map params); diff --git a/src/main/java/com/peanut/modules/master/service/impl/CourseServiceImpl.java b/src/main/java/com/peanut/modules/master/service/impl/CourseServiceImpl.java index abb2c330..db3c3c20 100644 --- a/src/main/java/com/peanut/modules/master/service/impl/CourseServiceImpl.java +++ b/src/main/java/com/peanut/modules/master/service/impl/CourseServiceImpl.java @@ -34,6 +34,10 @@ public class CourseServiceImpl extends ServiceImpl impl @Autowired private CourseToMedicineDao toMedicalDao; @Autowired + private CoursePsycheDao psycheDao; + @Autowired + private CourseToPsycheDao toPsycheDao; + @Autowired private CourseCatalogueDao courseCatalogueDao; @Autowired private CourseCatalogueChapterDao chapterDao; @@ -155,6 +159,33 @@ public class CourseServiceImpl extends ServiceImpl impl return page; } + @Override + public List getCourseListForPsyche(int psycheId) { + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.selectAll(CourseEntity.class); + wrapper.selectAs(CourseToPsyche::getId,"bindId"); + wrapper.selectAs(CourseToPsyche::getSort,"toSociologySort"); + wrapper.selectAs(CourseToPsyche::getLevel,"level"); + wrapper.selectAs(CourseToPsyche::getSelective,"selective"); + wrapper.leftJoin(CourseEntity.class,CourseEntity::getId, CourseToPsyche::getCourseId); + wrapper.eq(CourseToPsyche::getPsycheId,psycheId); + wrapper.orderByAsc(CourseToPsyche::getSort); + List courseEntities = toPsycheDao.selectJoinList(CourseEntity.class, wrapper); + return courseEntities; + } + + @Override + public Page getCourseListCanPsyche(ParamTo param) { + List collect = toPsycheDao.selectList(new LambdaQueryWrapper().eq(CourseToPsyche::getPsycheId, param.getId())).stream().map(CourseToPsyche::getCourseId).collect(Collectors.toList()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (collect.size() != 0){ + wrapper.notIn(CourseEntity::getId,collect); + } + wrapper.like(StringUtils.isNotBlank(param.getKeywords()),CourseEntity::getTitle,param.getKeywords()); + Page page = this.page(new Page<>(param.getPage(), param.getLimit()), wrapper); + return page; + } + @Override public void testCourse() { diff --git a/src/main/java/com/peanut/modules/psyche/controller/PsycheHomeController.java b/src/main/java/com/peanut/modules/psyche/controller/PsycheHomeController.java new file mode 100644 index 00000000..1589c726 --- /dev/null +++ b/src/main/java/com/peanut/modules/psyche/controller/PsycheHomeController.java @@ -0,0 +1,53 @@ +package com.peanut.modules.psyche.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.CourseEntity; +import com.peanut.modules.common.entity.CoursePsyche; +import com.peanut.modules.common.entity.CourseToPsyche; +import com.peanut.modules.common.service.CoursePsycheService; +import com.peanut.modules.master.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; +import java.util.Map; + +@Slf4j +@RestController("psycheHome") +@RequestMapping("psyche/home") +public class PsycheHomeController { + + @Autowired + private CoursePsycheService coursePsycheService; + @Autowired + private CourseService courseService; + + //获取标签列表 + @RequestMapping("/getPsycheLabels") + public R getPsycheLabels(@RequestBody Map params){ + List psycheLabels = coursePsycheService.list(new LambdaQueryWrapper() + .eq(CoursePsyche::getPid,params.get("id")) + .orderByAsc(CoursePsyche::getSort)); + return R.ok().put("labels",psycheLabels); + } + + //获取标签下的课程列表 + @RequestMapping("/getPsycheCourseList") + public R getPsycheCourseList(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.selectAll(CourseEntity.class); + wrapper.leftJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId); + wrapper.eq(CourseToPsyche::getPsycheId,params.get("id")); + wrapper.orderByAsc(CourseToPsyche::getSort); + Page courseEntityPage = courseService.page(new Page<>( + Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper); + return R.ok().put("courses",courseEntityPage); + } + + +} diff --git a/src/main/java/com/peanut/modules/sys/controller/VisitorController.java b/src/main/java/com/peanut/modules/sys/controller/VisitorController.java index 11cff89e..c55a4ace 100644 --- a/src/main/java/com/peanut/modules/sys/controller/VisitorController.java +++ b/src/main/java/com/peanut/modules/sys/controller/VisitorController.java @@ -9,6 +9,7 @@ import com.peanut.common.utils.R; import com.peanut.modules.common.dao.ShopProductToLabelDao; import com.peanut.modules.book.service.*; import com.peanut.modules.common.entity.*; +import com.peanut.modules.common.service.CoursePsycheService; import com.peanut.modules.common.service.MessageService; import com.peanut.modules.common.to.ParamTo; import com.peanut.modules.medical.service.CourseMedicalService; @@ -18,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.*; +import java.util.stream.Collectors; @Slf4j @RestController @@ -58,6 +60,8 @@ public class VisitorController { private MessageService messageService; @Autowired private com.peanut.modules.sociology.service.ShopProductService medicineShopProductService; + @Autowired + private CoursePsycheService coursePsycheService; //新书 @RequestMapping("/getNewBook") @@ -223,6 +227,7 @@ public class VisitorController { wrapper.eq(message.getIsBook()==1,Message::getIsBook,1); wrapper.eq(message.getIsMedical()==1,Message::getIsMedical,1); wrapper.eq(message.getIsSociology()==1,Message::getIsSociology,1); + wrapper.eq(message.getIsPsyche()==1,Message::getIsPsyche,1); wrapper.orderByDesc(Message::getCreateTime); List messages = messageService.getBaseMapper().selectList(wrapper); return R.ok().put("messages", messages); @@ -262,4 +267,38 @@ public class VisitorController { Page marketCourseList = sociologyCourseService.getMarketCourseList(param); return R.ok().put("courseList",marketCourseList); } + + //获取心灵空间标签树 + @RequestMapping("/getCoursePsycheTree") + public R getCoursePsycheTree(){ + List psychesTree = coursePsycheService.getCoursePsycheTree(); + return R.ok().put("labels",psychesTree); + } + /** + * 心灵空间营销标签下商品列表 + */ + @RequestMapping("/getPsycheMarketShopProductList") + public R getPsycheMarketShopProductList(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper(); + wrapper.selectAll(ShopProduct.class); + wrapper.rightJoin(ShopProductToPsycheMarket.class,ShopProductToPsycheMarket::getProductId,ShopProduct::getProductId); + if (params.containsKey("psycheMarketId")&&!"".equals(params.get("psycheMarketId").toString())){ + wrapper.eq(ShopProductToPsycheMarket::getPsycheMarketId,params.get("psycheMarketId").toString()); + } + Page page = productService.page(new Page<>( + Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper); + return R.ok().put("result", page); + } + //心灵空间营销标签下的课程列表 + @RequestMapping("/getPsycheMarketCourseList") + public R getPsycheMarketCourseList(@RequestBody Map params){ + MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); + wrapper.selectAll(CourseEntity.class); + wrapper.leftJoin(CourseToPsycheMarket.class, CourseToPsycheMarket::getCourseId,CourseEntity::getId); + wrapper.eq(CourseToPsycheMarket::getPsycheMarketId,params.get("id")); + wrapper.orderByAsc(CourseToPsyche::getSort); + Page courseEntityPage = courseService.page(new Page<>( + Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper); + return R.ok().put("courseList",courseEntityPage); + } } diff --git a/src/main/java/com/peanut/modules/sys/entity/SysUserTokenEntity.java b/src/main/java/com/peanut/modules/sys/entity/SysUserTokenEntity.java index 1ef2aaff..7f2d7bb0 100644 --- a/src/main/java/com/peanut/modules/sys/entity/SysUserTokenEntity.java +++ b/src/main/java/com/peanut/modules/sys/entity/SysUserTokenEntity.java @@ -44,5 +44,9 @@ public class SysUserTokenEntity implements Serializable { private String tokenSociology; //更新时间 private Date sociologyUpdateTime; + //token + private String tokenPsyche; + //更新时间 + private Date psycheUpdateTime; } diff --git a/src/main/java/com/peanut/modules/sys/oauth2/OAuth2Realm.java b/src/main/java/com/peanut/modules/sys/oauth2/OAuth2Realm.java index e1c78e98..da90bb67 100644 --- a/src/main/java/com/peanut/modules/sys/oauth2/OAuth2Realm.java +++ b/src/main/java/com/peanut/modules/sys/oauth2/OAuth2Realm.java @@ -95,6 +95,8 @@ public class OAuth2Realm extends AuthorizingRealm { tokenEntity.setMedicalUpdateTime(now); }else if ("sociology".equals(appType)){ tokenEntity.setSociologyUpdateTime(now); + }else if ("psyche".equals(appType)){ + tokenEntity.setPsycheUpdateTime(now); } sysUserTokenService.updateById(tokenEntity); } diff --git a/src/main/java/com/peanut/modules/sys/service/impl/SysUserTokenServiceImpl.java b/src/main/java/com/peanut/modules/sys/service/impl/SysUserTokenServiceImpl.java index 3465755c..4b47c5ee 100644 --- a/src/main/java/com/peanut/modules/sys/service/impl/SysUserTokenServiceImpl.java +++ b/src/main/java/com/peanut/modules/sys/service/impl/SysUserTokenServiceImpl.java @@ -53,6 +53,9 @@ public class SysUserTokenServiceImpl extends ServiceImpl \ No newline at end of file