diff --git a/go.mod b/go.mod index 8ed19b5e..cf285972 100644 --- a/go.mod +++ b/go.mod @@ -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/v4 v4.0.0-rc.1 - github.com/alimy/yesql v1.2.0 + github.com/alimy/yesql v1.3.0 github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible github.com/allegro/bigcache/v3 v3.1.0 github.com/bytedance/sonic v1.9.2 diff --git a/go.sum b/go.sum index 329a47e5..5f1eba08 100644 --- a/go.sum +++ b/go.sum @@ -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/v4 v4.0.0-rc.1 h1:x9rKbD6I4INqwvgmSI4Vbswff66ANDnPmCySMLzEV4w= github.com/alimy/mir/v4 v4.0.0-rc.1/go.mod h1:d58dBvw2KImcVbAUANrciEV/of0arMNsI9c/5UNCMMc= -github.com/alimy/yesql v1.2.0 h1:yWa4kYk/7E2iYtS/4xvjlKQvGsfRhAHqr58s5Sig33A= -github.com/alimy/yesql v1.2.0/go.mod h1:Y0FdRIwIbJyTv56wSX+MpaIHiAW1PyKTDYO6K/er4JY= +github.com/alimy/yesql v1.3.0 h1:4/p097ZvFMlIzm1CWYy1q+eBQH0DcqlB+/UxKTHsj30= +github.com/alimy/yesql v1.3.0/go.mod h1:Y0FdRIwIbJyTv56wSX+MpaIHiAW1PyKTDYO6K/er4JY= github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible h1:KpbJFXwhVeuxNtBJ74MCGbIoaBok2uZvkD7QXp2+Wis= github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk= diff --git a/internal/dao/sakila/sqlx.go b/internal/dao/sakila/sqlx.go index 4e6b440c..32af8c1a 100644 --- a/internal/dao/sakila/sqlx.go +++ b/internal/dao/sakila/sqlx.go @@ -151,6 +151,15 @@ func mustBuild[T any](db *sqlx.DB, fn func(yesql.PreparexBuilder, ...context.Con return obj } +func mustBuildFn[T any](db *sqlx.DB, fn func(yesql.PreparexBuilder) (T, error)) T { + p := yesql.NewPreparexBuilder(db, t) + obj, err := fn(p) + if err != nil { + logrus.Fatalf("build object failure: %s", err) + } + return obj +} + func initSqlxDB() { _db = conf.MustSqlxDB() _tablePrefix = conf.DatabaseSetting.TablePrefix diff --git a/internal/dao/sakila/tweets.go b/internal/dao/sakila/tweets.go index b2db0c76..78cb37f4 100644 --- a/internal/dao/sakila/tweets.go +++ b/internal/dao/sakila/tweets.go @@ -467,7 +467,7 @@ func newTweetManageService(db *sqlx.DB, cacheIndex core.CacheIndexService) core. func newTweetHelpService(db *sqlx.DB) core.TweetHelpService { return &tweetHelpSrv{ sqlxSrv: newSqlxSrv(db), - q: mustBuild(db, cc.BuildTweetHelp), + q: mustBuildFn(db, cc.BuildTweetHelp), } } diff --git a/internal/dao/sakila/yesql/cc/yesql.go b/internal/dao/sakila/yesql/cc/yesql.go index 78351e25..f5544e76 100644 --- a/internal/dao/sakila/yesql/cc/yesql.go +++ b/internal/dao/sakila/yesql/cc/yesql.go @@ -1,6 +1,6 @@ // Code generated by Yesql. DO NOT EDIT. // versions: -// - Yesql v1.2.0 +// - Yesql v1.3.0 package cc @@ -596,13 +596,7 @@ func BuildTweetA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *TweetA, return } -func BuildTweetHelp(p yesql.PreparexBuilder, ctx ...context.Context) (obj *TweetHelp, err error) { - var c context.Context - if len(ctx) > 0 && ctx[0] != nil { - c = ctx[0] - } else { - c = context.Background() - } +func BuildTweetHelp(p yesql.PreparexBuilder) (obj *TweetHelp, err error) { obj = &TweetHelp{ GetPostContentByIds: p.QueryHook(_GetPostContentByIds_TweetHelp), GetUsersByIds: p.QueryHook(_GetUsersByIds_TweetHelp),