From 9588235f872c852c76c98d834d97727bf16cbe1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8D=93=E7=85=9C?= <2210102150@qq.com> Date: Thu, 21 Aug 2025 09:36:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=89=8D=E5=8F=B0=E7=83=AD?= =?UTF-8?q?=E7=82=B9=E6=A0=87=E7=AD=BE10=E4=B8=AA=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=EF=BC=8C=E4=BB=8E=E7=83=AD=E7=82=B9=E6=B1=A0=E4=B8=AD=E9=80=89?= =?UTF-8?q?=E5=8F=96=E5=89=8D10=EF=BC=8C=E7=AD=9B=E9=80=89=E5=92=8C?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E8=A7=84=E5=88=99=EF=BC=9A1=EF=BC=89?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E6=A0=87=E8=AE=B0=E7=83=AD=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=8C=89=E6=A0=87=E8=AE=B0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=80=92=E5=BA=8F=E6=8E=92=E5=88=97=202=EF=BC=89=E5=85=B3?= =?UTF-8?q?=E8=81=94=E8=AF=BE=E7=A8=8B=E6=95=B0=E9=87=8F>4=E9=97=A8?= =?UTF-8?q?=E7=9A=84=E6=A0=87=E7=AD=BE=EF=BC=8C=E6=8C=89=E5=85=B3=E8=81=94?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=95=B0=E9=87=8F=E5=A4=9A=E5=B0=91=E5=80=92?= =?UTF-8?q?=E5=BA=8F=E6=8E=92=E5=88=97=E3=80=82=E5=A6=821=EF=BC=89?= =?UTF-8?q?=E5=92=8C2=EF=BC=89=E5=90=88=E8=AE=A1=E4=B8=8D=E8=B6=B310?= =?UTF-8?q?=E4=B8=AA=EF=BC=8C=E5=88=99=E5=89=8D=E5=8F=B0=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E6=95=B0=E9=87=8F=E6=98=BE=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xboe/module/course/dao/CourseTagDao.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/servers/boe-server-all/src/main/java/com/xboe/module/course/dao/CourseTagDao.java b/servers/boe-server-all/src/main/java/com/xboe/module/course/dao/CourseTagDao.java index a3665887..d3e347a9 100644 --- a/servers/boe-server-all/src/main/java/com/xboe/module/course/dao/CourseTagDao.java +++ b/servers/boe-server-all/src/main/java/com/xboe/module/course/dao/CourseTagDao.java @@ -34,11 +34,13 @@ public class CourseTagDao extends BaseDao { */ public List 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);