修复一下bug
This commit is contained in:
@@ -38,4 +38,9 @@ public class CourseCatalogueEntity{
|
|||||||
*/
|
*/
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Integer needCreate;
|
private Integer needCreate;
|
||||||
|
/**
|
||||||
|
* isBuy:0否1是
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer isBuy;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,15 +24,6 @@ public class HomeController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CourseSociologyService courseSociologyService;
|
private CourseSociologyService courseSociologyService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//首页-我的课程
|
|
||||||
@RequestMapping("/getMyCourse")
|
|
||||||
public R getMyCourse(String userId){
|
|
||||||
List<CourseEntity> courseList = courseService.getMyCourse(userId);
|
|
||||||
return R.ok().put("myCourse",courseList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*获取国学标签列表
|
*获取国学标签列表
|
||||||
* @param param
|
* @param param
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface CourseService extends IService<CourseEntity> {
|
public interface CourseService extends IService<CourseEntity> {
|
||||||
|
|
||||||
List<CourseEntity> getMyCourse(String userId);
|
|
||||||
|
|
||||||
List<CourseEntity> getCourseListBySociology(String sociologyId);
|
List<CourseEntity> getCourseListBySociology(String sociologyId);
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.peanut.modules.common.dao.CourseCatalogueDao;
|
import com.peanut.common.utils.ShiroUtils;
|
||||||
import com.peanut.modules.common.dao.CourseDao;
|
import com.peanut.modules.common.dao.*;
|
||||||
import com.peanut.modules.common.dao.CourseToSociologyDao;
|
|
||||||
import com.peanut.modules.common.dao.UserToCourseDao;
|
|
||||||
import com.peanut.modules.common.entity.*;
|
import com.peanut.modules.common.entity.*;
|
||||||
import com.peanut.modules.common.to.ParamTo;
|
import com.peanut.modules.common.to.ParamTo;
|
||||||
import com.peanut.modules.sociology.service.CourseService;
|
import com.peanut.modules.sociology.service.CourseService;
|
||||||
@@ -30,18 +28,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
private CourseToSociologyDao courseToSociologyDao;
|
private CourseToSociologyDao courseToSociologyDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CourseCatalogueDao courseCatalogueDao;
|
private CourseCatalogueDao courseCatalogueDao;
|
||||||
|
@Autowired
|
||||||
|
private UserCourseBuyDao userCourseBuyDao;
|
||||||
|
|
||||||
//我的课程
|
|
||||||
@Override
|
|
||||||
public List<CourseEntity> getMyCourse(String userId) {
|
|
||||||
MPJLambdaWrapper<UserToCourseEntity> wrapper = new MPJLambdaWrapper();
|
|
||||||
wrapper.selectAll(CourseEntity.class);
|
|
||||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,UserToCourseEntity::getCourseId);
|
|
||||||
wrapper.groupBy(UserToCourseEntity::getCourseId);
|
|
||||||
wrapper.eq(UserToCourseEntity::getUserId,userId);
|
|
||||||
List courseList = userToCourseDao.selectMaps(wrapper);
|
|
||||||
return courseList;
|
|
||||||
}
|
|
||||||
|
|
||||||
//根据标签获取课程列表
|
//根据标签获取课程列表
|
||||||
@Override
|
@Override
|
||||||
@@ -90,6 +79,11 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
CourseEntity course = this.getById(id);
|
CourseEntity course = this.getById(id);
|
||||||
flag.put("course",course);
|
flag.put("course",course);
|
||||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, id));
|
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, id));
|
||||||
|
Integer uId = ShiroUtils.getUId();
|
||||||
|
for (CourseCatalogueEntity c :courseCatalogueEntities){
|
||||||
|
Integer integer = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>().eq(UserCourseBuyEntity::getUserId, uId).eq(UserCourseBuyEntity::getCatalogueId, c.getId()));
|
||||||
|
c.setIsBuy(integer>0?1:0);
|
||||||
|
}
|
||||||
flag.put("catalogues",courseCatalogueEntities);
|
flag.put("catalogues",courseCatalogueEntities);
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user