修复前台热点标签10个位置,从热点池中选取前10,筛选和排序规则:1)手动标记热点的标签按标记时间倒序排列 2)关联课程数量>4门的标签,按关联课程数量多少倒序排列。如1)和2)合计不足10个,则前台根据实际数量显示。

This commit is contained in:
王卓煜
2025-08-21 09:36:49 +08:00
parent 7074255e94
commit 9588235f87

View File

@@ -34,11 +34,13 @@ public class CourseTagDao extends BaseDao<CourseTag> {
*/
public List<CourseTag> getHotTagList() {
// 原生SQL注意表名和列名需与数据库实际一致
String sql = "SELECT c.* FROM boe_course_tag c " +
"JOIN boe_course_type_tag_relation r ON c.id = r.tag_id " +
"WHERE r.deleted = 0 " +
"AND c.is_hot = true " + // 数据库字段为is_hot与实体属性isHot对应
"ORDER BY c.last_set_hot_time DESC"; // 数据库字段为last_set_hot_time
String sql = "select t.*,COUNT(r.tag_id) AS relation_count\n" +
"from boe_course_tag t\n" +
"left join boe_course_tag_relation r\n" +
"on t.id = r.tag_id\n" +
"where t.is_hot = true\n" +
"GROUP BY t.id\n" +
"order by t.last_set_hot_time desc,relation_count desc"; // 数据库字段为last_set_hot_time
// 创建原生查询并指定结果映射到CourseTag实体
javax.persistence.Query query = entityManager.createNativeQuery(sql, CourseTag.class);