mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 10:56:50 +08:00
ES查询时,二次查询评分处理
This commit is contained in:
@@ -234,12 +234,28 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
PageList<CourseFullText> coursePageList = fullTextSearch.search(ICourseFullTextSearch.DEFAULT_INDEX_NAME,pager.getStartRow(), pager.getPageSize(),paras);
|
||||
//提取教师信息
|
||||
List<String> ids=new ArrayList<String>();
|
||||
List<String> cids=new ArrayList<String>();
|
||||
for(CourseFullText c :coursePageList.getList()) {
|
||||
ids.add(c.getId());
|
||||
if(c.getSource()==2) {
|
||||
cids.add(c.getId());
|
||||
}
|
||||
}
|
||||
List<Course> clist=null;
|
||||
if(!cids.isEmpty()) {
|
||||
clist=courseService.findStudysScoreByIds(cids);
|
||||
}
|
||||
List<CourseTeacher> teachers = courseService.findTeachersByCourseIds(ids);
|
||||
//注意对于多个教师的情况,这里只是设置第一个教师
|
||||
for(CourseFullText c :coursePageList.getList()) {
|
||||
if(clist!=null) {
|
||||
for(Course c2 : clist) {
|
||||
if(c2.getId().equals(c.getId())) {
|
||||
c.setScore(c2.getScore());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(CourseTeacher ct : teachers) {
|
||||
if(ct.getCourseId().equals(c.getId())) {
|
||||
c.setTeacher(ct.getTeacherName());
|
||||
|
||||
@@ -50,6 +50,12 @@ public class Course extends BaseEntity {
|
||||
|
||||
}
|
||||
|
||||
public Course(String id,Integer studys,Float score) {
|
||||
this.setId(id);
|
||||
this.studys=studys;
|
||||
this.score=score;
|
||||
}
|
||||
|
||||
public Course(String id,Integer type,String name,String coverImg, Float score,Integer studys,Integer comments,Integer shares,Integer praises,Integer favorites
|
||||
,String forUsers,String value,String summary,LocalDateTime publishTime,Boolean isTop) {
|
||||
this.setId(id);
|
||||
|
||||
@@ -320,6 +320,13 @@ public interface ICourseService {
|
||||
* 页面二次查询
|
||||
* */
|
||||
List<Course> ids(List<String> ids);
|
||||
|
||||
/**
|
||||
* 查询需要的字段
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<Course> findStudysScoreByIds(List<String> ids);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1653,6 +1653,12 @@ public class CourseServiceImpl implements ICourseService {
|
||||
courseDao.updateFieldById(id, field, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Course> findStudysScoreByIds(List<String> ids) {
|
||||
|
||||
return courseDao.findListByHql("Select new Course(id,studys,score) from Course where id in(?1)",ids);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user