mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
模糊查询
This commit is contained in:
@@ -11,6 +11,9 @@ import com.boe.feign.api.serverall.entity.UserData;
|
|||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.xboe.api.ThirdApi;
|
import com.xboe.api.ThirdApi;
|
||||||
|
import com.xboe.core.orm.FieldFilters;
|
||||||
|
import com.xboe.core.orm.IFieldFilter;
|
||||||
|
import com.xboe.core.orm.QueryBuilder;
|
||||||
import com.xboe.data.outside.IOutSideDataService;
|
import com.xboe.data.outside.IOutSideDataService;
|
||||||
import com.xboe.module.course.entity.CourseTag;
|
import com.xboe.module.course.entity.CourseTag;
|
||||||
import com.xboe.module.course.service.*;
|
import com.xboe.module.course.service.*;
|
||||||
@@ -318,10 +321,23 @@ public class CourseFullTextApi extends ApiBaseController{
|
|||||||
String tagName = dto.getKeyword();
|
String tagName = dto.getKeyword();
|
||||||
log.info("课程查询 关键字 = " + tagName);
|
log.info("课程查询 关键字 = " + tagName);
|
||||||
if (StringUtils.isNotEmpty(tagName)){
|
if (StringUtils.isNotEmpty(tagName)){
|
||||||
CourseTag courseTag = courseTagService.getTagByName(tagName);
|
//精准查询
|
||||||
log.info("课程查询 关键字对应标签 = " + courseTag);
|
// CourseTag courseTag = courseTagService.getTagByName(tagName);
|
||||||
if (courseTag != null){
|
// log.info("课程查询 关键字对应标签 = " + courseTag);
|
||||||
paras.setTags(courseTag.getId());
|
// if (courseTag != null){
|
||||||
|
// paras.setTags(courseTag.getId());
|
||||||
|
// }
|
||||||
|
// 获取所有标签并进行模糊匹配
|
||||||
|
List<CourseTag> allTags = courseTagService.getAllTags();
|
||||||
|
List<String> matchedTagIds = new ArrayList<>();
|
||||||
|
for (CourseTag tag : allTags) {
|
||||||
|
// 使用模糊匹配(不区分大小写)
|
||||||
|
if (tag.getTagName() != null && tag.getTagName().toLowerCase().contains(tagName.toLowerCase())) {
|
||||||
|
matchedTagIds.add(tag.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!matchedTagIds.isEmpty()) {
|
||||||
|
paras.setTags(String.join(",", matchedTagIds));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,4 +92,6 @@ public interface ICourseTagService {
|
|||||||
CourseTag getTagByName(String tagName);
|
CourseTag getTagByName(String tagName);
|
||||||
|
|
||||||
void updateTags(Course oldCourse,Course newCourse,CurrentUser userInfo);
|
void updateTags(Course oldCourse,Course newCourse,CurrentUser userInfo);
|
||||||
|
|
||||||
|
List<CourseTag> getAllTags();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,6 +424,17 @@ public class CourseTagServiceImpl implements ICourseTagService {
|
|||||||
log.info("完成课程标签更新: courseId={}", newCourse != null ? newCourse.getId() : "null");
|
log.info("完成课程标签更新: courseId={}", newCourse != null ? newCourse.getId() : "null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CourseTag> getAllTags() {
|
||||||
|
QueryBuilder query=QueryBuilder.from(CourseTag.class);
|
||||||
|
List<IFieldFilter> filters = new ArrayList<>();
|
||||||
|
filters.add(FieldFilters.eq("deleted",false));//未删除
|
||||||
|
filters.add(FieldFilters.eq("status",0));//正式标签
|
||||||
|
query.addFilters(filters);
|
||||||
|
List<CourseTag> courseTagList = courseTagDao.findList(query.builder());
|
||||||
|
return courseTagList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从课程对象中提取标签ID列表
|
* 从课程对象中提取标签ID列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user