From 65340be4da8f35cfb8e5e6d4870e8a7605e4a1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 2 Dec 2020 10:20:09 +0800 Subject: [PATCH] aa --- business/jxstore/cms/job.go | 4 ++-- business/jxstore/cms/user2.go | 29 ++++++++++++++++++++--------- business/model/dao/dao_job.go | 6 ++---- business/model/user.go | 8 ++++---- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/business/jxstore/cms/job.go b/business/jxstore/cms/job.go index 4a1ff2871..0fa5fe0ad 100644 --- a/business/jxstore/cms/job.go +++ b/business/jxstore/cms/job.go @@ -211,8 +211,8 @@ func GetJobs(ctx *jxcontext.Context, userIDs []string, categoryIDs, statuss, ven dao.UpdateEntity(db, userSearchs[0], "Count", "UpdatedAt") } else { userSearch := &model.UserSearch{ - UserID: userID, - Key: keyword, + UserID: userID, + Keyword: keyword, } dao.WrapAddIDCULEntity(userSearch, ctx.GetUserName()) dao.CreateEntity(db, userSearch) diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index 6dc6fdd9d..37416d727 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -741,13 +741,24 @@ type GetUserSerachKeywordResult struct { UserSpan []*model.UserSearch `json:"userSpan"` } -func GetUserSerachKeyword(ctx *jxcontext.Context) (err error) { - // var ( - // db = dao.GetDB() - // userID = ctx.GetUserID() - // ) - // sql := ` - // SELECT SUM(count) count FROM user_search WHERE - // ` - return err +func GetUserSerachKeyword(ctx *jxcontext.Context) (getUserSerachKeywordResult *GetUserSerachKeywordResult, err error) { + var ( + db = dao.GetDB() + userID = ctx.GetUserID() + userSearchAll []*model.UserSearch + userSearch []*model.UserSearch + ) + sql := ` + SELECT keyword, SUM(count) count FROM user_search WHERE created_at > ? GROUP 1 ORDER BY SUM(count) DESC LIMIT 20 + ` + sqlParams := []interface{}{time.Now().AddDate(0, -1, 0)} + err = dao.GetRows(db, &userSearchAll, sql, sqlParams) + getUserSerachKeywordResult.AllSpan = userSearchAll + sql2 := ` + SELECT keyword, SUM(count) count FROM user_search WHERE created_at > ? AND user_id = ? GROUP 1 ORDER BY SUM(count) DESC LIMIT 20 + ` + sqlParams2 := []interface{}{time.Now().AddDate(0, -1, 0), userID} + err = dao.GetRows(db, &userSearch, sql2, sqlParams2) + getUserSerachKeywordResult.UserSpan = userSearch + return getUserSerachKeywordResult, err } diff --git a/business/model/dao/dao_job.go b/business/model/dao/dao_job.go index 8ae92eb8e..2427ba9b8 100644 --- a/business/model/dao/dao_job.go +++ b/business/model/dao/dao_job.go @@ -402,15 +402,13 @@ func GetUserSearch(db *DaoDB, userID, keyword string) (userSearchs []*model.User ` sqlParams := []interface{}{} if userID != "" { - sql += ` AND user_id = ?` + sql += " AND user_id = ?" sqlParams = append(sqlParams, userID) } if keyword != "" { - sql += ` AND key = ?` + sql += " AND keyword = ?" sqlParams = append(sqlParams, keyword) } - fmt.Println(sql) - fmt.Println(sqlParams) err = GetRows(db, &userSearchs, sql, sqlParams) return userSearchs, err } diff --git a/business/model/user.go b/business/model/user.go index 703e1cbe0..f262bd8fc 100644 --- a/business/model/user.go +++ b/business/model/user.go @@ -264,14 +264,14 @@ type GetUserResult struct { type UserSearch struct { ModelIDCUL - UserID string `orm:"column(user_id)" json:"userID"` //用户ID - Key string `json:"key"` //搜索关键字 - Count int `json:"count"` //搜索次数 + UserID string `orm:"column(user_id)" json:"userID"` //用户ID + Keyword string `json:"keyword"` //搜索关键字 + Count int `json:"count"` //搜索次数 } func (v *UserSearch) TableIndex() [][]string { return [][]string{ []string{"UserID"}, - []string{"Key"}, + []string{"Keyword"}, } }