mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-13 21:06:48 +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) {
|
||||
// 1. 查询课程数据
|
||||
Course course = courseDao.get(courseId);
|
||||
Map<String, Object> fieldMap = new HashMap<>();
|
||||
if (top) {
|
||||
// 2. 执行置顶操作
|
||||
// 2.1 目前课程是否已置顶
|
||||
@@ -172,10 +173,14 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
||||
return ServiceResponse.failure("最多只能置顶10个课程");
|
||||
}
|
||||
// 2.3 设置置顶
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
courseDao.updateMultiFieldById(courseId,
|
||||
UpdateBuilder.create("isTop", top),
|
||||
UpdateBuilder.create("topTime", LocalDateTime.now()),
|
||||
UpdateBuilder.create("topTime", now),
|
||||
UpdateBuilder.create("sortWeight", 0));
|
||||
fieldMap.put("isTop", 1);
|
||||
fieldMap.put("topTime", now);
|
||||
fieldMap.put("sortWeight", 0);
|
||||
} else {
|
||||
// 3. 取消置顶
|
||||
// 3.1 课程是否已置顶
|
||||
@@ -189,12 +194,14 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
||||
UpdateBuilder.create("isTop", top),
|
||||
UpdateBuilder.create("topTime", null),
|
||||
UpdateBuilder.create("sortWeight", 9999));
|
||||
fieldMap.put("isTop", 0);
|
||||
fieldMap.put("sortWeight", 9999);
|
||||
}
|
||||
// ES同步
|
||||
if (this.fullTextSearch != null) {
|
||||
Object fullId = courseDao.findField("fullTextId", FieldFilters.eq("id", courseId));
|
||||
if (fullId != null) {
|
||||
publishUtil.updateFieldByDocId((String) fullId, "isTop", top ? 1 : 0);
|
||||
publishUtil.updateFieldByDocId((String) fullId, fieldMap);
|
||||
}
|
||||
}
|
||||
return ServiceResponse.success(true);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xboe.module.course.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@@ -122,6 +123,14 @@ public class PublishCourseUtil {
|
||||
log.error("更新全文索引字段错误",e);
|
||||
}
|
||||
}
|
||||
|
||||
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){
|
||||
if(fullTextSearch==null) {
|
||||
|
||||
Reference in New Issue
Block a user