bug
This commit is contained in:
@@ -5,10 +5,7 @@ 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.CourseEntity;
|
||||
import com.peanut.modules.common.entity.CourseMedicineMarketEntity;
|
||||
import com.peanut.modules.common.entity.CourseToMedicineMarketEntity;
|
||||
import com.peanut.modules.common.entity.CourseToSociologyMarketEntity;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.master.service.CourseMedicineMarketService;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
@@ -44,58 +41,41 @@ public class CourseMedicineMarketController {
|
||||
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) {
|
||||
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 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("/addSociologyMarket")
|
||||
public R addSociologyMarket(@RequestBody CourseMedicineMarketEntity courseMedicineMarketEntity){
|
||||
marketService.save(courseMedicineMarketEntity);
|
||||
return R.ok().put("market",courseMedicineMarketEntity);
|
||||
}
|
||||
|
||||
@RequestMapping("/editSociologyMarket")
|
||||
public R editSociologyMarket(@RequestBody CourseMedicineMarketEntity courseMedicineMarketEntity){
|
||||
CourseMedicineMarketEntity old = marketService.getById(courseMedicineMarketEntity.getId());
|
||||
if(courseMedicineMarketEntity.getIsLast()==1&&old.getIsLast()==0){//非终节点到终结点,要排除是否存在子集
|
||||
Integer integer = marketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseMedicineMarketEntity>().eq(CourseMedicineMarketEntity::getPid, courseMedicineMarketEntity.getId()));
|
||||
if(integer>0){
|
||||
return R.error("请先清空子集再操作!");
|
||||
}
|
||||
}
|
||||
|
||||
if(courseMedicineMarketEntity.getIsLast()==0&&old.getIsLast()==1){
|
||||
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToMedicineMarketEntity>().eq(CourseToMedicineMarketEntity::getMedicineMarketId, courseMedicineMarketEntity.getId()));
|
||||
if(integer>0){
|
||||
return R.error("请先清空绑定的课程后,再操作");
|
||||
}
|
||||
}
|
||||
marketService.updateById(courseMedicineMarketEntity);
|
||||
return R.ok().put("market",courseMedicineMarketEntity);
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/delMarket")
|
||||
public R delMarket(String id) {
|
||||
public R delMarket(@RequestBody Map<String ,Integer> map) {
|
||||
int id = map.get("id");
|
||||
CourseMedicineMarketEntity market = marketService.getById(id);
|
||||
if (market.getIsLast()==1){
|
||||
MPJLambdaWrapper<CourseToMedicineMarketEntity> wrapper = new MPJLambdaWrapper();
|
||||
@@ -118,22 +98,6 @@ public class CourseMedicineMarketController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取营销标签下课程
|
||||
*/
|
||||
// @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(path = "/getCourseByMarketId")
|
||||
public R getCourseByMarketId(@RequestBody Map<String,Integer> map){
|
||||
int marketId = map.get("marketId");
|
||||
@@ -154,35 +118,27 @@ public class CourseMedicineMarketController {
|
||||
return R.ok().put("page",page1);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@RequestMapping("/bindCourseAndMedicineMarket")
|
||||
public R bindCourseAndMedicineMarket(@RequestBody Map<String,Integer> map){
|
||||
int marketId = map.get("marketId");
|
||||
int courseId = map.get("courseId");
|
||||
Integer integer = toMarketService.getBaseMapper().selectCount(new LambdaQueryWrapper<CourseToMedicineMarketEntity>().eq(CourseToMedicineMarketEntity::getMedicineMarketId, marketId).eq(CourseToMedicineMarketEntity::getCourseId, courseId));
|
||||
if(integer>0){
|
||||
return R.error("不可重复绑定");
|
||||
}
|
||||
CourseToMedicineMarketEntity courseToMedicineMarketEntity = new CourseToMedicineMarketEntity();
|
||||
courseToMedicineMarketEntity.setMedicineMarketId(marketId);
|
||||
courseToMedicineMarketEntity.setCourseId(courseId);
|
||||
toMarketService.save(courseToMedicineMarketEntity);
|
||||
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("参数为空");
|
||||
@RequestMapping("/unbindCourseAndMedicineMarket")
|
||||
public R unbindCourseAndMedicineMarket(@RequestBody Map<String,Integer> map){
|
||||
int marketId = map.get("marketId");
|
||||
int courseId = map.get("courseId");
|
||||
toMarketService.getBaseMapper().delete(new LambdaQueryWrapper<CourseToMedicineMarketEntity>().eq(CourseToMedicineMarketEntity::getMedicineMarketId,marketId).eq(CourseToMedicineMarketEntity::getCourseId,courseId));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ public class CourseMedicineServiceImpl extends ServiceImpl<CourseMedicineDao, Co
|
||||
}
|
||||
}
|
||||
if(old.getIsLast()==1&& courseMedicine.getIsLast()==0){
|
||||
CourseToMedicine courseToSociologyEntity = toMedicalDao.selectOne(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getMedicalId, courseMedicine.getId()));
|
||||
if(courseToSociologyEntity!=null){
|
||||
Integer integer = toMedicalDao.selectCount(new LambdaQueryWrapper<CourseToMedicine>().eq(CourseToMedicine::getMedicalId, courseMedicine.getId()));
|
||||
if(integer>0){
|
||||
return R.error(502,"更新失败,请先把此项与课程的关联关系清空后才可把此标签变成普通标签");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user