心灵空间

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

@@ -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<Message> messages = messageService.getBaseMapper().selectList(wrapper);
return R.ok().put("messages", messages);

View File

@@ -50,6 +50,11 @@ public class Message {
*/
private Integer isSociology;
/**
* 是否在心灵空间显示0否1是
*/
private Integer isPsyche;
private Date createTime;
@TableLogic

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);
}
}

View File

@@ -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<CoursePsyche> 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<CourseEntity> 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();
}
}

View File

@@ -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<CoursePsycheMarket> coursePsycheMarketEntities = marketService.marketTree();
return R.ok().put("result", coursePsycheMarketEntities);
}
@RequestMapping(path = "/getMarketById")
public R getMarketById(@RequestBody Map<String,Integer> 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<CoursePsycheMarket>().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<CourseToPsycheMarket>().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<String ,Integer> map) {
int id = map.get("id");
CoursePsycheMarket market = marketService.getById(id);
if (market.getIsLast()==1){
MPJLambdaWrapper<CourseToPsycheMarket> wrapper = new MPJLambdaWrapper();
wrapper.eq(CourseToPsycheMarket::getPsycheMarketId,id);
List<CourseToPsycheMarket> tomarkets = toMarketService.list(wrapper);
if (tomarkets.size()>0){
return R.error("请先移除课程");
}else {
marketService.removeById(id);
return R.ok();
}
}else {
List<CoursePsycheMarket> marketList = marketService.list(new LambdaQueryWrapper<CoursePsycheMarket>().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<String,Integer> map){
CourseToPsycheMarket info = toMarketService.getOne(new LambdaQueryWrapper<CourseToPsycheMarket>()
.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<String,Integer> map){
List<CourseToPsycheMarket> marketId = toMarketService.getCourseListByMarketId(map.get("marketId"));
return R.ok().put("list",marketId);
}
@RequestMapping("/getNotToMarketList")
public R getNotToMarketList(@RequestBody ParamTo param){
List<Integer> collect = toMarketService.getBaseMapper().selectList(new LambdaQueryWrapper<CourseToPsycheMarket>().eq(CourseToPsycheMarket::getPsycheMarketId, param.getId())).stream().map(CourseToPsycheMarket::getCourseId).collect(Collectors.toList());
LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.notIn(collect.size()>0,CourseEntity::getId,collect);
wrapper.like(StringUtils.isNotBlank(param.getKeywords()),CourseEntity::getTitle,param.getKeywords());
Page<CourseEntity> page = courseService.page(new Page<>(param.getPage(), param.getLimit()), wrapper);
return R.ok().put("page",page);
}
@RequestMapping("/bindCourseAndPsycheMarket")
public R bindCourseAndPsycheMarket(@RequestBody Map<String,Integer> map){
int marketId = map.get("marketId");
int courseId = map.get("courseId");
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToPsycheMarket>().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<String,Integer> map){
int marketId = map.get("marketId");
int courseId = map.get("courseId");
toMarketService.getBaseMapper().delete(new LambdaQueryWrapper<CourseToPsycheMarket>().eq(CourseToPsycheMarket::getPsycheMarketId,marketId).eq(CourseToPsycheMarket::getCourseId,courseId));
return R.ok();
}
}

View File

@@ -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<Message> page = messageService.page(new Page<>(

View File

@@ -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<ShopProductPsycheLabel> labelsTree = labelService.labelTree();
return R.ok().put("result", labelsTree);
}
/**
* 获取标签列表
*/
@RequestMapping(path = "/getLabelListByPid")
public R getLabelListByPid(String pid) {
LambdaQueryWrapper<ShopProductPsycheLabel> wrapper = new LambdaQueryWrapper();
wrapper.eq(ShopProductPsycheLabel::getPid,pid);
wrapper.orderByAsc(ShopProductPsycheLabel::getSort);
wrapper.orderByAsc(ShopProductPsycheLabel::getCreateTime);
List<ShopProductPsycheLabel> labelTopList = labelService.list(wrapper);
return R.ok().put("result", labelTopList);
}
/**
* 营销标签树
*/
@RequestMapping(path = "/marketTree")
public R marketTree() {
List<ShopProductPsycheMarket> marketsTree = marketService.marketTree();
return R.ok().put("result", marketsTree);
}
/**
* 获取营销标签列表
*/
@RequestMapping(path = "/getMakertListByPid")
public R getMakertListByPid(String pid) {
LambdaQueryWrapper<ShopProductPsycheMarket> wrapper = new LambdaQueryWrapper();
wrapper.eq(ShopProductPsycheMarket::getPid,pid);
wrapper.orderByAsc(ShopProductPsycheMarket::getSort);
wrapper.orderByAsc(ShopProductPsycheMarket::getCreateTime);
List<ShopProductPsycheMarket> 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<ShopProductPsycheLabel>()
.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<ShopProductToPsycheLabel> wrapper = new MPJLambdaWrapper();
wrapper.eq(ShopProductToPsycheLabel::getPsycheLabelId,id);
List<ShopProductToPsycheLabel> tolables = toLabelService.list(wrapper);
if (tolables.size()>0){
return R.error("请先移除商品");
}else {
labelService.removeById(id);
return R.ok();
}
}else {
List<ShopProductPsycheLabel> labelList = labelService.list(new LambdaQueryWrapper<ShopProductPsycheLabel>().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<ShopProductPsycheMarket>()
.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<ShopProductToPsycheMarket> wrapper = new MPJLambdaWrapper();
wrapper.eq(ShopProductToPsycheMarket::getPsycheMarketId,id);
List<ShopProductToPsycheMarket> tomarkets = toMarketService.list(wrapper);
if (tomarkets.size()>0){
return R.error("请先移除商品");
}else {
marketService.removeById(id);
return R.ok();
}
}else {
List<ShopProductPsycheMarket> marketList = marketService.list(new LambdaQueryWrapper<ShopProductPsycheMarket>().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<ShopProduct> 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<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);
}
@RequestMapping("/editMarketSort")
public R editMarketSort(@RequestBody Map<String,Integer> 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<ShopProductToPsycheLabel> 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<ShopProductToPsycheLabel> page = toLabelService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
List<ShopProductToPsycheLabel> 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<ShopProductToPsycheMarket> 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<ShopProductToPsycheMarket> page = toMarketService.page(new Page<>(
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
List<ShopProductToPsycheMarket> 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<String,Integer> 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<ShopProductToPsycheLabel> 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<ShopProductToPsycheMarket> wrapper = new LambdaQueryWrapper();
wrapper.eq(ShopProductToPsycheMarket::getPsycheMarketId,marketId);
wrapper.eq(ShopProductToPsycheMarket::getProductId,id);
toMarketService.remove(wrapper);
}
}
return R.ok();
}
}

View File

@@ -23,6 +23,10 @@ public interface CourseService extends IService<CourseEntity> {
Page getCourseListCanMedical(ParamTo param);
List<CourseEntity> getCourseListForPsyche(int medicalId);
Page getCourseListCanPsyche(ParamTo param);
void testCourse();
List<CourseEntity> courseAndChildrenList(Map<String, Object> params);

View File

@@ -34,6 +34,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> 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<CourseDao, CourseEntity> impl
return page;
}
@Override
public List<CourseEntity> getCourseListForPsyche(int psycheId) {
MPJLambdaWrapper<CourseToPsyche> 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<CourseEntity> courseEntities = toPsycheDao.selectJoinList(CourseEntity.class, wrapper);
return courseEntities;
}
@Override
public Page getCourseListCanPsyche(ParamTo param) {
List<Integer> collect = toPsycheDao.selectList(new LambdaQueryWrapper<CourseToPsyche>().eq(CourseToPsyche::getPsycheId, param.getId())).stream().map(CourseToPsyche::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
public void testCourse() {

View File

@@ -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<String,Object> params){
List<CoursePsyche> psycheLabels = coursePsycheService.list(new LambdaQueryWrapper<CoursePsyche>()
.eq(CoursePsyche::getPid,params.get("id"))
.orderByAsc(CoursePsyche::getSort));
return R.ok().put("labels",psycheLabels);
}
//获取标签下的课程列表
@RequestMapping("/getPsycheCourseList")
public R getPsycheCourseList(@RequestBody Map<String,Object> params){
MPJLambdaWrapper<CourseEntity> 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<CourseEntity> courseEntityPage = courseService.page(new Page<>(
Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("courses",courseEntityPage);
}
}

View File

@@ -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<Message> messages = messageService.getBaseMapper().selectList(wrapper);
return R.ok().put("messages", messages);
@@ -262,4 +267,38 @@ public class VisitorController {
Page<CourseEntity> marketCourseList = sociologyCourseService.getMarketCourseList(param);
return R.ok().put("courseList",marketCourseList);
}
//获取心灵空间标签树
@RequestMapping("/getCoursePsycheTree")
public R getCoursePsycheTree(){
List<CoursePsyche> psychesTree = coursePsycheService.getCoursePsycheTree();
return R.ok().put("labels",psychesTree);
}
/**
* 心灵空间营销标签下商品列表
*/
@RequestMapping("/getPsycheMarketShopProductList")
public R getPsycheMarketShopProductList(@RequestBody Map params){
MPJLambdaWrapper<ShopProduct> 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<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);
}
//心灵空间营销标签下的课程列表
@RequestMapping("/getPsycheMarketCourseList")
public R getPsycheMarketCourseList(@RequestBody Map params){
MPJLambdaWrapper<CourseEntity> 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<CourseEntity> courseEntityPage = courseService.page(new Page<>(
Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("courseList",courseEntityPage);
}
}

View File

@@ -44,5 +44,9 @@ public class SysUserTokenEntity implements Serializable {
private String tokenSociology;
//更新时间
private Date sociologyUpdateTime;
//token
private String tokenPsyche;
//更新时间
private Date psycheUpdateTime;
}

View File

@@ -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);
}

View File

@@ -53,6 +53,9 @@ public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenDao, SysUse
}else if ("sociology".equals(appType)){
tokenEntity.setTokenSociology(token);
tokenEntity.setSociologyUpdateTime(now);
}else if ("psyche".equals(appType)){
tokenEntity.setTokenPsyche(token);
tokenEntity.setPsycheUpdateTime(now);
}
tokenEntity.setUserId(userId);
tokenEntity.setExpireTime(expireTime);

View File

@@ -4,6 +4,6 @@
<mapper namespace="com.peanut.modules.sys.dao.SysUserTokenDao">
<select id="queryByToken" resultType="com.peanut.modules.sys.entity.SysUserTokenEntity">
select * from sys_user_token where (token = #{value} or token_medical = #{value} or token_sociology = #{value})
select * from sys_user_token where (token = #{value} or token_medical = #{value} or token_sociology = #{value} or token_psyche = #{value})
</select>
</mapper>