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",
"request": "launch",
"mode": "exec",
"program": "${fileDirname}/__debug_bin",
"program": "${workspaceFolder}/.vscode/__debug_bin",
"preLaunchTask": "go: build (debug)",
"cwd": "${workspaceFolder}"
}

@ -7,7 +7,7 @@ require (
github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868
github.com/alimy/cfg v0.3.0
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/allegro/bigcache/v3 v3.0.2
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/mir/v3 v3.1.1 h1:3tz7uGOwuA1IKU0BysyBvGbyqKtEVMuhPBD/APk1ANw=
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.2.0/go.mod h1:Y0FdRIwIbJyTv56wSX+MpaIHiAW1PyKTDYO6K/er4JY=
github.com/alimy/yesql v0.3.0 h1:KKjDBaDIrWoKor3E2XRc/wtnA6ZIZdScevpQaYizqmo=
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/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
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)
}
// 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() {
_db = conf.MustSqlxDB()
yesql.UseSqlx(_db)

@ -12,7 +12,6 @@ import (
"github.com/jmoiron/sqlx"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/sirupsen/logrus"
)
var (
@ -21,17 +20,17 @@ var (
type topicSrv struct {
*sqlxSrv
Scope yesql.Scope `yesql:"topic"`
StmtNewestTags *sqlx.Stmt `yesql:"newest_tags"`
StmtHotTags *sqlx.Stmt `yesql:"hot_tags"`
StmtTagsByKeywordA *sqlx.Stmt `yesql:"tags_by_keyword_a"`
StmtTagsByKeywordB *sqlx.Stmt `yesql:"tags_by_keyword_b"`
StmtInsertTag *sqlx.Stmt `yesql:"insert_tag"`
SqlTagsByIdA string `yesql:"tags_by_id_a"`
SqlTagsByIdB string `yesql:"tags_by_id_b"`
SqlDecrTagsById string `yesql:"decr_tags_by_id"`
SqlTagsForIncr string `yesql:"tags_for_incr"`
SqlIncrTagsById string `yesql:"incr_tags_by_id"`
yesql.Namespace `yesql:"topic"`
StmtNewestTags *sqlx.Stmt `yesql:"newest_tags"`
StmtHotTags *sqlx.Stmt `yesql:"hot_tags"`
StmtTagsByKeywordA *sqlx.Stmt `yesql:"tags_by_keyword_a"`
StmtTagsByKeywordB *sqlx.Stmt `yesql:"tags_by_keyword_b"`
StmtInsertTag *sqlx.Stmt `yesql:"insert_tag"`
SqlTagsByIdA string `yesql:"tags_by_id_a"`
SqlTagsByIdB string `yesql:"tags_by_id_b"`
SqlDecrTagsById string `yesql:"decr_tags_by_id"`
SqlTagsForIncr string `yesql:"tags_for_incr"`
SqlIncrTagsById string `yesql:"incr_tags_by_id"`
}
func (s *topicSrv) UpsertTags(userId int64, tags []string) (res cs.TagInfoList, xerr error) {
@ -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 {
obj := &topicSrv{
return yesqlScan(query, &topicSrv{
sqlxSrv: newSqlxSrv(db),
}
if err := yesql.Scan(obj, query); err != nil {
logrus.Fatal(err)
}
return obj
})
}

Loading…
Cancel
Save