Merge remote-tracking branch 'origin/zcc'
This commit is contained in:
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.ObjectUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.book.service.CouponProductRelationService;
|
||||
import com.peanut.modules.common.dao.*;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
@@ -44,19 +45,39 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
public Page getCourseList(Map<String,Object> map) {
|
||||
Integer limit = Integer.valueOf(map.get("limit").toString());
|
||||
Integer page = Integer.valueOf(map.get("page").toString());
|
||||
LambdaQueryWrapper<CourseEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if(ObjectUtils.isNotBlank(map,"keywords")){
|
||||
wrapper.like(CourseEntity::getTitle,map.get("keywords").toString());
|
||||
}
|
||||
Page<CourseEntity> courseEntityPage = null;
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.orderByAsc(CourseEntity::getSort);
|
||||
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
if(ObjectUtils.isNotBlank(map,"courseName")){
|
||||
wrapper.like(CourseEntity::getTitle,map.get("courseName").toString());
|
||||
}
|
||||
//0全部
|
||||
if ("1".equals(map.get("type").toString())){
|
||||
//医学
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.rightJoin(CourseToMedicine.class,CourseToMedicine::getCourseId,CourseEntity::getId);
|
||||
if (!"".equals(map.get("medicalId").toString())){
|
||||
List list = new ArrayList();
|
||||
getMedicineIdByPid(list,map.get("medicalId").toString());
|
||||
wrapper.in(CourseToMedicine::getMedicalId,list);
|
||||
}
|
||||
}else if("2".equals(map.get("type").toString())){
|
||||
//国学
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.rightJoin(CourseToSociologyEntity.class,CourseToSociologyEntity::getCourseId,CourseEntity::getId);
|
||||
if (!"".equals(map.get("sociologyId").toString())){
|
||||
List list = new ArrayList();
|
||||
getSociologyIdByPid(list,map.get("sociologyId").toString());
|
||||
wrapper.in(CourseToSociologyEntity::getSociologyId,list);
|
||||
}
|
||||
}
|
||||
courseEntityPage = this.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
for (CourseEntity c:courseEntityPage.getRecords()){
|
||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, c.getId()).orderByAsc(CourseCatalogueEntity::getSort));
|
||||
c.setCourseCatalogueEntityList(courseCatalogueEntities);
|
||||
}
|
||||
|
||||
return courseEntityPage;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,4 +205,38 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
}
|
||||
|
||||
|
||||
private void getMedicineIdByPid(List res,String pid){
|
||||
MPJLambdaWrapper<CourseMedicine> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(CourseMedicine::getPid,pid);
|
||||
List<CourseMedicine> list = medicalDao.selectList(wrapper);
|
||||
if (list.size() > 0) {
|
||||
for (CourseMedicine c:list){
|
||||
if(c.getIsLast()!=1){
|
||||
getMedicineIdByPid(res,c.getId().toString());
|
||||
}else {
|
||||
res.add(c.getId());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
res.add(pid);
|
||||
}
|
||||
}
|
||||
private void getSociologyIdByPid(List res,String pid){
|
||||
MPJLambdaWrapper<CourseSociologyEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.eq(CourseSociologyEntity::getPid,pid);
|
||||
List<CourseSociologyEntity> list = courseSociologyDao.selectList(wrapper);
|
||||
if (list.size() > 0) {
|
||||
for (CourseSociologyEntity c:list){
|
||||
if(c.getIsLast()!=1){
|
||||
getSociologyIdByPid(res,c.getId().toString());
|
||||
}else {
|
||||
res.add(c.getId());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
res.add(pid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user