sqlx: add timeline logic implement WIP: 90%

r/paopao-ce-plus
Michael Li 2 years ago
parent 5cb550f186
commit 45d0318c4d
No known key found for this signature in database

@ -56,23 +56,11 @@ func NewDataService() (core.DataService, core.VersionInfo) {
var ( var (
v core.VersionInfo v core.VersionInfo
cis core.CacheIndexService cis core.CacheIndexService
ips core.IndexPostsService
) )
pvs := security.NewPhoneVerifyService() pvs := security.NewPhoneVerifyService()
ams := NewAuthorizationManageService() ams := NewAuthorizationManageService()
ths := newTweetHelpService(_db) ths := newTweetHelpService(_db)
ips := newShipIndexService(_db, ams, ths)
// initialize core.IndexPostsService
if cfg.If("Friendship") {
ips = newFriendIndexService(_db, ams, ths)
} else if cfg.If("Followship") {
ips = newFollowIndexService(_db, ths)
} else if cfg.If("Lightship") {
ips = newLightIndexService(_db, ths)
} else {
// default use lightship post index service
ips = newLightIndexService(_db, ths)
}
// initialize core.CacheIndexService // initialize core.CacheIndexService
cfg.On(cfg.Actions{ cfg.On(cfg.Actions{
@ -119,23 +107,11 @@ func NewWebDataServantA() (core.WebDataServantA, core.VersionInfo) {
var ( var (
v core.VersionInfo v core.VersionInfo
cis core.CacheIndexService cis core.CacheIndexService
ips core.IndexPostsService
) )
// pvs := security.NewPhoneVerifyService() // pvs := security.NewPhoneVerifyService()
ams := NewAuthorizationManageService() ams := NewAuthorizationManageService()
ths := newTweetHelpService(_db) ths := newTweetHelpService(_db)
ips := newShipIndexService(_db, ams, ths)
// initialize core.IndexPostsService
if cfg.If("Friendship") {
ips = newFriendIndexService(_db, ams, ths)
} else if cfg.If("Followship") {
ips = newFollowIndexService(_db, ths)
} else if cfg.If("Lightship") {
ips = newLightIndexService(_db, ths)
} else {
// default use lightship post index service
ips = newLightIndexService(_db, ths)
}
// initialize core.CacheIndexService // initialize core.CacheIndexService
cfg.On(cfg.Actions{ cfg.On(cfg.Actions{

@ -39,6 +39,7 @@ func (s *sqlxSrv) with(handle func(tx *sqlx.Tx) error) error {
return tx.Commit() return tx.Commit()
} }
//lint:ignore U1000 withTx
func (s *sqlxSrv) withTx(ctx context.Context, opts *sql.TxOptions, handle func(*sqlx.Tx) error) error { func (s *sqlxSrv) withTx(ctx context.Context, opts *sql.TxOptions, handle func(*sqlx.Tx) error) error {
tx, err := s.db.BeginTxx(ctx, opts) tx, err := s.db.BeginTxx(ctx, opts)
if err != nil { if err != nil {
@ -51,6 +52,7 @@ func (s *sqlxSrv) withTx(ctx context.Context, opts *sql.TxOptions, handle func(*
return tx.Commit() return tx.Commit()
} }
//lint:ignore U1000 in
func (s *sqlxSrv) in(query string, args ...any) (string, []any, error) { func (s *sqlxSrv) in(query string, args ...any) (string, []any, error) {
q, params, err := sqlx.In(query, args...) q, params, err := sqlx.In(query, args...)
if err != nil { if err != nil {
@ -59,6 +61,7 @@ func (s *sqlxSrv) in(query string, args ...any) (string, []any, error) {
return s.db.Rebind(q), params, nil return s.db.Rebind(q), params, nil
} }
//lint:ignore U1000 inExec
func (s *sqlxSrv) inExec(query string, args ...any) (sql.Result, error) { func (s *sqlxSrv) inExec(query string, args ...any) (sql.Result, error) {
q, params, err := sqlx.In(query, args...) q, params, err := sqlx.In(query, args...)
if err != nil { if err != nil {
@ -102,6 +105,8 @@ func (s *sqlxSrv) inSelectx(queryer sqlx.Queryer, dest any, query string, args .
} }
// inGetx get for in clause with Transcation // inGetx get for in clause with Transcation
//
//lint:ignore U1000 inGetx
func (s *sqlxSrv) inGetx(queryer sqlx.Queryer, dest any, query string, args ...any) error { func (s *sqlxSrv) inGetx(queryer sqlx.Queryer, dest any, query string, args ...any) error {
q, params, err := sqlx.In(query, args...) q, params, err := sqlx.In(query, args...)
if err != nil { if err != nil {
@ -117,10 +122,12 @@ func newSqlxSrv(db *sqlx.DB) *sqlxSrv {
} }
} }
//lint:ignore U1000 r
func r(query string) string { func r(query string) string {
return _db.Rebind(t(query)) return _db.Rebind(t(query))
} }
//lint:ignore U1000 c
func c(query string) *sqlx.Stmt { func c(query string) *sqlx.Stmt {
query = _db.Rebind(t(query)) query = _db.Rebind(t(query))
stmt, err := _db.Preparex(query) stmt, err := _db.Preparex(query)
@ -130,6 +137,7 @@ func c(query string) *sqlx.Stmt {
return stmt return stmt
} }
//lint:ignore U1000 n
func n(query string) *sqlx.NamedStmt { func n(query string) *sqlx.NamedStmt {
query = t(query) query = t(query)
stmt, err := _db.PrepareNamed(query) stmt, err := _db.PrepareNamed(query)
@ -165,6 +173,8 @@ func t(query string) string {
} }
// yesqlScan yesql.Scan help function // yesqlScan yesql.Scan help function
//
//lint:ignore U1000 yesqlScan
func yesqlScan[T any](query yesql.SQLQuery, obj T) T { func yesqlScan[T any](query yesql.SQLQuery, obj T) T {
if err := yesql.Scan(obj, query); err != nil { if err := yesql.Scan(obj, query); err != nil {
logrus.Fatal(err) logrus.Fatal(err)

@ -11,37 +11,22 @@ import (
"github.com/rocboss/paopao-ce/internal/core/ms" "github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc" "github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
"github.com/rocboss/paopao-ce/pkg/debug" "github.com/rocboss/paopao-ce/pkg/debug"
"github.com/sirupsen/logrus"
) )
var ( var (
_ core.IndexPostsService = (*friendIndexSrv)(nil) _ core.IndexPostsService = (*shipIndexSrv)(nil)
_ core.IndexPostsService = (*followIndexSrv)(nil)
_ core.IndexPostsService = (*lightIndexSrv)(nil)
_ core.IndexPostsService = (*simpleIndexPostsSrv)(nil) _ core.IndexPostsService = (*simpleIndexPostsSrv)(nil)
_ core.IndexPostsServantA = (*friendIndexSrvA)(nil) _ core.IndexPostsServantA = (*shipIndexSrvA)(nil)
_ core.IndexPostsServantA = (*followIndexSrvA)(nil)
_ core.IndexPostsServantA = (*lightIndexSrvA)(nil)
_ core.IndexPostsServantA = (*simpleIndexPostsSrvA)(nil) _ core.IndexPostsServantA = (*simpleIndexPostsSrvA)(nil)
) )
type friendIndexSrv struct { type shipIndexSrv struct {
*sqlxSrv *sqlxSrv
ams core.AuthorizationManageService ams core.AuthorizationManageService
ths core.TweetHelpService ths core.TweetHelpService
q *cc.FriendIndex q *cc.ShipIndex
}
type followIndexSrv struct {
*sqlxSrv
ths core.TweetHelpService
q *cc.FollowIndex
}
type lightIndexSrv struct {
*sqlxSrv
ths core.TweetHelpService
q *cc.LightIndex
} }
type simpleIndexPostsSrv struct { type simpleIndexPostsSrv struct {
@ -50,23 +35,11 @@ type simpleIndexPostsSrv struct {
q *cc.SimpleIndex q *cc.SimpleIndex
} }
type friendIndexSrvA struct { type shipIndexSrvA struct {
*sqlxSrv *sqlxSrv
ams core.AuthorizationManageService ams core.AuthorizationManageService
ths core.TweetHelpServantA ths core.TweetHelpServantA
q *cc.FriendIndexA q *cc.ShipIndexA
}
type followIndexSrvA struct {
*sqlxSrv
ths core.TweetHelpServantA
q *cc.FollowIndexA
}
type lightIndexSrvA struct {
*sqlxSrv
ths core.TweetHelpServantA
q *cc.LightIndexA
} }
type simpleIndexPostsSrvA struct { type simpleIndexPostsSrvA struct {
@ -76,43 +49,57 @@ type simpleIndexPostsSrvA struct {
} }
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的 // IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的
func (s *friendIndexSrv) IndexPosts(user *ms.User, offset int, limit int) (*ms.IndexTweetList, error) { func (s *shipIndexSrv) IndexPosts(user *ms.User, offset int, limit int) (res *ms.IndexTweetList, err error) {
// TODO var posts []*ms.Post
return nil, debug.ErrNotImplemented res = &ms.IndexTweetList{}
switch {
case user == nil:
if err = s.q.IndexByGuest.Select(&posts, limit, offset); err == nil {
err = s.q.IndexCountByGuest.Get(&res.Total)
} }
case user != nil && user.IsAdmin:
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的 if err = s.q.IndexByAdmin.Select(&posts, limit, offset); err == nil {
func (s *followIndexSrv) IndexPosts(user *ms.User, offset int, limit int) (*ms.IndexTweetList, error) { err = s.q.IndexByAdmin.Get(&res.Total)
// TODO
return nil, debug.ErrNotImplemented
} }
default:
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的 friendIds, _ := s.ams.BeFriendIds(user.ID)
func (s *lightIndexSrv) IndexPosts(user *ms.User, offset int, limit int) (*ms.IndexTweetList, error) { friendIds = append(friendIds, user.ID)
// TODO err = s.inSelect(&posts, s.q.IndexBySelf, user.ID, friendIds, limit, offset)
return nil, debug.ErrNotImplemented if err == nil {
err = s.inGet(&res.Total, s.q.IndexCountBySelf, user.ID, friendIds)
}
}
if err != nil {
logrus.Debugf("shipIndex.IndexPosts err: %s", err)
return
}
if res.Tweets, err = s.ths.MergePosts(posts); err != nil {
logrus.Debugf("shipIndex.IndexPosts merge posts err: %s", err)
return
}
return
} }
// simpleCacheIndexGetPosts simpleCacheIndex 专属获取广场推文列表函数 // simpleCacheIndexGetPosts simpleCacheIndex 专属获取广场推文列表函数
func (s *simpleIndexPostsSrv) IndexPosts(_user *ms.User, offset int, limit int) (*ms.IndexTweetList, error) { func (s *simpleIndexPostsSrv) IndexPosts(_user *ms.User, offset int, limit int) (res *ms.IndexTweetList, err error) {
// TODO var posts []*ms.Post
return nil, debug.ErrNotImplemented res = &ms.IndexTweetList{}
if err = s.q.Index.Select(&posts, limit, offset); err == nil {
err = s.q.IndexCount.Get(&res.Total)
} }
if err != nil {
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的 logrus.Debugf("simpleIndexPostsSrv.IndexPosts err: %s", err)
func (s *friendIndexSrvA) IndexPosts(user *ms.User, limit int, offset int) (*cs.TweetBox, error) { return
// TODO
return nil, debug.ErrNotImplemented
} }
if res.Tweets, err = s.ths.MergePosts(posts); err != nil {
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的 logrus.Debugf("shipIndex.IndexPosts merge posts err: %s", err)
func (s *followIndexSrvA) IndexPosts(user *ms.User, limit int, offset int) (*cs.TweetBox, error) { return
// TODO }
return nil, debug.ErrNotImplemented return
} }
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的 // IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的
func (s *lightIndexSrvA) IndexPosts(user *ms.User, limit int, offset int) (*cs.TweetBox, error) { func (s *shipIndexSrvA) IndexPosts(user *ms.User, limit int, offset int) (*cs.TweetBox, error) {
// TODO // TODO
return nil, debug.ErrNotImplemented return nil, debug.ErrNotImplemented
} }
@ -123,28 +110,12 @@ func (s *simpleIndexPostsSrvA) IndexPosts(_user *ms.User, limit int, offset int)
return nil, debug.ErrNotImplemented return nil, debug.ErrNotImplemented
} }
func newFriendIndexService(db *sqlx.DB, ams core.AuthorizationManageService, ths core.TweetHelpService) core.IndexPostsService { func newShipIndexService(db *sqlx.DB, ams core.AuthorizationManageService, ths core.TweetHelpService) core.IndexPostsService {
return &friendIndexSrv{ return &shipIndexSrv{
ams: ams, ams: ams,
ths: ths, ths: ths,
sqlxSrv: newSqlxSrv(db), sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildFriendIndex), q: mustBuild(db, cc.BuildShipIndex),
}
}
func newFollowIndexService(db *sqlx.DB, ths core.TweetHelpService) core.IndexPostsService {
return &followIndexSrv{
ths: ths,
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildFollowIndex),
}
}
func newLightIndexService(db *sqlx.DB, ths core.TweetHelpService) core.IndexPostsService {
return &lightIndexSrv{
ths: ths,
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildLightIndex),
} }
} }
@ -156,35 +127,21 @@ func newSimpleIndexPostsService(db *sqlx.DB, ths core.TweetHelpService) core.Ind
} }
} }
func newFriendIndexServantA(db *sqlx.DB, ams core.AuthorizationManageService, ths core.TweetHelpServantA) core.IndexPostsServantA { //lint:ignore U1000 newShipIndexServantA
return &friendIndexSrvA{ func newShipIndexServantA(db *sqlx.DB, ams core.AuthorizationManageService, ths core.TweetHelpServantA) core.IndexPostsServantA {
return &shipIndexSrvA{
ams: ams, ams: ams,
ths: ths, ths: ths,
sqlxSrv: newSqlxSrv(db), sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildFriendIndexA), q: mustBuildFn(db, cc.BuildShipIndexA),
}
}
func newFollowIndexServantA(db *sqlx.DB, ths core.TweetHelpServantA) core.IndexPostsServantA {
return &followIndexSrvA{
ths: ths,
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildFollowIndexA),
}
}
func newLightIndexServantA(db *sqlx.DB, ths core.TweetHelpServantA) core.IndexPostsServantA {
return &lightIndexSrvA{
ths: ths,
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildLightIndexA),
} }
} }
//lint:ignore U1000 newSimpleIndexPostsServantA
func newSimpleIndexPostsServantA(db *sqlx.DB, ths core.TweetHelpServantA) core.IndexPostsServantA { func newSimpleIndexPostsServantA(db *sqlx.DB, ths core.TweetHelpServantA) core.IndexPostsServantA {
return &simpleIndexPostsSrvA{ return &simpleIndexPostsSrvA{
ths: ths, ths: ths,
sqlxSrv: newSqlxSrv(db), sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildSimpleIndexA), q: mustBuildFn(db, cc.BuildSimpleIndexA),
} }
} }

@ -421,40 +421,18 @@ func (s *tweetSrv) GetPostContentByID(id int64) (res *ms.PostContent, err error)
} }
func (s *tweetSrvA) TweetInfoById(id int64) (*cs.TweetInfo, error) { func (s *tweetSrvA) TweetInfoById(id int64) (*cs.TweetInfo, error) {
res := &cs.TweetInfo{} // TODO
err := s.q.TweetInfoById.Get(res, id) return nil, debug.ErrNotImplemented
return res, err
} }
func (s *tweetSrvA) TweetItemById(id int64) (*cs.TweetItem, error) { func (s *tweetSrvA) TweetItemById(id int64) (*cs.TweetItem, error) {
res := &cs.TweetItem{} // TODO
err := s.q.TweetItemById.Get(res, id) return nil, debug.ErrNotImplemented
if err != nil {
return nil, err
}
// TODO need add contents info to res
return res, nil
} }
func (s *tweetSrvA) UserTweets(visitorId, userId int64) (res cs.TweetList, err error) { func (s *tweetSrvA) UserTweets(visitorId, userId int64) (res cs.TweetList, err error) {
res = cs.TweetList{} // TODO
switch s.checkRelationBy(visitorId, userId) { return nil, debug.ErrNotImplemented
case 0: // admin
err = s.q.UserTweetsByAdmin.Select(&res, userId)
case 1: // self
err = s.q.UserTweetsBySelf.Select(&res, userId)
case 2: // friend
err = s.q.UserTweetsByFriend.Select(&res, userId)
case 3: // follower
fallthrough
default: // guest
err = s.q.UserTweetsByGuest.Select(&res, userId)
}
if err != nil {
return nil, err
}
// TODO need add contents info to res
return res, nil
} }
// checkRelationBy check the relation of visitor with user // checkRelationBy check the relation of visitor with user
@ -464,33 +442,28 @@ func (s *tweetSrvA) checkRelationBy(visitorId, userId int64) uint {
} }
func (s *tweetSrvA) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) { func (s *tweetSrvA) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) {
res := &cs.ReactionItem{} // TODO
err := s.q.ReactionByTweetId.Get(res, userId, tweetId) return nil, debug.ErrNotImplemented
return res, err
} }
func (s *tweetSrvA) UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error) { func (s *tweetSrvA) UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error) {
res := cs.ReactionList{} // TODO
err := s.q.UserReactions.Select(&res, userId) return nil, debug.ErrNotImplemented
return res, err
} }
func (s *tweetSrvA) FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error) { func (s *tweetSrvA) FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error) {
res := &cs.FavoriteItem{} // TODO
err := s.q.FavoriteByTweetId.Get(res, userId, tweetId) return nil, debug.ErrNotImplemented
return res, err
} }
func (s *tweetSrvA) UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error) { func (s *tweetSrvA) UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error) {
res := cs.FavoriteList{} // TODO
err := s.q.UserFavorites.Select(&res, userId) return nil, debug.ErrNotImplemented
return res, err
} }
func (s *tweetSrvA) AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error) { func (s *tweetSrvA) AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error) {
res := &cs.AttachmentBill{} // TODO
err := s.q.AttachmentByTweetId.Get(res, userId, tweetId) return nil, debug.ErrNotImplemented
return res, err
} }
func (s *tweetManageSrvA) CreateAttachment(obj *cs.Attachment) (int64, error) { func (s *tweetManageSrvA) CreateAttachment(obj *cs.Attachment) (int64, error) {
@ -578,7 +551,7 @@ func newTweetHelpService(db *sqlx.DB) core.TweetHelpService {
func newTweetServantA(db *sqlx.DB) core.TweetServantA { func newTweetServantA(db *sqlx.DB) core.TweetServantA {
return &tweetSrvA{ return &tweetSrvA{
sqlxSrv: newSqlxSrv(db), sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildTweetA), q: mustBuildFn(db, cc.BuildTweetA),
} }
} }
@ -586,13 +559,13 @@ func newTweetManageServantA(db *sqlx.DB, cacheIndex core.CacheIndexService) core
return &tweetManageSrvA{ return &tweetManageSrvA{
sqlxSrv: newSqlxSrv(db), sqlxSrv: newSqlxSrv(db),
cis: cacheIndex, cis: cacheIndex,
q: mustBuild(db, cc.BuildTweetManageA), q: mustBuildFn(db, cc.BuildTweetManageA),
} }
} }
func newTweetHelpServantA(db *sqlx.DB) core.TweetHelpServantA { func newTweetHelpServantA(db *sqlx.DB) core.TweetHelpServantA {
return &tweetHelpSrvA{ return &tweetHelpSrvA{
sqlxSrv: newSqlxSrv(db), sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildTweetHelpA), q: mustBuildFn(db, cc.BuildTweetHelpA),
} }
} }

@ -50,13 +50,7 @@ const (
_ContactManager_ListFriend = `SELECT c.friend_id user_id, u.username username, u.nickname nickname, u.avatar avatar, u.phone phone FROM @contact c JOIN @user u ON c.friend_id=u.id WHERE user_id=? AND status=2 AND is_del=0 ORDER BY u.nickname ASC LIMIT ? OFFSET ?` _ContactManager_ListFriend = `SELECT c.friend_id user_id, u.username username, u.nickname nickname, u.avatar avatar, u.phone phone FROM @contact c JOIN @user u ON c.friend_id=u.id WHERE user_id=? AND status=2 AND is_del=0 ORDER BY u.nickname ASC LIMIT ? OFFSET ?`
_ContactManager_RejectFriendMsgsUpdate = `UPDATE @message SET reply_id=?, modified_on=? WHERE sender_user_id = ? AND receiver_user_id = ? AND type = ? AND reply_id = ?` _ContactManager_RejectFriendMsgsUpdate = `UPDATE @message SET reply_id=?, modified_on=? WHERE sender_user_id = ? AND receiver_user_id = ? AND type = ? AND reply_id = ?`
_ContactManager_TotalFriendsById = `SELECT count(*) FROM @contact WHERE user_id=? AND status=2 AND is_del=0` _ContactManager_TotalFriendsById = `SELECT count(*) FROM @contact WHERE user_id=? AND status=2 AND is_del=0`
_FollowIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_FollowIndex_UserInfo = `SELECT * FROM @user WHERE username=?`
_FollowingManager_CreateFollowing = `INSERT INTO @following (user_id, follow_id, created_on) VALUES (?, ?, ?)` _FollowingManager_CreateFollowing = `INSERT INTO @following (user_id, follow_id, created_on) VALUES (?, ?, ?)`
_FriendIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_FriendIndex_UserInfo = `SELECT * FROM @user WHERE username=?`
_LightIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_LightIndex_UserInfo = `SELECT * FROM @user WHERE username=?`
_Message_CreateMessage = `INSERT INTO @message (sender_user_id, receiver_user_id, type, brief, content, post_id, comment_id, reply_id, created_on) VALUES (:sender_user_id, :receiver_user_id, :type, :brief, :content, :post_id, :comment_id, :reply_id, :created_on)` _Message_CreateMessage = `INSERT INTO @message (sender_user_id, receiver_user_id, type, brief, content, post_id, comment_id, reply_id, created_on) VALUES (:sender_user_id, :receiver_user_id, :type, :brief, :content, :post_id, :comment_id, :reply_id, :created_on)`
_Message_GetMessageById = `SELECT * FROM @message WHERE id=? AND is_del=0` _Message_GetMessageById = `SELECT * FROM @message WHERE id=? AND is_del=0`
_Message_GetMessageCount = `SELECT count(*) FROM @message WHERE receiver_user_id=:recerver_user_id AND is_del=0` _Message_GetMessageCount = `SELECT count(*) FROM @message WHERE receiver_user_id=:recerver_user_id AND is_del=0`
@ -66,8 +60,16 @@ const (
_Security_CreatePhoneCaptcha = `INSERT INTO @captcha (phone, captcha, expired_on, created_on) VALUES (:phone, :captcha, :expired_on, :created_on)` _Security_CreatePhoneCaptcha = `INSERT INTO @captcha (phone, captcha, expired_on, created_on) VALUES (:phone, :captcha, :expired_on, :created_on)`
_Security_GetLatestPhoneCaptcha = `SELECT * FROM @captcha WHERE phone=? AND is_del=0` _Security_GetLatestPhoneCaptcha = `SELECT * FROM @captcha WHERE phone=? AND is_del=0`
_Security_UsePhoneCaptcha = `UPDATE @captcha SET use_times=use_times+1, modified_on=? WHERE id=? AND is_del=0` _Security_UsePhoneCaptcha = `UPDATE @captcha SET use_times=use_times+1, modified_on=? WHERE id=? AND is_del=0`
_ShipIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_ShipIndex_IndexByAdmin = `SELECT * FROM @p_post WHERE is_del=0 ORDER BY is_top DESC, latest_replied_on DESC LIMIT ? OFFSET ?`
_ShipIndex_IndexByGuest = `SELECT * FROM @p_post WHERE visibility=0 AND is_del=0 ORDER BY is_top DESC, latest_replied_on DESC LIMIT ? OFFSET ?`
_ShipIndex_IndexBySelf = `SELECT * FROM @p_post WHERE is_del=0 AND (visibility=0 OR (visibility=1 AND user_id=?) OR (visibility=2 AND user_id IN ?)) ORDER BY is_top DESC, latest_replied_on DESC LIMIT ? OFFSET ?`
_ShipIndex_IndexCountByAdmin = `SELECT count(*) FROM @p_post WHERE is_del=0`
_ShipIndex_IndexCountByGuest = `SELECT count(*) FROM @p_post WHERE visibility=0 AND is_del=0`
_ShipIndex_IndexCountBySelf = `SELECT count(*) FROM @p_post WHERE is_del=0 AND (visibility=0 OR (visibility=1 AND user_id=?) OR (visibility=2 AND user_id IN ?))`
_SimpleIndexA_UserInfo = `SELECT * FROM @user WHERE username=?` _SimpleIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_SimpleIndex_UserInfo = `SELECT * FROM @user WHERE username=?` _SimpleIndex_Index = `SELECT * FROM @p_post WHERE visibility=0 ORDER BY is_top DESC, latest_replied_on DESC LIMIT ? OFFSET ?`
_SimpleIndex_IndexCount = `SELECT count(*) FROM @p_post WHERE visibility=0`
_TopicA_DecrTagsById = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)` _TopicA_DecrTagsById = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)`
_TopicA_HotTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?` _TopicA_HotTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?`
_TopicA_IncrTagsById = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)` _TopicA_IncrTagsById = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)`
@ -205,41 +207,11 @@ type ContactManager struct {
CreateMessage *sqlx.NamedStmt `yesql:"create_message"` CreateMessage *sqlx.NamedStmt `yesql:"create_message"`
} }
type FollowIndex struct {
yesql.Namespace `yesql:"follow_index"`
UserInfo *sqlx.Stmt `yesql:"user_info"`
}
type FollowIndexA struct {
yesql.Namespace `yesql:"follow_index_a"`
UserInfo *sqlx.Stmt `yesql:"user_info"`
}
type FollowingManager struct { type FollowingManager struct {
yesql.Namespace `yesql:"following_manager"` yesql.Namespace `yesql:"following_manager"`
CreateFollowing *sqlx.Stmt `yesql:"create_following"` CreateFollowing *sqlx.Stmt `yesql:"create_following"`
} }
type FriendIndex struct {
yesql.Namespace `yesql:"friend_index"`
UserInfo *sqlx.Stmt `yesql:"user_info"`
}
type FriendIndexA struct {
yesql.Namespace `yesql:"friend_index_a"`
UserInfo *sqlx.Stmt `yesql:"user_info"`
}
type LightIndex struct {
yesql.Namespace `yesql:"light_index"`
UserInfo *sqlx.Stmt `yesql:"user_info"`
}
type LightIndexA struct {
yesql.Namespace `yesql:"light_index_a"`
UserInfo *sqlx.Stmt `yesql:"user_info"`
}
type Message struct { type Message struct {
yesql.Namespace `yesql:"message"` yesql.Namespace `yesql:"message"`
GetMessageById *sqlx.Stmt `yesql:"get_message_by_id"` GetMessageById *sqlx.Stmt `yesql:"get_message_by_id"`
@ -257,14 +229,30 @@ type Security struct {
CreatePhoneCaptcha *sqlx.NamedStmt `yesql:"create_phone_captcha"` CreatePhoneCaptcha *sqlx.NamedStmt `yesql:"create_phone_captcha"`
} }
type ShipIndex struct {
yesql.Namespace `yesql:"ship_index"`
IndexBySelf string `yesql:"index_by_self"`
IndexCountBySelf string `yesql:"index_count_by_self"`
IndexByAdmin *sqlx.Stmt `yesql:"index_by_admin"`
IndexByGuest *sqlx.Stmt `yesql:"index_by_guest"`
IndexCountByAdmin *sqlx.Stmt `yesql:"index_count_by_admin"`
IndexCountByGuest *sqlx.Stmt `yesql:"index_count_by_guest"`
}
type ShipIndexA struct {
yesql.Namespace `yesql:"ship_index_a"`
UserInfo string `yesql:"user_info"`
}
type SimpleIndex struct { type SimpleIndex struct {
yesql.Namespace `yesql:"simple_index"` yesql.Namespace `yesql:"simple_index"`
UserInfo *sqlx.Stmt `yesql:"user_info"` Index *sqlx.Stmt `yesql:"index"`
IndexCount *sqlx.Stmt `yesql:"index_count"`
} }
type SimpleIndexA struct { type SimpleIndexA struct {
yesql.Namespace `yesql:"simple_index_a"` yesql.Namespace `yesql:"simple_index_a"`
UserInfo *sqlx.Stmt `yesql:"user_info"` UserInfo string `yesql:"user_info"`
} }
type TopicA struct { type TopicA struct {
@ -301,18 +289,18 @@ type Tweet struct {
type TweetA struct { type TweetA struct {
yesql.Namespace `yesql:"tweet_a"` yesql.Namespace `yesql:"tweet_a"`
AttachmentByTweetId *sqlx.Stmt `yesql:"attachment_by_tweet_id"` AttachmentByTweetId string `yesql:"attachment_by_tweet_id"`
FavoriteByTweetId *sqlx.Stmt `yesql:"favorite_by_tweet_id"` FavoriteByTweetId string `yesql:"favorite_by_tweet_id"`
ReactionByTweetId *sqlx.Stmt `yesql:"reaction_by_tweet_id"` ReactionByTweetId string `yesql:"reaction_by_tweet_id"`
TweetInfoById *sqlx.Stmt `yesql:"tweet_info_by_id"` TweetInfoById string `yesql:"tweet_info_by_id"`
TweetItemById *sqlx.Stmt `yesql:"tweet_item_by_id"` TweetItemById string `yesql:"tweet_item_by_id"`
UserFavorites *sqlx.Stmt `yesql:"user_favorites"` UserFavorites string `yesql:"user_favorites"`
UserInfo *sqlx.Stmt `yesql:"user_info"` UserInfo string `yesql:"user_info"`
UserReactions *sqlx.Stmt `yesql:"user_reactions"` UserReactions string `yesql:"user_reactions"`
UserTweetsByAdmin *sqlx.Stmt `yesql:"user_tweets_by_admin"` UserTweetsByAdmin string `yesql:"user_tweets_by_admin"`
UserTweetsByFriend *sqlx.Stmt `yesql:"user_tweets_by_friend"` UserTweetsByFriend string `yesql:"user_tweets_by_friend"`
UserTweetsByGuest *sqlx.Stmt `yesql:"user_tweets_by_guest"` UserTweetsByGuest string `yesql:"user_tweets_by_guest"`
UserTweetsBySelf *sqlx.Stmt `yesql:"user_tweets_by_self"` UserTweetsBySelf string `yesql:"user_tweets_by_self"`
} }
type TweetHelp struct { type TweetHelp struct {
@ -323,7 +311,7 @@ type TweetHelp struct {
type TweetHelpA struct { type TweetHelpA struct {
yesql.Namespace `yesql:"tweet_help_a"` yesql.Namespace `yesql:"tweet_help_a"`
UserInfo *sqlx.Stmt `yesql:"user_info"` UserInfo string `yesql:"user_info"`
} }
type TweetManage struct { type TweetManage struct {
@ -350,7 +338,7 @@ type TweetManage struct {
type TweetManageA struct { type TweetManageA struct {
yesql.Namespace `yesql:"tweet_manage_a"` yesql.Namespace `yesql:"tweet_manage_a"`
UserInfo *sqlx.Stmt `yesql:"user_info"` UserInfo string `yesql:"user_info"`
} }
type UserManage struct { type UserManage struct {
@ -542,149 +530,98 @@ func BuildContactManager(p yesql.PreparexBuilder, ctx ...context.Context) (obj *
return return
} }
func BuildFollowIndex(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FollowIndex, err error) { func BuildFollowingManager(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FollowingManager, err error) {
var c context.Context var c context.Context
if len(ctx) > 0 && ctx[0] != nil { if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0] c = ctx[0]
} else { } else {
c = context.Background() c = context.Background()
} }
obj = &FollowIndex{} obj = &FollowingManager{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_FollowIndex_UserInfo))); err != nil { if obj.CreateFollowing, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_FollowingManager_CreateFollowing))); err != nil {
return return
} }
return return
} }
func BuildFollowIndexA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FollowIndexA, err error) { func BuildMessage(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Message, err error) {
var c context.Context var c context.Context
if len(ctx) > 0 && ctx[0] != nil { if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0] c = ctx[0]
} else { } else {
c = context.Background() c = context.Background()
} }
obj = &FollowIndexA{} obj = &Message{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_FollowIndexA_UserInfo))); err != nil { if obj.GetMessageById, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Message_GetMessageById))); err != nil {
return
}
return return
} }
if obj.GetUnreadCount, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Message_GetUnreadCount))); err != nil {
func BuildFollowingManager(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FollowingManager, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &FollowingManager{}
if obj.CreateFollowing, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_FollowingManager_CreateFollowing))); err != nil {
return return
} }
if obj.ReadMessage, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Message_ReadMessage))); err != nil {
return return
} }
if obj.CreateMessage, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Message_CreateMessage))); err != nil {
func BuildFriendIndex(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FriendIndex, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &FriendIndex{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_FriendIndex_UserInfo))); err != nil {
return return
} }
if obj.GetMessageCount, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Message_GetMessageCount))); err != nil {
return return
} }
if obj.GetMessages, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Message_GetMessages))); err != nil {
func BuildFriendIndexA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *FriendIndexA, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &FriendIndexA{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_FriendIndexA_UserInfo))); err != nil {
return return
} }
return return
} }
func BuildLightIndex(p yesql.PreparexBuilder, ctx ...context.Context) (obj *LightIndex, err error) { func BuildSecurity(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Security, err error) {
var c context.Context var c context.Context
if len(ctx) > 0 && ctx[0] != nil { if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0] c = ctx[0]
} else { } else {
c = context.Background() c = context.Background()
} }
obj = &LightIndex{} obj = &Security{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_LightIndex_UserInfo))); err != nil { if obj.GetLatestPhoneCaptcha, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Security_GetLatestPhoneCaptcha))); err != nil {
return return
} }
if obj.UsePhoneCaptcha, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Security_UsePhoneCaptcha))); err != nil {
return return
} }
if obj.CreatePhoneCaptcha, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Security_CreatePhoneCaptcha))); err != nil {
func BuildLightIndexA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *LightIndexA, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &LightIndexA{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_LightIndexA_UserInfo))); err != nil {
return return
} }
return return
} }
func BuildMessage(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Message, err error) { func BuildShipIndex(p yesql.PreparexBuilder, ctx ...context.Context) (obj *ShipIndex, err error) {
var c context.Context var c context.Context
if len(ctx) > 0 && ctx[0] != nil { if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0] c = ctx[0]
} else { } else {
c = context.Background() c = context.Background()
} }
obj = &Message{} obj = &ShipIndex{
if obj.GetMessageById, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Message_GetMessageById))); err != nil { IndexBySelf: p.QueryHook(_ShipIndex_IndexBySelf),
return IndexCountBySelf: p.QueryHook(_ShipIndex_IndexCountBySelf),
}
if obj.GetUnreadCount, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Message_GetUnreadCount))); err != nil {
return
} }
if obj.ReadMessage, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Message_ReadMessage))); err != nil { if obj.IndexByAdmin, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_ShipIndex_IndexByAdmin))); err != nil {
return return
} }
if obj.CreateMessage, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Message_CreateMessage))); err != nil { if obj.IndexByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_ShipIndex_IndexByGuest))); err != nil {
return return
} }
if obj.GetMessageCount, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Message_GetMessageCount))); err != nil { if obj.IndexCountByAdmin, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_ShipIndex_IndexCountByAdmin))); err != nil {
return return
} }
if obj.GetMessages, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Message_GetMessages))); err != nil { if obj.IndexCountByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_ShipIndex_IndexCountByGuest))); err != nil {
return return
} }
return return
} }
func BuildSecurity(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Security, err error) { func BuildShipIndexA(p yesql.PreparexBuilder) (obj *ShipIndexA, err error) {
var c context.Context obj = &ShipIndexA{
if len(ctx) > 0 && ctx[0] != nil { UserInfo: p.QueryHook(_ShipIndexA_UserInfo),
c = ctx[0]
} else {
c = context.Background()
}
obj = &Security{}
if obj.GetLatestPhoneCaptcha, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Security_GetLatestPhoneCaptcha))); err != nil {
return
}
if obj.UsePhoneCaptcha, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Security_UsePhoneCaptcha))); err != nil {
return
}
if obj.CreatePhoneCaptcha, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Security_CreatePhoneCaptcha))); err != nil {
return
} }
return return
} }
@ -697,23 +634,19 @@ func BuildSimpleIndex(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Sim
c = context.Background() c = context.Background()
} }
obj = &SimpleIndex{} obj = &SimpleIndex{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_SimpleIndex_UserInfo))); err != nil { if obj.Index, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_SimpleIndex_Index))); err != nil {
return return
} }
if obj.IndexCount, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_SimpleIndex_IndexCount))); err != nil {
return return
} }
func BuildSimpleIndexA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *SimpleIndexA, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &SimpleIndexA{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_SimpleIndexA_UserInfo))); err != nil {
return return
} }
func BuildSimpleIndexA(p yesql.PreparexBuilder) (obj *SimpleIndexA, err error) {
obj = &SimpleIndexA{
UserInfo: p.QueryHook(_SimpleIndexA_UserInfo),
}
return return
} }
@ -793,49 +726,20 @@ func BuildTweet(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Tweet, er
return return
} }
func BuildTweetA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *TweetA, err error) { func BuildTweetA(p yesql.PreparexBuilder) (obj *TweetA, err error) {
var c context.Context obj = &TweetA{
if len(ctx) > 0 && ctx[0] != nil { AttachmentByTweetId: p.QueryHook(_TweetA_AttachmentByTweetId),
c = ctx[0] FavoriteByTweetId: p.QueryHook(_TweetA_FavoriteByTweetId),
} else { ReactionByTweetId: p.QueryHook(_TweetA_ReactionByTweetId),
c = context.Background() TweetInfoById: p.QueryHook(_TweetA_TweetInfoById),
} TweetItemById: p.QueryHook(_TweetA_TweetItemById),
obj = &TweetA{} UserFavorites: p.QueryHook(_TweetA_UserFavorites),
if obj.AttachmentByTweetId, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_AttachmentByTweetId))); err != nil { UserInfo: p.QueryHook(_TweetA_UserInfo),
return UserReactions: p.QueryHook(_TweetA_UserReactions),
} UserTweetsByAdmin: p.QueryHook(_TweetA_UserTweetsByAdmin),
if obj.FavoriteByTweetId, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_FavoriteByTweetId))); err != nil { UserTweetsByFriend: p.QueryHook(_TweetA_UserTweetsByFriend),
return UserTweetsByGuest: p.QueryHook(_TweetA_UserTweetsByGuest),
} UserTweetsBySelf: p.QueryHook(_TweetA_UserTweetsBySelf),
if obj.ReactionByTweetId, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_ReactionByTweetId))); err != nil {
return
}
if obj.TweetInfoById, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_TweetInfoById))); err != nil {
return
}
if obj.TweetItemById, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_TweetItemById))); err != nil {
return
}
if obj.UserFavorites, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_UserFavorites))); err != nil {
return
}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_UserInfo))); err != nil {
return
}
if obj.UserReactions, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_UserReactions))); err != nil {
return
}
if obj.UserTweetsByAdmin, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_UserTweetsByAdmin))); err != nil {
return
}
if obj.UserTweetsByFriend, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_UserTweetsByFriend))); err != nil {
return
}
if obj.UserTweetsByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_UserTweetsByGuest))); err != nil {
return
}
if obj.UserTweetsBySelf, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetA_UserTweetsBySelf))); err != nil {
return
} }
return return
} }
@ -848,16 +752,9 @@ func BuildTweetHelp(p yesql.PreparexBuilder) (obj *TweetHelp, err error) {
return return
} }
func BuildTweetHelpA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *TweetHelpA, err error) { func BuildTweetHelpA(p yesql.PreparexBuilder) (obj *TweetHelpA, err error) {
var c context.Context obj = &TweetHelpA{
if len(ctx) > 0 && ctx[0] != nil { UserInfo: p.QueryHook(_TweetHelpA_UserInfo),
c = ctx[0]
} else {
c = context.Background()
}
obj = &TweetHelpA{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetHelpA_UserInfo))); err != nil {
return
} }
return return
} }
@ -922,16 +819,9 @@ func BuildTweetManage(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Twe
return return
} }
func BuildTweetManageA(p yesql.PreparexBuilder, ctx ...context.Context) (obj *TweetManageA, err error) { func BuildTweetManageA(p yesql.PreparexBuilder) (obj *TweetManageA, err error) {
var c context.Context obj = &TweetManageA{
if len(ctx) > 0 && ctx[0] != nil { UserInfo: p.QueryHook(_TweetManageA_UserInfo),
c = ctx[0]
} else {
c = context.Background()
}
obj = &TweetManageA{}
if obj.UserInfo, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManageA_UserInfo))); err != nil {
return
} }
return return
} }

@ -270,59 +270,83 @@ INSERT INTO @captcha (phone, captcha, expired_on, created_on)
VALUES (:phone, :captcha, :expired_on, :created_on); VALUES (:phone, :captcha, :expired_on, :created_on);
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- friend_index sql dml -- ship_index sql dml
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- name: user_info@friend_index -- name: index_by_admin@ship_index
-- prepare: stmt -- prepare: stmt
SELECT * FROM @user WHERE username=? SELECT *
FROM @p_post
-------------------------------------------------------------------------------- WHERE is_del=0
-- follow_index sql dml ORDER BY is_top DESC, latest_replied_on DESC
-------------------------------------------------------------------------------- LIMIT ? OFFSET ?;
-- name: user_info@follow_index -- name: index_count_by_admin@ship_index
-- prepare: stmt -- prepare: stmt
SELECT * FROM @user WHERE username=? SELECT count(*)
FROM @p_post
WHERE is_del=0;
-------------------------------------------------------------------------------- -- name: index_by_guest@ship_index
-- light_index sql dml -- prepare: stmt
-------------------------------------------------------------------------------- SELECT *
FROM @p_post
WHERE visibility=0 AND is_del=0
ORDER BY is_top DESC, latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_info@light_index -- name: index_count_by_guest@ship_index
-- prepare: stmt -- prepare: stmt
SELECT * FROM @user WHERE username=? SELECT count(*)
FROM @p_post
WHERE visibility=0 AND is_del=0;
-------------------------------------------------------------------------------- -- name: index_by_self@ship_index
-- simple_index sql dml -- prepare: raw
-------------------------------------------------------------------------------- -- clause: in
SELECT *
FROM @p_post
WHERE is_del=0 AND
(visibility=0 OR
(visibility=1 AND user_id=?) OR
(visibility=2 AND user_id IN ?))
ORDER BY is_top DESC, latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_info@simple_index -- name: index_count_by_self@ship_index
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? -- clause: in
SELECT count(*)
FROM @p_post
WHERE is_del=0 AND
(visibility=0 OR
(visibility=1 AND user_id=?) OR
(visibility=2 AND user_id IN ?));
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- friend_index_a sql dml -- simple_index sql dml
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- name: user_info@friend_index_a -- name: index@simple_index
-- prepare: stmt -- prepare: stmt
SELECT * FROM @user WHERE username=? SELECT *
FROM @p_post
-------------------------------------------------------------------------------- WHERE visibility=0
-- follow_index_a sql dml ORDER BY is_top DESC, latest_replied_on DESC
-------------------------------------------------------------------------------- LIMIT ? OFFSET ?;
-- name: user_info@follow_index_a -- name: index_count@simple_index
-- prepare: stmt -- prepare: stmt
SELECT * FROM @user WHERE username=? SELECT count(*)
FROM @p_post
WHERE visibility=0;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- light_index_a sql dml -- ship_index_a sql dml
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- name: user_info@light_index_a -- name: user_info@ship_index_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -330,7 +354,7 @@ SELECT * FROM @user WHERE username=?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- name: user_info@simple_index_a -- name: user_info@simple_index_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -653,51 +677,51 @@ WHERE id IN (?) AND is_del=0;
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- name: user_info@tweet_a -- name: user_info@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: tweet_info_by_id@tweet_a -- name: tweet_info_by_id@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: tweet_item_by_id@tweet_a -- name: tweet_item_by_id@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: user_tweets_by_admin@tweet_a -- name: user_tweets_by_admin@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: user_tweets_by_self@tweet_a -- name: user_tweets_by_self@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: user_tweets_by_friend@tweet_a -- name: user_tweets_by_friend@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: user_tweets_by_guest@tweet_a -- name: user_tweets_by_guest@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: reaction_by_tweet_id@tweet_a -- name: reaction_by_tweet_id@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: user_reactions@tweet_a -- name: user_reactions@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: favorite_by_tweet_id@tweet_a -- name: favorite_by_tweet_id@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: user_favorites@tweet_a -- name: user_favorites@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-- name: attachment_by_tweet_id@tweet_a -- name: attachment_by_tweet_id@tweet_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -705,7 +729,7 @@ SELECT * FROM @user WHERE username=?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- name: user_info@tweet_manage_a -- name: user_info@tweet_manage_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -713,7 +737,7 @@ SELECT * FROM @user WHERE username=?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- name: user_info@tweet_help_a -- name: user_info@tweet_help_a
-- prepare: stmt -- prepare: raw
SELECT * FROM @user WHERE username=? SELECT * FROM @user WHERE username=?
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

Loading…
Cancel
Save