mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-14 05:16:49 +08:00
fix: 【FCJDFDXTXS-87】修正置顶时对es的修改逻辑
This commit is contained in:
@@ -158,6 +158,7 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
|||||||
public ServiceResponse<Boolean> top(String courseId, boolean top) {
|
public ServiceResponse<Boolean> top(String courseId, boolean top) {
|
||||||
// 1. 查询课程数据
|
// 1. 查询课程数据
|
||||||
Course course = courseDao.get(courseId);
|
Course course = courseDao.get(courseId);
|
||||||
|
Map<String, Object> fieldMap = new HashMap<>();
|
||||||
if (top) {
|
if (top) {
|
||||||
// 2. 执行置顶操作
|
// 2. 执行置顶操作
|
||||||
// 2.1 目前课程是否已置顶
|
// 2.1 目前课程是否已置顶
|
||||||
@@ -172,10 +173,14 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
|||||||
return ServiceResponse.failure("最多只能置顶10个课程");
|
return ServiceResponse.failure("最多只能置顶10个课程");
|
||||||
}
|
}
|
||||||
// 2.3 设置置顶
|
// 2.3 设置置顶
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
courseDao.updateMultiFieldById(courseId,
|
courseDao.updateMultiFieldById(courseId,
|
||||||
UpdateBuilder.create("isTop", top),
|
UpdateBuilder.create("isTop", top),
|
||||||
UpdateBuilder.create("topTime", LocalDateTime.now()),
|
UpdateBuilder.create("topTime", now),
|
||||||
UpdateBuilder.create("sortWeight", 0));
|
UpdateBuilder.create("sortWeight", 0));
|
||||||
|
fieldMap.put("isTop", 1);
|
||||||
|
fieldMap.put("topTime", now);
|
||||||
|
fieldMap.put("sortWeight", 0);
|
||||||
} else {
|
} else {
|
||||||
// 3. 取消置顶
|
// 3. 取消置顶
|
||||||
// 3.1 课程是否已置顶
|
// 3.1 课程是否已置顶
|
||||||
@@ -189,12 +194,14 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
|||||||
UpdateBuilder.create("isTop", top),
|
UpdateBuilder.create("isTop", top),
|
||||||
UpdateBuilder.create("topTime", null),
|
UpdateBuilder.create("topTime", null),
|
||||||
UpdateBuilder.create("sortWeight", 9999));
|
UpdateBuilder.create("sortWeight", 9999));
|
||||||
|
fieldMap.put("isTop", 0);
|
||||||
|
fieldMap.put("sortWeight", 9999);
|
||||||
}
|
}
|
||||||
// ES同步
|
// ES同步
|
||||||
if (this.fullTextSearch != null) {
|
if (this.fullTextSearch != null) {
|
||||||
Object fullId = courseDao.findField("fullTextId", FieldFilters.eq("id", courseId));
|
Object fullId = courseDao.findField("fullTextId", FieldFilters.eq("id", courseId));
|
||||||
if (fullId != null) {
|
if (fullId != null) {
|
||||||
publishUtil.updateFieldByDocId((String) fullId, "isTop", top ? 1 : 0);
|
publishUtil.updateFieldByDocId((String) fullId, fieldMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ServiceResponse.success(true);
|
return ServiceResponse.success(true);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.xboe.module.course.service.impl;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
@@ -123,6 +124,14 @@ public class PublishCourseUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateFieldByDocId(String docId, Map<String, Object> fieldMap) {
|
||||||
|
try {
|
||||||
|
fullTextSearch.updateFields(ICourseFullTextSearch.DEFAULT_INDEX_NAME, fieldMap, docId);
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("更新全文索引字段错误",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeByDocId(String docId){
|
public void removeByDocId(String docId){
|
||||||
if(fullTextSearch==null) {
|
if(fullTextSearch==null) {
|
||||||
log.error("未实现全文检索的接口:"+ICourseFullTextSearch.class);
|
log.error("未实现全文检索的接口:"+ICourseFullTextSearch.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user