[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"article-32":3},{"id":4,"title":5,"title_en":6,"abstract":7,"abstract_en":8,"content":9,"content_en":10,"category":11,"banner_id":12,"banner_path":13,"tags":14,"is_recommend":17,"prev_article":18,"next_article":22,"created_at":26},32,"在线平台个性化推荐","Personalized recommendation on online platform","# 在线平台个性化推荐系统的设计与实现\n\n> 在当今的在线教育平台中，个性化推荐系统已成为提升用户体","#Design and implementation of personalized recommendation system on online platform\n\n> In today's online education platforms, personalized recommendation systems have become an enhanced user body","# 在线平台个性化推荐系统的设计与实现\n\n> 在当今的在线教育平台中，个性化推荐系统已成为提升用户体验和增加用户粘性的关键技术之一。本文将介绍一个基于Go语言和Gin框架构建的课程推荐系统，该系统已在企业级在线教育平台中成功应用。\n\n## 系统架构概述\n\n该推荐系统采用分层架构设计，主要包括以下几个核心组件：\n\n1. **API层** - 提供RESTful接口供前端调用\n2. **Service层** - 实现推荐算法和业务逻辑\n3. **Model层** - 定义数据结构和数据库交互\n4. **定时任务** - 定期生成推荐数据\n\n## 核心功能实现\n\n### 1. 推荐算法设计\n\n推荐算法采用多维度评分机制，综合考虑以下三个方面的因素：\n\n#### 内容质量分 (0-40分)\n```go\n\u002F\u002F 内容质量分\nfunc getQualityScore(courseID uint) float64 {\n    var course models.CourseModel\n    global.DB.Take(&course, courseID)\n\n    score := 0.0\n    \u002F\u002F 学习人数权重\n    score += math.Min(float64(course.StudentCount)\u002F100, 20)\n    \u002F\u002F 是否完成章节\n    if len(course.Chapters) > 0 {\n        score += 10\n    }\n    \u002F\u002F 是否有标签\n    if len(course.Tags) > 0 {\n        score += 10\n    }\n\n    return score\n}\n```\n\n#### 个性化匹配分 (0-40分)\n```go\n\u002F\u002F 个性化匹配分\nfunc getPersonalizedScore(userID, courseID uint) float64 {\n    score := 0.0\n\n    \u002F\u002F 分类匹配(15分)\n    score += getCategoryMatchScore(userID, courseID)\n\n    \u002F\u002F 标签匹配(15分)\n    score += getTagMatchScore(userID, courseID)\n\n    \u002F\u002F VIP权益匹配(10分)\n    score += getVIPMatchScore(userID, courseID)\n\n    return score\n}\n```\n\n#### 热度分 (0-20分)\n```go\n\u002F\u002F 热度分\nfunc getPopularityScore(courseID uint) float64 {\n    var course models.CourseModel\n    global.DB.Take(&course, courseID)\n\n    \u002F\u002F 基于学习人数的热度分\n    return math.Min(float64(course.StudentCount)\u002F50, 20)\n}\n```\n\n### 2. 定时任务生成推荐\n\n系统通过定时任务定期为活跃用户生成个性化推荐：\n\n```go\nconst RecommendCourseSchedule string = \"0 0 2 * * 0\" \u002F\u002F 每周日凌晨2点执行\n\nfunc GenerateRecommendations() {\n    \u002F\u002F 获取所有活跃用户(最近30天有学习记录）\n    var userIDs []uint\n    global.DB.Model(&models.EnrollModel{}).\n        Where(\"updated_at > ?\", time.Now().AddDate(0, 0, -30)).\n        Distinct(\"user_id\").\n        Pluck(\"user_id\", &userIDs)\n\n    for _, userID := range userIDs {\n        generateUserRecommendations(userID)\n    }\n}\n```\n\n### 3. API接口实现\n\n推荐系统提供RESTful API接口供前端调用：\n\n```go\nfunc (RecommendApi) RecommendCourseView(c *gin.Context) {\n    claims := middleware.GetAuth(c)\n\n    var recommends []models.RecommendModel\n    if err := global.DB.Preload(\"Course.Teacher\").\n        Where(\"user_id = ? AND is_consumed = false AND expire_at > ?\", claims.UserID, time.Now()).\n        Order(\"score Desc\").\n        Limit(5).Find(&recommends).Error; err != nil {\n        global.Log.Error(\"获取推荐失败\", zap.Error(err))\n        res.InternalError(\"获取推荐失败\", c)\n        return\n    }\n    \u002F\u002F ... 处理响应数据\n}\n```\n\n## 系统特点\n\n1. **个性化推荐** - 基于用户学习历史、兴趣标签和VIP权益进行个性化匹配\n2. **实时更新** - 通过定时任务定期更新推荐数据，保证推荐内容的新鲜度\n3. **高性能** - 采用预计算方式，避免实时计算带来的性能问题\n4. **可解释性** - 每个推荐都附带推荐理由，提升用户信任度\n\n## 总结\n\n该推荐系统通过多维度评分机制实现了精准的个性化推荐，有效提升了用户的学习体验和平台的用户粘性。系统架构清晰，易于维护和扩展，为在线教育平台的智能化运营提供了有力支撑。\n\n通过合理运用用户行为数据和内容特征，该推荐系统能够持续优化推荐效果，为用户提供更加精准和个性化的学习内容推荐。","#Design and implementation of personalized recommendation system on online platform\n\n> In today's online education platforms, personalized recommendation systems have become one of the key technologies to improve user experience and increase user stickiness. This article will introduce a course recommendation system based on Go language and Gin framework, which has been successfully applied in enterprise-level online education platforms.\n\n##System Architecture Overview\n\nThe recommendation system adopts a hierarchical architecture design and mainly includes the following core components:\n\n1. **API layer ** -Provides a RESTful interface for front-end calls\n2. **Service layer ** -implements recommendation algorithms and business logic\n3. **Model layer ** -defines data structures and database interactions\n4. ** Scheduled tasks ** -Generate recommendation data regularly\n\n##Implementation of core functions\n\n### 1. Recommendation algorithm design\n\nThe recommendation algorithm adopts a multi-dimensional scoring mechanism, comprehensively considering the following three factors:\n\n####Content quality score (0-40 points)\n```go\n\u002F\u002FContent quality score\nfunc getQualityScore(courseID uint) float64 {\n    var course models.CourseModel\n    global.DB.Take(&course, courseID)\n\n    score := 0.0\n    \u002F\u002FWeight of learners\n    score += math.Min(float64(course.StudentCount)\u002F100, 20)\n    \u002F\u002FWhether to complete the chapter\n    if len(course.Chapters) > 0 {\n        score += 10\n    }\n    \u002F\u002FWhether there is a label\n    if len(course.Tags) > 0 {\n        score += 10\n    }\n\n    return score\n}\n```\n\n####Personalized matching score (0-40 points)\n```go\n\u002F\u002FPersonalized matching points\nfunc getPersonalizedScore(userID, courseID uint) float64 {\n    score := 0.0\n\n    \u002F\u002FCategory matching (15 points)\n    score += getCategoryMatchScore(userID, courseID)\n\n    \u002F\u002FTag match (15 points)\n    score += getTagMatchScore(userID, courseID)\n\n    \u002F\u002F VIP rights matching (10 points)\n    score += getVIPMatchScore(userID, courseID)\n\n    return score\n}\n```\n\n####Heat score (0-20 points)\n```go\n\u002F\u002FHeat score\nfunc getPopularityScore(courseID uint) float64 {\n    var course models.CourseModel\n    global.DB.Take(&course, courseID)\n\n    \u002F\u002Fpopularity score based on number of learners\n    return math.Min(float64(course.StudentCount)\u002F50, 20)\n}\n```\n\n### 2. Timing task generation recommendations\n\nThe system regularly generates personalized recommendations for active users through scheduled tasks:\n\n```go\nconst Recommended CourseSchedule string = \"0 0 2 * * 0\" \u002F\u002FExecuted at 2 a.m. every Sunday\n\nfunc GenerateRecommendations() {\n    \u002F\u002FGet all active users (with learning records in the last 30 days)\n    var userIDs []uint\n    global.DB.Model(&models.EnrollModel{}).\n        Where(\"updated_at > ? \", time.Now().AddDate(0, 0, -30)).\n        Distinct(\"user_id\").\n        Pluck(\"user_id\", &userIDs)\n\n    for _, userID := range userIDs {\n        generateUserRecommendations(userID)\n    }\n}\n```\n\n### 3. API interface implementation\n\nThe recommendation system provides a RESTful API interface for front-end calls:\n\n```go\nfunc (RecommendApi) RecommendCourseView(c *gin.Context) {\n    claims := middleware.GetAuth(c)\n\n    var recommends []models.RecommendModel\n    if err := global.DB.Preload(\"Course.Teacher\").\n        Where(\"user_id = ? AND is_consumed = false AND expire_at > ? \", claims.UserID, time.Now()).\n        Order(\"score Desc\").\n        Limit(5).Find(&recommends).Error; err != nil {\n        global.Log.Error(\"Failed to get recommendations\", zap.Error(err))\n        res.InternalError(\"Failed to get recommendation\", c)\n        return\n    }\n    \u002F\u002F ... Processing response data\n}\n```\n\n##System characteristics\n\n1. ** Personalized recommendation ** -Personalized matching based on user learning history, interest tags and VIP rights\n2. ** Real-time update ** -Regularly update recommendation data through scheduled tasks to ensure the freshness of recommended content\n3. ** High performance ** -Adopt pre-calculation method to avoid performance problems caused by real-time computing\n4. ** Interpretability ** -Each recommendation comes with a recommendation reason to increase user trust\n\n##Summary\n\nThe recommendation system achieves accurate personalized recommendations through a multi-dimensional scoring mechanism, effectively improving the user's learning experience and the user stickiness of the platform. The system architecture is clear, easy to maintain and expand, providing strong support for the intelligent operation of online education platforms.\n\nBy rationally using user behavior data and content characteristics, the recommendation system can continuously optimize the recommendation effect and provide users with more accurate and personalized learning content recommendations.","go",36,"https:\u002F\u002Fblog4-1316398321.cos.ap-nanjing.myqcloud.com\u002Fblog5\u002F20260623050840__WLOP-.png",[15,16],"Gin","GO",false,{"id":19,"title":20,"title_en":21},31,"Docker 部署 Elasticsearch 8.x","Docker Deployment of Elasticsearch 8.x",{"id":23,"title":24,"title_en":25},34,"我用 LiveKit Agents 搭了一个全双工 AI 语音助理：从选型到落地的完整思考","I built a full-duplex AI voice assistant using LiveKit Agents: A complete reflection from selection to implementation","2025-11-04T02:44:12+08:00"]