upgrade github.com/alimy/yesql => v0.3.0

r/paopao-ce-xtra
Michael Li 2 years ago
parent f890e647d3
commit 375c761b24
No known key found for this signature in database

@ -6,7 +6,7 @@
"type": "go", "type": "go",
"request": "launch", "request": "launch",
"mode": "exec", "mode": "exec",
"program": "${fileDirname}/__debug_bin", "program": "${workspaceFolder}/.vscode/__debug_bin",
"preLaunchTask": "go: build (debug)", "preLaunchTask": "go: build (debug)",
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
} }

@ -7,7 +7,7 @@ require (
github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868 github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868
github.com/alimy/cfg v0.3.0 github.com/alimy/cfg v0.3.0
github.com/alimy/mir/v3 v3.1.1 github.com/alimy/mir/v3 v3.1.1
github.com/alimy/yesql v0.2.0 github.com/alimy/yesql v0.3.0
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible
github.com/allegro/bigcache/v3 v3.0.2 github.com/allegro/bigcache/v3 v3.0.2
github.com/bytedance/sonic v1.8.5 github.com/bytedance/sonic v1.8.5

@ -127,8 +127,8 @@ github.com/alimy/cfg v0.3.0 h1:9xgA0QWVCPSq9fFNRcYahVCAX22IL9ts2wrTQPfAStY=
github.com/alimy/cfg v0.3.0/go.mod h1:rOxbasTH2srl6StAjNF5Vyi8bfrdkl3fLGmOYtSw81c= github.com/alimy/cfg v0.3.0/go.mod h1:rOxbasTH2srl6StAjNF5Vyi8bfrdkl3fLGmOYtSw81c=
github.com/alimy/mir/v3 v3.1.1 h1:3tz7uGOwuA1IKU0BysyBvGbyqKtEVMuhPBD/APk1ANw= github.com/alimy/mir/v3 v3.1.1 h1:3tz7uGOwuA1IKU0BysyBvGbyqKtEVMuhPBD/APk1ANw=
github.com/alimy/mir/v3 v3.1.1/go.mod h1:ybhT2ijOiDn0lLwWzIY6vXdv+uzZrctS7VFfczcXBWU= github.com/alimy/mir/v3 v3.1.1/go.mod h1:ybhT2ijOiDn0lLwWzIY6vXdv+uzZrctS7VFfczcXBWU=
github.com/alimy/yesql v0.2.0 h1:tYDPxWSakSUOss1xcYisRjDH//GnUunvlrfB4Ek8ikQ= github.com/alimy/yesql v0.3.0 h1:KKjDBaDIrWoKor3E2XRc/wtnA6ZIZdScevpQaYizqmo=
github.com/alimy/yesql v0.2.0/go.mod h1:Y0FdRIwIbJyTv56wSX+MpaIHiAW1PyKTDYO6K/er4JY= github.com/alimy/yesql v0.3.0/go.mod h1:Y0FdRIwIbJyTv56wSX+MpaIHiAW1PyKTDYO6K/er4JY=
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible h1:KXeJoM1wo9I/6xPTyt6qCxoSZnmASiAjlrr0dyTUKt8= github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible h1:KXeJoM1wo9I/6xPTyt6qCxoSZnmASiAjlrr0dyTUKt8=
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/allegro/bigcache/v3 v3.0.2 h1:AKZCw+5eAaVyNTBmI2fgyPVJhHkdWder3O9IrprcQfI= github.com/allegro/bigcache/v3 v3.0.2 h1:AKZCw+5eAaVyNTBmI2fgyPVJhHkdWder3O9IrprcQfI=

@ -116,6 +116,14 @@ func t(query string) string {
return strings.Replace(query, "@", conf.DatabaseSetting.TablePrefix, -1) return strings.Replace(query, "@", conf.DatabaseSetting.TablePrefix, -1)
} }
// yesqlScan yesql.Scan help function
func yesqlScan[T any](query yesql.SQLQuery, obj T) T {
if err := yesql.Scan(obj, query); err != nil {
logrus.Fatal(err)
}
return obj
}
func initSqlxDB() { func initSqlxDB() {
_db = conf.MustSqlxDB() _db = conf.MustSqlxDB()
yesql.UseSqlx(_db) yesql.UseSqlx(_db)

@ -12,7 +12,6 @@ import (
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
"github.com/rocboss/paopao-ce/internal/core" "github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs" "github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/sirupsen/logrus"
) )
var ( var (
@ -21,7 +20,7 @@ var (
type topicSrv struct { type topicSrv struct {
*sqlxSrv *sqlxSrv
Scope yesql.Scope `yesql:"topic"` yesql.Namespace `yesql:"topic"`
StmtNewestTags *sqlx.Stmt `yesql:"newest_tags"` StmtNewestTags *sqlx.Stmt `yesql:"newest_tags"`
StmtHotTags *sqlx.Stmt `yesql:"hot_tags"` StmtHotTags *sqlx.Stmt `yesql:"hot_tags"`
StmtTagsByKeywordA *sqlx.Stmt `yesql:"tags_by_keyword_a"` StmtTagsByKeywordA *sqlx.Stmt `yesql:"tags_by_keyword_a"`
@ -124,11 +123,7 @@ func (s *topicSrv) TagsByKeyword(keyword string) (res cs.TagInfoList, err error)
} }
func newTopicService(db *sqlx.DB, query yesql.SQLQuery) core.TopicService { func newTopicService(db *sqlx.DB, query yesql.SQLQuery) core.TopicService {
obj := &topicSrv{ return yesqlScan(query, &topicSrv{
sqlxSrv: newSqlxSrv(db), sqlxSrv: newSqlxSrv(db),
} })
if err := yesql.Scan(obj, query); err != nil {
logrus.Fatal(err)
}
return obj
} }

Loading…
Cancel
Save