心灵空间

This commit is contained in:
wuchunlei
2025-02-07 17:10:49 +08:00
parent d8e7c90c01
commit 26d08a5f8b
28 changed files with 1027 additions and 3 deletions

View File

@@ -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<CoursePsycheMarket> {
List<CoursePsycheMarket> marketTree();
}

View File

@@ -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<CoursePsyche> {
List<CoursePsyche> getCoursePsycheTree();
List<CoursePsyche> getCoursePsycheList();
R delCoursePsyche(int id);
R editCoursePsyche(CoursePsyche coursePsyche);
}

View File

@@ -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<CourseToPsycheMarket> {
List<CourseToPsycheMarket> getCourseListByMarketId(int marketId);
}

View File

@@ -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<CourseToPsyche> {
R bindCourseAndPsyche(CourseToPsyche toPsyche);
}

View File

@@ -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<ShopProductPsycheLabel> {
List<ShopProductPsycheLabel> labelTree();
}

View File

@@ -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<ShopProductPsycheMarket> {
List<ShopProductPsycheMarket> marketTree();
}

View File

@@ -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<ShopProductToPsycheMarket> {
void editToMarketSort(Map<String,Integer> map);
}

View File

@@ -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<CoursePsycheMarketDao, CoursePsycheMarket> implements CoursePsycheMarketService {
@Autowired
private CoursePsycheMarketDao marketDao;
@Override
public List<CoursePsycheMarket> marketTree() {
List<CoursePsycheMarket> markets = marketDao.selectList(new QueryWrapper<>());
List<CoursePsycheMarket> 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<CoursePsycheMarket> getMarketChildrens(CoursePsycheMarket root, List<CoursePsycheMarket> all){
List<CoursePsycheMarket> 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;
}
}

View File

@@ -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<CoursePsycheDao, CoursePsyche> implements CoursePsycheService {
@Autowired
private CourseToPsycheDao courseToPsycheDao;
@Override
public List<CoursePsyche> getCoursePsycheTree() {
List<CoursePsyche> psyches = this.list(new QueryWrapper<>());
List<CoursePsyche> 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<CoursePsyche> getPsycheChildrens(CoursePsyche root, List<CoursePsyche> all){
List<CoursePsyche> 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<CoursePsyche> getCoursePsycheList() {
return this.Psyches(0);
}
@Override
public R delCoursePsyche(int id) {
//查看下一级是否存在
int count = this.count(new LambdaQueryWrapper<CoursePsyche>().eq(CoursePsyche::getPid, id));
if(count>0){
return R.error(501,"删除失败,请先删除子项目后再尝试");
}
//查看绑定关系是否存在
Integer integer = courseToPsycheDao.selectCount(new LambdaQueryWrapper<CourseToPsyche>().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<CoursePsyche>().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<CourseToPsyche>().eq(CourseToPsyche::getPsycheId, coursePsyche.getId()));
if(courseToPsyche!=null){
return R.error(502,"更新失败,请先把此项与课程的关联关系清空后才可把此标签变成普通标签");
}
}
this.updateById(coursePsyche);
return R.ok().put("Psyche",coursePsyche);
}
private List<CoursePsyche> Psyches(int id){
List<CoursePsyche> list = this.list(new LambdaQueryWrapper<CoursePsyche>()
.eq(CoursePsyche::getPid, id).orderByAsc(CoursePsyche::getSort));
for (CoursePsyche c : list){
if(c.getIsLast()!=1){
List<CoursePsyche> so = this.Psyches(c.getId());
c.setChildren(so);
}
}
return list;
}
}

View File

@@ -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<CourseToPsycheMarketDao, CourseToPsycheMarket> implements CourseToPsycheMarketService {
@Autowired
private CoursePsycheMarketDao coursePsycheMarketDao;
@Autowired
private CourseDao courseDao;
@Override
public List<CourseToPsycheMarket> getCourseListByMarketId(int marketId) {
List<CourseToPsycheMarket> courseToPsycheMarketEntities = this.getBaseMapper().selectList(new LambdaQueryWrapper<CourseToPsycheMarket>()
.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;
}
}

View File

@@ -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<CourseToPsycheDao, CourseToPsyche> implements CourseToPsycheService {
@Override
public R bindCourseAndPsyche(CourseToPsyche toPsyche) {
//去重
CourseToPsyche one = this.getOne(new LambdaQueryWrapper<CourseToPsyche>().eq(CourseToPsyche::getCourseId, toPsyche.getCourseId()).eq(CourseToPsyche::getPsycheId, toPsyche.getPsycheId()));
if(one != null){
return R.error(501,"绑定失败,绑定关系已将存在");
}
this.save(toPsyche);
return R.ok();
}
}

View File

@@ -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<ShopProductPsycheLabelDao, ShopProductPsycheLabel> implements ShopProductPsycheLabelService {
@Autowired
private ShopProductPsycheLabelDao labelDao;
@Override
public List<ShopProductPsycheLabel> labelTree() {
List<ShopProductPsycheLabel> labels = labelDao.selectList(new QueryWrapper<>());
List<ShopProductPsycheLabel> 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<ShopProductPsycheLabel> getLabelChildrens(ShopProductPsycheLabel root,List<ShopProductPsycheLabel> all){
List<ShopProductPsycheLabel> 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;
}
}

View File

@@ -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<ShopProductPsycheMarketDao, ShopProductPsycheMarket> implements ShopProductPsycheMarketService {
@Autowired
private ShopProductPsycheMarketDao marketDao;
@Override
public List<ShopProductPsycheMarket> marketTree() {
List<ShopProductPsycheMarket> markets = marketDao.selectList(new QueryWrapper<>());
List<ShopProductPsycheMarket> 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<ShopProductPsycheMarket> getMarketChildrens(ShopProductPsycheMarket root,List<ShopProductPsycheMarket> all){
List<ShopProductPsycheMarket> 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;
}
}

View File

@@ -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<ShopProductToPsycheMarketDao, ShopProductToPsycheMarket> implements ShopProductToPsycheMarketService {
@Override
public void editToMarketSort(Map<String, Integer> map) {
ShopProductToPsycheMarket info = this.getById(map.get("id"));
info.setSort(map.get("sort"));
this.updateById(info);
}
}