bug
This commit is contained in:
@@ -3,8 +3,10 @@ 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.ObjectUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.master.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -15,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController("masterCourseSociologyMarket")
|
||||
@@ -37,58 +40,41 @@ public class CourseSociologyMarketController {
|
||||
return R.ok().put("result", courseSociologyMarketEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销标签列表
|
||||
*/
|
||||
@RequestMapping(path = "/getMakertListByPid")
|
||||
public R getMakertListByPid(String pid) {
|
||||
LambdaQueryWrapper<CourseSociologyMarketEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(CourseSociologyMarketEntity::getPid,pid);
|
||||
wrapper.orderByAsc(CourseSociologyMarketEntity::getSort);
|
||||
wrapper.orderByAsc(CourseSociologyMarketEntity::getCreateTime);
|
||||
List<CourseSociologyMarketEntity> marketTopList = marketService.list(wrapper);
|
||||
return R.ok().put("result", marketTopList);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/getMarketById")
|
||||
public R getMarketById(String id) {
|
||||
public R getMarketById(@RequestBody Map<String,Integer> map) {
|
||||
int id = map.get("id");
|
||||
return R.ok().put("result",marketService.getById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateMarket")
|
||||
public R saveOrUpdateMarket(@RequestBody CourseSociologyMarketEntity market) {
|
||||
if (market.getId()==null){
|
||||
if(market.getPid()==0){
|
||||
marketService.save(market);
|
||||
return R.ok().put("result",market);
|
||||
}else {
|
||||
CourseSociologyMarketEntity 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<CourseSociologyMarketEntity>()
|
||||
.eq(CourseSociologyMarketEntity::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("/addSociologyMarket")
|
||||
public R addSociologyMarket(@RequestBody CourseSociologyMarketEntity courseSociologyMarketEntity){
|
||||
marketService.save(courseSociologyMarketEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/editSociologyMarket")
|
||||
public R editSociologyMarket(@RequestBody CourseSociologyMarketEntity courseSociologyMarketEntity){
|
||||
CourseSociologyMarketEntity old = marketService.getById(courseSociologyMarketEntity.getId());
|
||||
if(courseSociologyMarketEntity.getIsLast()==1&&old.getIsLast()==0){//非终节点到终结点,要排除是否存在子集
|
||||
Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseSociologyMarketEntity>().eq(CourseSociologyMarketEntity::getPid, courseSociologyMarketEntity.getId()));
|
||||
if(integer>0){
|
||||
return R.error("请先清空子集再操作!");
|
||||
}
|
||||
}
|
||||
|
||||
if(courseSociologyMarketEntity.getIsLast()==0&&old.getIsLast()==1){
|
||||
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToSociologyMarketEntity>().eq(CourseToSociologyMarketEntity::getSociologyMarketId, courseSociologyMarketEntity.getId()));
|
||||
if(integer>0){
|
||||
return R.error("请先清空绑定的课程后,再操作");
|
||||
}
|
||||
}
|
||||
marketService.save(courseSociologyMarketEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delMarket")
|
||||
public R delMarket(String id) {
|
||||
public R delMarket(@RequestBody Map<String ,Integer> map) {
|
||||
int id = map.get("id");
|
||||
CourseSociologyMarketEntity market = marketService.getById(id);
|
||||
if (market.getIsLast()==1){
|
||||
MPJLambdaWrapper<CourseToSociologyMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
@@ -111,66 +97,105 @@ public class CourseSociologyMarketController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/getCourseListByMarketId")
|
||||
public R getCourseListByMarketId(@RequestBody Map<String,Integer> map){
|
||||
List<CourseEntity> marketId = toMarketService.getCourseListByMarketId(map.get("marketId"));
|
||||
return R.ok().put("courseList",marketId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销标签下课程
|
||||
*/
|
||||
@RequestMapping(path = "/getCourseByMarketId")
|
||||
public R getCourseByMarket(@RequestBody Map<String, Object> params) {
|
||||
MPJLambdaWrapper<CourseToSociologyMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId, CourseToSociologyMarketEntity::getCourseId);
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.like(CourseEntity::getTitle,params.get("title"));
|
||||
wrapper.eq(CourseToSociologyMarketEntity::getSociologyMarketId,params.get("marketId"));
|
||||
Page res = toMarketService.pageMaps(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
|
||||
return R.ok().put("result", res);
|
||||
// @RequestMapping(path = "/getCourseByMarketId")
|
||||
// public R getCourseByMarket(@RequestBody Map<String, Object> params) {
|
||||
// MPJLambdaWrapper<CourseToSociologyMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
// wrapper.leftJoin(CourseEntity.class,CourseEntity::getId, CourseToSociologyMarketEntity::getCourseId);
|
||||
// wrapper.selectAll(CourseEntity.class);
|
||||
// wrapper.like(CourseEntity::getTitle,params.get("title"));
|
||||
// wrapper.eq(CourseToSociologyMarketEntity::getSociologyMarketId,params.get("marketId"));
|
||||
// Page res = toMarketService.pageMaps(new Page<>(
|
||||
// Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
|
||||
// return R.ok().put("result", res);
|
||||
// }
|
||||
|
||||
@RequestMapping("/getNotToMarketList")
|
||||
public R getNotToMarketList(@RequestBody ParamTo param){
|
||||
List<Integer> collect = toMarketService.getBaseMapper().selectList(new LambdaQueryWrapper<CourseToSociologyMarketEntity>().eq(CourseToSociologyMarketEntity::getSociologyMarketId, param.getId())).stream().map(CourseToSociologyMarketEntity::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("/getNotToMarketList")
|
||||
public R getNotToMarketList(@RequestBody Map params){
|
||||
LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.like(CourseEntity::getTitle,params.get("title"));
|
||||
if (params.containsKey("marketId")&&!"".equals(params.get("marketId").toString())){
|
||||
String sql = "select course_id from course_to_market where del_flag = 0 and market_id = "+params.get("marketId");
|
||||
wrapper.notInSql(CourseEntity::getId,sql);
|
||||
}
|
||||
Page<CourseEntity> page = courseService.page(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
// @RequestMapping("/getNotToMarketList")
|
||||
// public R getNotToMarketList(@RequestBody Map params){
|
||||
// LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper();
|
||||
// wrapper.like(CourseEntity::getTitle,params.get("title"));
|
||||
// if (params.containsKey("marketId")&&!"".equals(params.get("marketId").toString())){
|
||||
// String sql = "select course_id from course_to_market where del_flag = 0 and market_id = "+params.get("marketId");
|
||||
// wrapper.notInSql(CourseEntity::getId,sql);
|
||||
// }
|
||||
// Page<CourseEntity> page = courseService.page(new Page<>(
|
||||
// Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
|
||||
// return R.ok().put("result", page);
|
||||
// }
|
||||
|
||||
@RequestMapping(path = "/saveToMarket")
|
||||
public R saveToMarket(@RequestBody Map params) {
|
||||
if (!StringUtils.isEmpty(params.get("courseId").toString())){
|
||||
String[] ids = params.get("courseId").toString().split(",");
|
||||
if (ids.length > 0) {
|
||||
for (String id : ids) {
|
||||
CourseToSociologyMarketEntity toMarket = new CourseToSociologyMarketEntity();
|
||||
toMarket.setSociologyMarketId(Integer.parseInt(params.get("marketId").toString()));
|
||||
toMarket.setCourseId(Integer.parseInt(id));
|
||||
toMarketService.save(toMarket);
|
||||
}
|
||||
}
|
||||
@RequestMapping("/bindCourseAndSociologyMarket")
|
||||
public R bindCourseAndSociologyMarket(@RequestBody Map<String,Integer> map){
|
||||
int marketId = map.get("marketId");
|
||||
int courseId = map.get("courseId");
|
||||
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToSociologyMarketEntity>().eq(CourseToSociologyMarketEntity::getSociologyMarketId, marketId).eq(CourseToSociologyMarketEntity::getCourseId, courseId));
|
||||
if(integer>0){
|
||||
return R.error("不可重复绑定");
|
||||
}
|
||||
CourseToSociologyMarketEntity courseToSociologyMarketEntity = new CourseToSociologyMarketEntity();
|
||||
courseToSociologyMarketEntity.setSociologyMarketId(marketId);
|
||||
courseToSociologyMarketEntity.setCourseId(courseId);
|
||||
toMarketService.save(courseToSociologyMarketEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delToMarket")
|
||||
public R delToMarket(String marketId,String courseId) {
|
||||
if(StringUtils.isNotEmpty(courseId)){
|
||||
String[] productIds = courseId.split(",");
|
||||
for(String id : productIds){
|
||||
LambdaQueryWrapper<CourseToSociologyMarketEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(CourseToSociologyMarketEntity::getSociologyMarketId,marketId);
|
||||
wrapper.eq(CourseToSociologyMarketEntity::getCourseId,id);
|
||||
toMarketService.remove(wrapper);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("参数为空");
|
||||
@RequestMapping("/unbindCourseAndSociologyMarket")
|
||||
public R unbindCourseAndSociologyMarket(@RequestBody Map<String,Integer> map){
|
||||
int marketId = map.get("marketId");
|
||||
int courseId = map.get("courseId");
|
||||
toMarketService.getBaseMapper().delete(new LambdaQueryWrapper<CourseToSociologyMarketEntity>().eq(CourseToSociologyMarketEntity::getSociologyMarketId,marketId).eq(CourseToSociologyMarketEntity::getCourseId,courseId));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
// @RequestMapping(path = "/saveToMarket")
|
||||
// public R saveToMarket(@RequestBody Map params) {
|
||||
// if (!StringUtils.isEmpty(params.get("courseId").toString())){
|
||||
// String[] ids = params.get("courseId").toString().split(",");
|
||||
// if (ids.length > 0) {
|
||||
// for (String id : ids) {
|
||||
// CourseToSociologyMarketEntity toMarket = new CourseToSociologyMarketEntity();
|
||||
// toMarket.setSociologyMarketId(Integer.parseInt(params.get("marketId").toString()));
|
||||
// toMarket.setCourseId(Integer.parseInt(id));
|
||||
// toMarketService.save(toMarket);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(path = "/delToMarket")
|
||||
// public R delToMarket(String marketId,String courseId) {
|
||||
// if(StringUtils.isNotEmpty(courseId)){
|
||||
// String[] productIds = courseId.split(",");
|
||||
// for(String id : productIds){
|
||||
// LambdaQueryWrapper<CourseToSociologyMarketEntity> wrapper = new LambdaQueryWrapper();
|
||||
// wrapper.eq(CourseToSociologyMarketEntity::getSociologyMarketId,marketId);
|
||||
// wrapper.eq(CourseToSociologyMarketEntity::getCourseId,id);
|
||||
// toMarketService.remove(wrapper);
|
||||
// }
|
||||
// return R.ok();
|
||||
// }
|
||||
// return R.error("参数为空");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.common.entity.CourseToMedicineMarketEntity;
|
||||
import com.peanut.modules.common.entity.CourseToSociologyMarketEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CourseToSociologyMarketService extends IService<CourseToSociologyMarketEntity> {
|
||||
|
||||
List<CourseEntity> getCourseListByMarketId(int marketId);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.modules.common.dao.CourseToMedicineMarketDao;
|
||||
import com.peanut.modules.common.dao.CourseToSociologyMarketDao;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.common.entity.CourseToMedicineMarketEntity;
|
||||
import com.peanut.modules.common.entity.CourseToSociologyMarketEntity;
|
||||
import com.peanut.modules.master.service.CourseToMedicineMarketService;
|
||||
@@ -10,7 +12,19 @@ import com.peanut.modules.master.service.CourseToSociologyMarketService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterCourseToSociologyMarketService")
|
||||
public class CourseToSociologyMarketServiceImpl extends ServiceImpl<CourseToSociologyMarketDao, CourseToSociologyMarketEntity> implements CourseToSociologyMarketService {
|
||||
|
||||
@Override
|
||||
public List<CourseEntity> getCourseListByMarketId(int marketId) {
|
||||
MPJLambdaWrapper<CourseToSociologyMarketEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,CourseToSociologyMarketEntity::getCourseId);
|
||||
wrapper.eq(CourseToSociologyMarketEntity::getSociologyMarketId,marketId);
|
||||
List<CourseEntity> courseEntities = this.getBaseMapper().selectJoinList(CourseEntity.class, wrapper);
|
||||
return courseEntities;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user