mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
修复前台热点标签10个位置,从热点池中选取前10,筛选和排序规则:1)手动标记热点的标签按标记时间倒序排列 2)关联课程数量>4门的标签,按关联课程数量多少倒序排列。如1)和2)合计不足10个,则前台根据实际数量显示。
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user