命名错误,课程营销标签分开的bug
This commit is contained in:
@@ -3,8 +3,8 @@ package com.peanut.modules.master.controller;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.common.entity.CourseMedical;
|
||||
import com.peanut.modules.common.entity.CourseToMedical;
|
||||
import com.peanut.modules.common.entity.CourseMedicine;
|
||||
import com.peanut.modules.common.entity.CourseToMedicine;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.master.service.CourseMedicalService;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@RestController("masterCourseMedical")
|
||||
@RequestMapping("master/courseMedical")
|
||||
public class CourseMedicalController {
|
||||
public class CourseMedicineController {
|
||||
@Autowired
|
||||
private CourseMedicalService medicalService;
|
||||
@Autowired
|
||||
@@ -30,14 +30,14 @@ public class CourseMedicalController {
|
||||
|
||||
@RequestMapping("/getCourseMedicalList")
|
||||
public R getCourseMedicalList(){
|
||||
List<CourseMedical> courseMedicalList = medicalService.getCourseMedicalList();
|
||||
return R.ok().put("Medicals",courseMedicalList);
|
||||
List<CourseMedicine> courseMedicineList = medicalService.getCourseMedicalList();
|
||||
return R.ok().put("Medicals", courseMedicineList);
|
||||
}
|
||||
|
||||
@RequestMapping("/addCourseMedical")
|
||||
public R addCourseMedical(@RequestBody CourseMedical courseMedical){
|
||||
medicalService.save(courseMedical);
|
||||
return R.ok().put("Medical",courseMedical);
|
||||
public R addCourseMedical(@RequestBody CourseMedicine courseMedicine){
|
||||
medicalService.save(courseMedicine);
|
||||
return R.ok().put("Medical", courseMedicine);
|
||||
}
|
||||
|
||||
@RequestMapping("/delCourseMedical")
|
||||
@@ -46,8 +46,8 @@ public class CourseMedicalController {
|
||||
}
|
||||
|
||||
@RequestMapping("/editCourseMedical")
|
||||
public R editCourseMedical(@RequestBody CourseMedical courseMedical){
|
||||
return medicalService.editCourseMedical(courseMedical);
|
||||
public R editCourseMedical(@RequestBody CourseMedicine courseMedicine){
|
||||
return medicalService.editCourseMedical(courseMedicine);
|
||||
}
|
||||
|
||||
@RequestMapping("/getCourseListForMedical")
|
||||
@@ -63,12 +63,12 @@ public class CourseMedicalController {
|
||||
}
|
||||
|
||||
@RequestMapping("/bindCourseAndMedical")
|
||||
public R bindCourseAndMedical(@RequestBody CourseToMedical toMedical){
|
||||
public R bindCourseAndMedical(@RequestBody CourseToMedicine toMedical){
|
||||
return toMedicalService.bindCourseAndMedical(toMedical);
|
||||
}
|
||||
|
||||
@RequestMapping("/unbindCourseAndMedical")
|
||||
public R unbindCourseAndMedical(@RequestBody CourseToMedical toMedical){
|
||||
public R unbindCourseAndMedical(@RequestBody CourseToMedicine toMedical){
|
||||
boolean b = toMedicalService.removeById(toMedical.getId());
|
||||
if(b){
|
||||
return R.ok();
|
||||
@@ -78,7 +78,7 @@ public class CourseMedicalController {
|
||||
}
|
||||
|
||||
@RequestMapping("/updateCourseToMedicalSort")
|
||||
public R updateCourseToMedicalSort(@RequestBody CourseToMedical toMedical){
|
||||
public R updateCourseToMedicalSort(@RequestBody CourseToMedicine toMedical){
|
||||
toMedicalService.updateById(toMedical);
|
||||
return R.ok();
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
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.CourseMedicineMarketEntity;
|
||||
import com.peanut.modules.common.entity.CourseToMedicineMarketEntity;
|
||||
import com.peanut.modules.master.service.CourseMedicineMarketService;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import com.peanut.modules.master.service.CourseToMedicineMarketService;
|
||||
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("masterCourseMedicineMarket")
|
||||
@RequestMapping("master/courseMedicineMarket")
|
||||
public class CourseMedicineMarketController {
|
||||
|
||||
@Autowired
|
||||
private CourseMedicineMarketService marketService;
|
||||
@Autowired
|
||||
private CourseToMedicineMarketService toMarketService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
|
||||
/**
|
||||
* 营销标签树
|
||||
*/
|
||||
@RequestMapping(path = "/marketTree")
|
||||
public R marketTree() {
|
||||
List<CourseMedicineMarketEntity> marketsTree = marketService.marketTree();
|
||||
return R.ok().put("result", marketsTree);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销标签列表
|
||||
*/
|
||||
@RequestMapping(path = "/getMakertListByPid")
|
||||
public R getMakertListByPid(String pid) {
|
||||
LambdaQueryWrapper<CourseMedicineMarketEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(CourseMedicineMarketEntity::getPid,pid);
|
||||
wrapper.orderByAsc(CourseMedicineMarketEntity::getSort);
|
||||
wrapper.orderByAsc(CourseMedicineMarketEntity::getCreateTime);
|
||||
List<CourseMedicineMarketEntity> marketTopList = marketService.list(wrapper);
|
||||
return R.ok().put("result", marketTopList);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/getMarketById")
|
||||
public R getMarketById(String id) {
|
||||
return R.ok().put("result",marketService.getById(id));
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateMarket")
|
||||
public R saveOrUpdateMarket(@RequestBody CourseMedicineMarketEntity market) {
|
||||
if (market.getId()==null){
|
||||
if(market.getPid()==0){
|
||||
marketService.save(market);
|
||||
return R.ok().put("result",market);
|
||||
}else {
|
||||
CourseMedicineMarketEntity 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<CourseMedicineMarketEntity>()
|
||||
.eq(CourseMedicineMarketEntity::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) {
|
||||
CourseMedicineMarketEntity market = marketService.getById(id);
|
||||
if (market.getIsLast()==1){
|
||||
MPJLambdaWrapper<CourseToMedicineMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(CourseToMedicineMarketEntity::getMedicineMarketId,id);
|
||||
List<CourseToMedicineMarketEntity> tomarkets = toMarketService.list(wrapper);
|
||||
if (tomarkets.size()>0){
|
||||
return R.error("请先移除课程");
|
||||
}else {
|
||||
marketService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}else {
|
||||
List<CourseMedicineMarketEntity> marketList = marketService.list(new LambdaQueryWrapper<CourseMedicineMarketEntity>().eq(CourseMedicineMarketEntity::getPid,id));
|
||||
if (marketList.size() > 0) {
|
||||
return R.error("请先删除子集");
|
||||
}else {
|
||||
marketService.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销标签下课程
|
||||
*/
|
||||
@RequestMapping(path = "/getCourseByMarketId")
|
||||
public R getCourseByMarket(@RequestBody Map<String, Object> params) {
|
||||
MPJLambdaWrapper<CourseToMedicineMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId, CourseToMedicineMarketEntity::getCourseId);
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.like(CourseEntity::getTitle,params.get("title"));
|
||||
wrapper.eq(CourseToMedicineMarketEntity::getMedicineMarketId,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 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) {
|
||||
CourseToMedicineMarketEntity toMarket = new CourseToMedicineMarketEntity();
|
||||
toMarket.setMedicineMarketId(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<CourseToMedicineMarketEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(CourseToMedicineMarketEntity::getMedicineMarketId,marketId);
|
||||
wrapper.eq(CourseToMedicineMarketEntity::getCourseId,id);
|
||||
toMarketService.remove(wrapper);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("参数为空");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,30 +4,27 @@ 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.CourseMarketEntity;
|
||||
import com.peanut.modules.common.entity.CourseToMarketEntity;
|
||||
import com.peanut.modules.master.service.CourseMarketService;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import com.peanut.modules.master.service.CourseToMarketService;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.master.service.*;
|
||||
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("masterCourseMarket")
|
||||
@RequestMapping("master/courseMarket")
|
||||
public class CourseMarketController {
|
||||
@RestController("masterCourseSociologyMarket")
|
||||
@RequestMapping("master/courseSociologyMarket")
|
||||
public class CourseSociologyMarketController {
|
||||
|
||||
@Autowired
|
||||
private CourseMarketService marketService;
|
||||
private CourseSociologyMarketService marketService;
|
||||
@Autowired
|
||||
private CourseToMarketService toMarketService;
|
||||
private CourseToSociologyMarketService toMarketService;
|
||||
@Autowired
|
||||
private CourseService courseService;
|
||||
|
||||
@@ -36,8 +33,8 @@ public class CourseMarketController {
|
||||
*/
|
||||
@RequestMapping(path = "/marketTree")
|
||||
public R marketTree() {
|
||||
List<CourseMarketEntity> marketsTree = marketService.marketTree();
|
||||
return R.ok().put("result", marketsTree);
|
||||
List<CourseSociologyMarketEntity> courseSociologyMarketEntities = marketService.marketTree();
|
||||
return R.ok().put("result", courseSociologyMarketEntities);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,11 +42,11 @@ public class CourseMarketController {
|
||||
*/
|
||||
@RequestMapping(path = "/getMakertListByPid")
|
||||
public R getMakertListByPid(String pid) {
|
||||
LambdaQueryWrapper<CourseMarketEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(CourseMarketEntity::getPid,pid);
|
||||
wrapper.orderByAsc(CourseMarketEntity::getSort);
|
||||
wrapper.orderByAsc(CourseMarketEntity::getCreateTime);
|
||||
List<CourseMarketEntity> marketTopList = marketService.list(wrapper);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -59,13 +56,13 @@ public class CourseMarketController {
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/saveOrUpdateMarket")
|
||||
public R saveOrUpdateMarket(@RequestBody CourseMarketEntity market) {
|
||||
public R saveOrUpdateMarket(@RequestBody CourseSociologyMarketEntity market) {
|
||||
if (market.getId()==null){
|
||||
if(market.getPid()==0){
|
||||
marketService.save(market);
|
||||
return R.ok().put("result",market);
|
||||
}else {
|
||||
CourseMarketEntity m = marketService.getById(market.getPid());
|
||||
CourseSociologyMarketEntity m = marketService.getById(market.getPid());
|
||||
if (m.getIsLast()==1){
|
||||
return R.error("请将父标签设置为非最后一集");
|
||||
}else {
|
||||
@@ -75,8 +72,8 @@ public class CourseMarketController {
|
||||
}
|
||||
}else {
|
||||
if (market.getIsLast() == 1){
|
||||
List mList = marketService.list(new LambdaQueryWrapper<CourseMarketEntity>()
|
||||
.eq(CourseMarketEntity::getPid,market.getId()));
|
||||
List mList = marketService.list(new LambdaQueryWrapper<CourseSociologyMarketEntity>()
|
||||
.eq(CourseSociologyMarketEntity::getPid,market.getId()));
|
||||
if (mList.size()>0){
|
||||
return R.error("请先删除子集,再设置为最后一集");
|
||||
}else {
|
||||
@@ -92,11 +89,11 @@ public class CourseMarketController {
|
||||
|
||||
@RequestMapping(path = "/delMarket")
|
||||
public R delMarket(String id) {
|
||||
CourseMarketEntity market = marketService.getById(id);
|
||||
CourseSociologyMarketEntity market = marketService.getById(id);
|
||||
if (market.getIsLast()==1){
|
||||
MPJLambdaWrapper<CourseToMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(CourseToMarketEntity::getMarketId,id);
|
||||
List<CourseToMarketEntity> tomarkets = toMarketService.list(wrapper);
|
||||
MPJLambdaWrapper<CourseToSociologyMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(CourseToSociologyMarketEntity::getSociologyMarketId,id);
|
||||
List<CourseToSociologyMarketEntity> tomarkets = toMarketService.list(wrapper);
|
||||
if (tomarkets.size()>0){
|
||||
return R.error("请先移除课程");
|
||||
}else {
|
||||
@@ -104,7 +101,7 @@ public class CourseMarketController {
|
||||
return R.ok();
|
||||
}
|
||||
}else {
|
||||
List<CourseMarketEntity> marketList = marketService.list(new LambdaQueryWrapper<CourseMarketEntity>().eq(CourseMarketEntity::getPid,id));
|
||||
List<CourseSociologyMarketEntity> marketList = marketService.list(new LambdaQueryWrapper<CourseSociologyMarketEntity>().eq(CourseSociologyMarketEntity::getPid,id));
|
||||
if (marketList.size() > 0) {
|
||||
return R.error("请先删除子集");
|
||||
}else {
|
||||
@@ -119,11 +116,11 @@ public class CourseMarketController {
|
||||
*/
|
||||
@RequestMapping(path = "/getCourseByMarketId")
|
||||
public R getCourseByMarket(@RequestBody Map<String, Object> params) {
|
||||
MPJLambdaWrapper<CourseToMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,CourseToMarketEntity::getCourseId);
|
||||
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(CourseToMarketEntity::getMarketId,params.get("marketId"));
|
||||
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);
|
||||
@@ -151,8 +148,8 @@ public class CourseMarketController {
|
||||
String[] ids = params.get("courseId").toString().split(",");
|
||||
if (ids.length > 0) {
|
||||
for (String id : ids) {
|
||||
CourseToMarketEntity toMarket = new CourseToMarketEntity();
|
||||
toMarket.setMarketId(Integer.parseInt(params.get("marketId").toString()));
|
||||
CourseToSociologyMarketEntity toMarket = new CourseToSociologyMarketEntity();
|
||||
toMarket.setSociologyMarketId(Integer.parseInt(params.get("marketId").toString()));
|
||||
toMarket.setCourseId(Integer.parseInt(id));
|
||||
toMarketService.save(toMarket);
|
||||
}
|
||||
@@ -166,9 +163,9 @@ public class CourseMarketController {
|
||||
if(StringUtils.isNotEmpty(courseId)){
|
||||
String[] productIds = courseId.split(",");
|
||||
for(String id : productIds){
|
||||
LambdaQueryWrapper<CourseToMarketEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(CourseToMarketEntity::getMarketId,marketId);
|
||||
wrapper.eq(CourseToMarketEntity::getCourseId,id);
|
||||
LambdaQueryWrapper<CourseToSociologyMarketEntity> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(CourseToSociologyMarketEntity::getSociologyMarketId,marketId);
|
||||
wrapper.eq(CourseToSociologyMarketEntity::getCourseId,id);
|
||||
toMarketService.remove(wrapper);
|
||||
}
|
||||
return R.ok();
|
||||
Reference in New Issue
Block a user