Merge branch 'r/paopao-ce-plus' into r/paopao-ce-xtra

r/paopao-ce-xtra
Michael Li 1 year ago
commit 7b15f1b568
No known key found for this signature in database

@ -84,7 +84,7 @@ gen-mir:
.PHONY: gen-yesql
gen-yesql:
@go generate internal/dao/sakila/yesql/gen.go
@go fmt ./internal/dao/sakila/yesql/...
@go fmt ./internal/dao/sakila/auto/...
.PHONY: gen-rpc
gen-rpc:

@ -7,7 +7,7 @@ require (
github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868
github.com/alimy/cfg v0.4.0
github.com/alimy/mir/v4 v4.0.0
github.com/alimy/yesql v1.8.0
github.com/alimy/yesql v1.8.4
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
github.com/allegro/bigcache/v3 v3.1.0
github.com/bitbus/sqlx v1.6.0

@ -127,8 +127,8 @@ github.com/alimy/cfg v0.4.0 h1:SslKPndmxRViT1ePWLmNsEq7okYP0GVeuowQlRWZPkw=
github.com/alimy/cfg v0.4.0/go.mod h1:rOxbasTH2srl6StAjNF5Vyi8bfrdkl3fLGmOYtSw81c=
github.com/alimy/mir/v4 v4.0.0 h1:MzGfmoLjjvR69jbZEmpKJO3tUuqB0RGRv1UWPbtukBg=
github.com/alimy/mir/v4 v4.0.0/go.mod h1:d58dBvw2KImcVbAUANrciEV/of0arMNsI9c/5UNCMMc=
github.com/alimy/yesql v1.8.0 h1:nOyElCU740uQ+S1hmG49Kpb6Sve5zqKayCj7mL21Dro=
github.com/alimy/yesql v1.8.0/go.mod h1:ROvO5FnBWhyAMI+sSSGzoXi2q/cCs0cW3WuelHCkLlk=
github.com/alimy/yesql v1.8.4 h1:Nj4u681SS6uEQTOqXUXBSFnXI67akStnYtv6eYXjPlM=
github.com/alimy/yesql v1.8.4/go.mod h1:ROvO5FnBWhyAMI+sSSGzoXi2q/cCs0cW3WuelHCkLlk=
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible h1:6JF1bjhT0WN2srEmijfOFtVWwV91KZ6dJY1/JbdtGrI=
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
github.com/allegro/bigcache/v3 v3.1.0 h1:H2Vp8VOvxcrB91o86fUSVJFqeuz8kpyyB02eH3bSzwk=

@ -9,7 +9,7 @@ import (
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs"
"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/auto/cc"
"github.com/rocboss/paopao-ce/pkg/types"
"github.com/sirupsen/logrus"
)
@ -74,6 +74,6 @@ func (s *authorizationManageSrv) isFriend(userId int64, friendId int64) bool {
func newAuthorizationManageService(db *sqlx.DB) core.AuthorizationManageService {
return &authorizationManageSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildAuthorizationManage),
q: ccBuild(db, cc.BuildAuthorizationManage),
}
}

@ -0,0 +1,222 @@
// Code generated by Yesql. DO NOT EDIT.
// versions:
// - Yesql v1.8.4
package ac
import (
"context"
"github.com/alimy/yesql"
"github.com/bitbus/sqlx"
)
const (
_ShipIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_SimpleIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_TopicA_DecrTagsById = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)`
_TopicA_ExistTopicUser = `SELECT 1 FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0`
_TopicA_FollowTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", 1 as is_following, c.is_top, u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "u.is_admin" FROM @topic_user c JOIN @user u ON c.user_id = u.id JOIN @tag t ON c.topic_id = t.id WHERE c.is_del = 0 AND t.quote_num > 0 AND AND c.user_id=? ORDER BY t.quote_num DESC LIMIT ? OFFSET ?`
_TopicA_FollowTopic = `INSERT INTO @topic_user(user_id, topic_id, created_on) VALUES (?, ?, ?)`
_TopicA_HotTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "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_InsertTag = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)`
_TopicA_NewestTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "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.id DESC LIMIT ? OFFSET ?`
_TopicA_StickTopic = `UPDATE @topic_user SET is_top=1-is_top; modified_on=? WHERE user_id=? AND topic_id=? AND is_del=0`
_TopicA_TagsByIdA = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0`
_TopicA_TagsByIdB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)`
_TopicA_TagsByKeywordA = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6`
_TopicA_TagsByKeywordB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6`
_TopicA_TagsForIncr = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)`
_TopicA_TopicInfos = `SELECT topic_id, is_top FROM @topic_user WHERE is_del=0 AND user_id=? AND topic_id IN ?`
_TopicA_TopicIsTop = `SELECT is_top FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0`
_TopicA_UnfollowTopic = `UPDATE @topic_user SET is_del=1, deleted_on=? WHERE user_id=? AND topic_id=? AND is_del=0`
_TweetA_AttachmentByTweetId = `SELECT * FROM @user WHERE username=?`
_TweetA_FavoriteByTweetId = `SELECT * FROM @user WHERE username=?`
_TweetA_ReactionByTweetId = `SELECT * FROM @user WHERE username=?`
_TweetA_TweetInfoById = `SELECT * FROM @user WHERE username=?`
_TweetA_TweetItemById = `SELECT * FROM @user WHERE username=?`
_TweetA_UserFavorites = `SELECT * FROM @user WHERE username=?`
_TweetA_UserInfo = `SELECT * FROM @user WHERE username=?`
_TweetA_UserReactions = `SELECT * FROM @user WHERE username=?`
_TweetA_UserTweetsByAdmin = `SELECT * FROM @user WHERE username=?`
_TweetA_UserTweetsByFriend = `SELECT * FROM @user WHERE username=?`
_TweetA_UserTweetsByGuest = `SELECT * FROM @user WHERE username=?`
_TweetA_UserTweetsBySelf = `SELECT * FROM @user WHERE username=?`
_TweetHelpA_UserInfo = `SELECT * FROM @user WHERE username=?`
_TweetManageA_UserInfo = `SELECT * FROM @user WHERE username=?`
)
// PreparexContext enhances the Conn interface with context.
type PreparexContext interface {
// PrepareContext prepares a statement.
// The provided context is used for the preparation of the statement, not for
// the execution of the statement.
PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
// PrepareNamedContext returns an sqlx.NamedStmt
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
// Rebind rebind query to adapte SQL Driver
Rebind(query string) string
}
// PreparexBuilder preparex builder interface for sqlx
type PreparexBuilder interface {
PreparexContext
QueryHook(query string) string
}
type ShipIndexA struct {
yesql.Namespace `yesql:"ship_index_a"`
UserInfo string `yesql:"user_info"`
}
type SimpleIndexA struct {
yesql.Namespace `yesql:"simple_index_a"`
UserInfo string `yesql:"user_info"`
}
type TopicA struct {
yesql.Namespace `yesql:"topic_a"`
DecrTagsById string `yesql:"decr_tags_by_id"`
IncrTagsById string `yesql:"incr_tags_by_id"`
TagsByIdA string `yesql:"tags_by_id_a"`
TagsByIdB string `yesql:"tags_by_id_b"`
TagsForIncr string `yesql:"tags_for_incr"`
TopicInfos string `yesql:"topic_infos"`
ExistTopicUser *sqlx.Stmt `yesql:"exist_topic_user"`
FollowTags *sqlx.Stmt `yesql:"follow_tags"`
FollowTopic *sqlx.Stmt `yesql:"follow_topic"`
HotTags *sqlx.Stmt `yesql:"hot_tags"`
InsertTag *sqlx.Stmt `yesql:"insert_tag"`
NewestTags *sqlx.Stmt `yesql:"newest_tags"`
StickTopic *sqlx.Stmt `yesql:"stick_topic"`
TagsByKeywordA *sqlx.Stmt `yesql:"tags_by_keyword_a"`
TagsByKeywordB *sqlx.Stmt `yesql:"tags_by_keyword_b"`
TopicIsTop *sqlx.Stmt `yesql:"topic_is_top"`
UnfollowTopic *sqlx.Stmt `yesql:"unfollow_topic"`
}
type TweetA struct {
yesql.Namespace `yesql:"tweet_a"`
AttachmentByTweetId string `yesql:"attachment_by_tweet_id"`
FavoriteByTweetId string `yesql:"favorite_by_tweet_id"`
ReactionByTweetId string `yesql:"reaction_by_tweet_id"`
TweetInfoById string `yesql:"tweet_info_by_id"`
TweetItemById string `yesql:"tweet_item_by_id"`
UserFavorites string `yesql:"user_favorites"`
UserInfo string `yesql:"user_info"`
UserReactions string `yesql:"user_reactions"`
UserTweetsByAdmin string `yesql:"user_tweets_by_admin"`
UserTweetsByFriend string `yesql:"user_tweets_by_friend"`
UserTweetsByGuest string `yesql:"user_tweets_by_guest"`
UserTweetsBySelf string `yesql:"user_tweets_by_self"`
}
type TweetHelpA struct {
yesql.Namespace `yesql:"tweet_help_a"`
UserInfo string `yesql:"user_info"`
}
type TweetManageA struct {
yesql.Namespace `yesql:"tweet_manage_a"`
UserInfo string `yesql:"user_info"`
}
func BuildShipIndexA(p PreparexBuilder) (obj *ShipIndexA, err error) {
obj = &ShipIndexA{
UserInfo: p.QueryHook(_ShipIndexA_UserInfo),
}
return
}
func BuildSimpleIndexA(p PreparexBuilder) (obj *SimpleIndexA, err error) {
obj = &SimpleIndexA{
UserInfo: p.QueryHook(_SimpleIndexA_UserInfo),
}
return
}
func BuildTopicA(p PreparexBuilder, ctx ...context.Context) (obj *TopicA, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &TopicA{
DecrTagsById: p.QueryHook(_TopicA_DecrTagsById),
IncrTagsById: p.QueryHook(_TopicA_IncrTagsById),
TagsByIdA: p.QueryHook(_TopicA_TagsByIdA),
TagsByIdB: p.QueryHook(_TopicA_TagsByIdB),
TagsForIncr: p.QueryHook(_TopicA_TagsForIncr),
TopicInfos: p.QueryHook(_TopicA_TopicInfos),
}
if obj.ExistTopicUser, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_ExistTopicUser))); err != nil {
return
}
if obj.FollowTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_FollowTags))); err != nil {
return
}
if obj.FollowTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_FollowTopic))); err != nil {
return
}
if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_HotTags))); err != nil {
return
}
if obj.InsertTag, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_InsertTag))); err != nil {
return
}
if obj.NewestTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_NewestTags))); err != nil {
return
}
if obj.StickTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_StickTopic))); err != nil {
return
}
if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TagsByKeywordA))); err != nil {
return
}
if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TagsByKeywordB))); err != nil {
return
}
if obj.TopicIsTop, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TopicIsTop))); err != nil {
return
}
if obj.UnfollowTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_UnfollowTopic))); err != nil {
return
}
return
}
func BuildTweetA(p PreparexBuilder) (obj *TweetA, err error) {
obj = &TweetA{
AttachmentByTweetId: p.QueryHook(_TweetA_AttachmentByTweetId),
FavoriteByTweetId: p.QueryHook(_TweetA_FavoriteByTweetId),
ReactionByTweetId: p.QueryHook(_TweetA_ReactionByTweetId),
TweetInfoById: p.QueryHook(_TweetA_TweetInfoById),
TweetItemById: p.QueryHook(_TweetA_TweetItemById),
UserFavorites: p.QueryHook(_TweetA_UserFavorites),
UserInfo: p.QueryHook(_TweetA_UserInfo),
UserReactions: p.QueryHook(_TweetA_UserReactions),
UserTweetsByAdmin: p.QueryHook(_TweetA_UserTweetsByAdmin),
UserTweetsByFriend: p.QueryHook(_TweetA_UserTweetsByFriend),
UserTweetsByGuest: p.QueryHook(_TweetA_UserTweetsByGuest),
UserTweetsBySelf: p.QueryHook(_TweetA_UserTweetsBySelf),
}
return
}
func BuildTweetHelpA(p PreparexBuilder) (obj *TweetHelpA, err error) {
obj = &TweetHelpA{
UserInfo: p.QueryHook(_TweetHelpA_UserInfo),
}
return
}
func BuildTweetManageA(p PreparexBuilder) (obj *TweetManageA, err error) {
obj = &TweetManageA{
UserInfo: p.QueryHook(_TweetManageA_UserInfo),
}
return
}

@ -1,6 +1,6 @@
// Code generated by Yesql. DO NOT EDIT.
// versions:
// - Yesql v1.8.0
// - Yesql v1.8.4
package cc
@ -12,8 +12,6 @@ import (
)
const (
_TagsFromNames = `SELECT * FROM @tag WHERE tag IN (?) AND is_del=0`
_UpdateTagQuote = `UPDATE @tag SET quote_num=?, modified_on=? WHERE id=? AND is_del=0`
_AuthorizationManage_BeFriendIds = `SELECT user_id FROM @contact WHERE friend_id=? AND status=2 AND is_del=0`
_AuthorizationManage_IsFriend = `SELECT status FROM @contact WHERE user_id=? AND friend_id=? AND is_del=0`
_AuthorizationManage_MyFriendSet = `SELECT friend_id FROM @contact WHERE user_id=? AND status=2 AND is_del=0`
@ -66,45 +64,14 @@ const (
_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_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=?`
_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_ExistTopicUser = `SELECT 1 FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0`
_TopicA_FollowTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", 1 as is_following, c.is_top, u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "u.is_admin" FROM @topic_user c JOIN @user u ON c.user_id = u.id JOIN @tag t ON c.topic_id = t.id WHERE c.is_del = 0 AND t.quote_num > 0 AND AND c.user_id=? ORDER BY t.quote_num DESC LIMIT ? OFFSET ?`
_TopicA_FollowTopic = `INSERT INTO @topic_user(user_id, topic_id, created_on) VALUES (?, ?, ?)`
_TopicA_HotTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "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_InsertTag = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)`
_TopicA_NewestTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id "u.id", u.nickname "u.nickname", u.username "u.username", u.status "u.status", u.avatar "u.avatar", u.is_admin "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.id DESC LIMIT ? OFFSET ?`
_TopicA_StickTopic = `UPDATE @topic_user SET is_top=1-is_top; modified_on=? WHERE user_id=? AND topic_id=? AND is_del=0`
_TopicA_TagsByIdA = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0`
_TopicA_TagsByIdB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)`
_TopicA_TagsByKeywordA = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6`
_TopicA_TagsByKeywordB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6`
_TopicA_TagsForIncr = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)`
_TopicA_TopicInfos = `SELECT topic_id, is_top FROM @topic_user WHERE is_del=0 AND user_id=? AND topic_id IN ?`
_TopicA_TopicIsTop = `SELECT is_top FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0`
_TopicA_UnfollowTopic = `UPDATE @topic_user SET is_del=1, deleted_on=? WHERE user_id=? AND topic_id=? AND is_del=0`
_TweetA_AttachmentByTweetId = `SELECT * FROM @user WHERE username=?`
_TweetA_FavoriteByTweetId = `SELECT * FROM @user WHERE username=?`
_TweetA_ReactionByTweetId = `SELECT * FROM @user WHERE username=?`
_TweetA_TweetInfoById = `SELECT * FROM @user WHERE username=?`
_TweetA_TweetItemById = `SELECT * FROM @user WHERE username=?`
_TweetA_UserFavorites = `SELECT * FROM @user WHERE username=?`
_TweetA_UserInfo = `SELECT * FROM @user WHERE username=?`
_TweetA_UserReactions = `SELECT * FROM @user WHERE username=?`
_TweetA_UserTweetsByAdmin = `SELECT * FROM @user WHERE username=?`
_TweetA_UserTweetsByFriend = `SELECT * FROM @user WHERE username=?`
_TweetA_UserTweetsByGuest = `SELECT * FROM @user WHERE username=?`
_TweetA_UserTweetsBySelf = `SELECT * FROM @user WHERE username=?`
_Tweet_GetAnyPostCount = `SELECT count(*) FROM @post WHERE visibility IN (?)`
_Tweet_GetAnyPosts = `SELECT * FROM @post WHERE visibility IN (?) AND is_del=0 LIMIT ? OFFSET ?`
_Tweet_GetPostAttachmentBill = `SELECT * FROM @post_attachment_bill WHERE post_id=? AND user_id=? AND is_del=0`
@ -119,10 +86,8 @@ const (
_Tweet_GetUserPostStarCount = `SELECT count(*) FROM @post_star s JOIN @post P ON s.post_id = P.ID WHERE s.user_id = ? AND s.is_del = 0 AND ( visibility <> 1 OR ( visibility = 1 AND P.user_id = ? ) )`
_Tweet_GetUserPostStars = `SELECT s.*, P.ID "post.id", P.user_id "post.user_id", P.comment_count "post.comment_count", P.collection_count "post.collection_count", P.upvote_count "post.upvote_count", P.share_count "post.share_count", P.visibility "post.visibility", P.is_top "post.is_top", P.is_essence "post.is_essence", P.is_lock "post.is_lock", P.latest_replied_on "post.latest_replied_on", P.tags "post.tags", P.attachment_price "post.attachment_price", P.ip "post.ip", P.ip_loc "post.ip_loc", P.is_del "post.is_del", P.created_on "post.created_on", P.modified_on "post.modified_on", P.deleted_on "post.deleted_on" FROM @post_star s JOIN @post P ON s.post_id = P.ID WHERE s.user_id = ? AND s.is_del = 0 AND ( visibility <> 1 OR ( visibility = 1 AND P.user_id = ? ) ) ORDER BY s.ID DESC, P.ID DESC LIMIT ? OFFSET ?`
_Tweet_GetUserPosts = `SELECT * FROM @post WHERE user_id=? AND visibility IN (?) ORDER BY latest_replies_on DESC LIMIT ? OFFSET ?`
_TweetHelpA_UserInfo = `SELECT * FROM @user WHERE username=?`
_TweetHelp_GetPostContentByIds = `SELECT id, post_id, content, type, sort FROM @post_content WHERE post_id IN (?) AND is_del=0`
_TweetHelp_GetUsersByIds = `SELECT id, username, nickname, status, avatar, is_admin FROM @user WHERE id IN (?) AND is_del=0`
_TweetManageA_UserInfo = `SELECT * FROM @user WHERE username=?`
_TweetManage_AddAttachment = `INSERT INTO @attachment (user_id, file_size, img_width, img_height, type, content, created_on) VALUES (?, ?, ?, ?, ?, ?, ?)`
_TweetManage_AddPost = `INSERT INTO @post (user_id, tags, ip, ip_loc, attachment_price, visibility, latest_replies_on, created_on) VALUES (:user_id, :tags, :ip, :ip_loc, :attachment_price, :visibility, :latest_replies_on, :created_on)`
_TweetManage_AddPostCollection = `INSERT INTO @post_collection (post_id, user_id, created_on) VALUES (?, ?, ?)`
@ -205,11 +170,6 @@ type PreparexBuilder interface {
QueryHook(query string) string
}
type Yesql struct {
TagsFromNames string `yesql:"tags_from_names"`
UpdateTagQuote *sqlx.Stmt `yesql:"update_tag_quote"`
}
type AuthorizationManage struct {
yesql.Namespace `yesql:"authorization_manage"`
BeFriendIds *sqlx.Stmt `yesql:"be_friend_ids"`
@ -300,43 +260,12 @@ type ShipIndex struct {
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 {
yesql.Namespace `yesql:"simple_index"`
Index *sqlx.Stmt `yesql:"index"`
IndexCount *sqlx.Stmt `yesql:"index_count"`
}
type SimpleIndexA struct {
yesql.Namespace `yesql:"simple_index_a"`
UserInfo string `yesql:"user_info"`
}
type TopicA struct {
yesql.Namespace `yesql:"topic_a"`
DecrTagsById string `yesql:"decr_tags_by_id"`
IncrTagsById string `yesql:"incr_tags_by_id"`
TagsByIdA string `yesql:"tags_by_id_a"`
TagsByIdB string `yesql:"tags_by_id_b"`
TagsForIncr string `yesql:"tags_for_incr"`
TopicInfos string `yesql:"topic_infos"`
ExistTopicUser *sqlx.Stmt `yesql:"exist_topic_user"`
FollowTags *sqlx.Stmt `yesql:"follow_tags"`
FollowTopic *sqlx.Stmt `yesql:"follow_topic"`
HotTags *sqlx.Stmt `yesql:"hot_tags"`
InsertTag *sqlx.Stmt `yesql:"insert_tag"`
NewestTags *sqlx.Stmt `yesql:"newest_tags"`
StickTopic *sqlx.Stmt `yesql:"stick_topic"`
TagsByKeywordA *sqlx.Stmt `yesql:"tags_by_keyword_a"`
TagsByKeywordB *sqlx.Stmt `yesql:"tags_by_keyword_b"`
TopicIsTop *sqlx.Stmt `yesql:"topic_is_top"`
UnfollowTopic *sqlx.Stmt `yesql:"unfollow_topic"`
}
type Tweet struct {
yesql.Namespace `yesql:"tweet"`
GetAnyPostCount string `yesql:"get_any_post_count"`
@ -375,33 +304,12 @@ type Tweet struct {
UserStarTweetsCountBySelf *sqlx.Stmt `yesql:"user_star_tweets_count_by_self"`
}
type TweetA struct {
yesql.Namespace `yesql:"tweet_a"`
AttachmentByTweetId string `yesql:"attachment_by_tweet_id"`
FavoriteByTweetId string `yesql:"favorite_by_tweet_id"`
ReactionByTweetId string `yesql:"reaction_by_tweet_id"`
TweetInfoById string `yesql:"tweet_info_by_id"`
TweetItemById string `yesql:"tweet_item_by_id"`
UserFavorites string `yesql:"user_favorites"`
UserInfo string `yesql:"user_info"`
UserReactions string `yesql:"user_reactions"`
UserTweetsByAdmin string `yesql:"user_tweets_by_admin"`
UserTweetsByFriend string `yesql:"user_tweets_by_friend"`
UserTweetsByGuest string `yesql:"user_tweets_by_guest"`
UserTweetsBySelf string `yesql:"user_tweets_by_self"`
}
type TweetHelp struct {
yesql.Namespace `yesql:"tweet_help"`
GetPostContentByIds string `yesql:"get_post_content_by_ids"`
GetUsersByIds string `yesql:"get_users_by_ids"`
}
type TweetHelpA struct {
yesql.Namespace `yesql:"tweet_help_a"`
UserInfo string `yesql:"user_info"`
}
type TweetManage struct {
yesql.Namespace `yesql:"tweet_manage"`
CommentMediaFromCommentIds string `yesql:"comment_media_from_comment_ids"`
@ -426,11 +334,6 @@ type TweetManage struct {
UpdatePost *sqlx.NamedStmt `yesql:"update_post"`
}
type TweetManageA struct {
yesql.Namespace `yesql:"tweet_manage_a"`
UserInfo string `yesql:"user_info"`
}
type UserManage struct {
yesql.Namespace `yesql:"user_manage"`
GetUsersByIds string `yesql:"get_users_by_ids"`
@ -459,22 +362,6 @@ type Wallet struct {
NewPostBill *sqlx.Stmt `yesql:"new_post_bill"`
}
func BuildYesql(p PreparexBuilder, ctx ...context.Context) (obj *Yesql, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &Yesql{
TagsFromNames: p.QueryHook(_TagsFromNames),
}
if obj.UpdateTagQuote, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_UpdateTagQuote))); err != nil {
return
}
return
}
func BuildAuthorizationManage(p PreparexBuilder, ctx ...context.Context) (obj *AuthorizationManage, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
@ -727,13 +614,6 @@ func BuildShipIndex(p PreparexBuilder, ctx ...context.Context) (obj *ShipIndex,
return
}
func BuildShipIndexA(p PreparexBuilder) (obj *ShipIndexA, err error) {
obj = &ShipIndexA{
UserInfo: p.QueryHook(_ShipIndexA_UserInfo),
}
return
}
func BuildSimpleIndex(p PreparexBuilder, ctx ...context.Context) (obj *SimpleIndex, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
@ -751,64 +631,6 @@ func BuildSimpleIndex(p PreparexBuilder, ctx ...context.Context) (obj *SimpleInd
return
}
func BuildSimpleIndexA(p PreparexBuilder) (obj *SimpleIndexA, err error) {
obj = &SimpleIndexA{
UserInfo: p.QueryHook(_SimpleIndexA_UserInfo),
}
return
}
func BuildTopicA(p PreparexBuilder, ctx ...context.Context) (obj *TopicA, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &TopicA{
DecrTagsById: p.QueryHook(_TopicA_DecrTagsById),
IncrTagsById: p.QueryHook(_TopicA_IncrTagsById),
TagsByIdA: p.QueryHook(_TopicA_TagsByIdA),
TagsByIdB: p.QueryHook(_TopicA_TagsByIdB),
TagsForIncr: p.QueryHook(_TopicA_TagsForIncr),
TopicInfos: p.QueryHook(_TopicA_TopicInfos),
}
if obj.ExistTopicUser, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_ExistTopicUser))); err != nil {
return
}
if obj.FollowTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_FollowTags))); err != nil {
return
}
if obj.FollowTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_FollowTopic))); err != nil {
return
}
if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_HotTags))); err != nil {
return
}
if obj.InsertTag, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_InsertTag))); err != nil {
return
}
if obj.NewestTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_NewestTags))); err != nil {
return
}
if obj.StickTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_StickTopic))); err != nil {
return
}
if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TagsByKeywordA))); err != nil {
return
}
if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TagsByKeywordB))); err != nil {
return
}
if obj.TopicIsTop, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_TopicIsTop))); err != nil {
return
}
if obj.UnfollowTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_UnfollowTopic))); err != nil {
return
}
return
}
func BuildTweet(p PreparexBuilder, ctx ...context.Context) (obj *Tweet, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
@ -913,24 +735,6 @@ func BuildTweet(p PreparexBuilder, ctx ...context.Context) (obj *Tweet, err erro
return
}
func BuildTweetA(p PreparexBuilder) (obj *TweetA, err error) {
obj = &TweetA{
AttachmentByTweetId: p.QueryHook(_TweetA_AttachmentByTweetId),
FavoriteByTweetId: p.QueryHook(_TweetA_FavoriteByTweetId),
ReactionByTweetId: p.QueryHook(_TweetA_ReactionByTweetId),
TweetInfoById: p.QueryHook(_TweetA_TweetInfoById),
TweetItemById: p.QueryHook(_TweetA_TweetItemById),
UserFavorites: p.QueryHook(_TweetA_UserFavorites),
UserInfo: p.QueryHook(_TweetA_UserInfo),
UserReactions: p.QueryHook(_TweetA_UserReactions),
UserTweetsByAdmin: p.QueryHook(_TweetA_UserTweetsByAdmin),
UserTweetsByFriend: p.QueryHook(_TweetA_UserTweetsByFriend),
UserTweetsByGuest: p.QueryHook(_TweetA_UserTweetsByGuest),
UserTweetsBySelf: p.QueryHook(_TweetA_UserTweetsBySelf),
}
return
}
func BuildTweetHelp(p PreparexBuilder) (obj *TweetHelp, err error) {
obj = &TweetHelp{
GetPostContentByIds: p.QueryHook(_TweetHelp_GetPostContentByIds),
@ -939,13 +743,6 @@ func BuildTweetHelp(p PreparexBuilder) (obj *TweetHelp, err error) {
return
}
func BuildTweetHelpA(p PreparexBuilder) (obj *TweetHelpA, err error) {
obj = &TweetHelpA{
UserInfo: p.QueryHook(_TweetHelpA_UserInfo),
}
return
}
func BuildTweetManage(p PreparexBuilder, ctx ...context.Context) (obj *TweetManage, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
@ -1012,13 +809,6 @@ func BuildTweetManage(p PreparexBuilder, ctx ...context.Context) (obj *TweetMana
return
}
func BuildTweetManageA(p PreparexBuilder) (obj *TweetManageA, err error) {
obj = &TweetManageA{
UserInfo: p.QueryHook(_TweetManageA_UserInfo),
}
return
}
func BuildUserManage(p PreparexBuilder, ctx ...context.Context) (obj *UserManage, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {

@ -0,0 +1,57 @@
// Code generated by Yesql. DO NOT EDIT.
// versions:
// - Yesql v1.8.4
package yesql
import (
"context"
"github.com/bitbus/sqlx"
)
const (
_TagsFromNames = `SELECT * FROM @tag WHERE tag IN (?) AND is_del=0`
_UpdateTagQuote = `UPDATE @tag SET quote_num=?, modified_on=? WHERE id=? AND is_del=0`
)
// PreparexContext enhances the Conn interface with context.
type PreparexContext interface {
// PrepareContext prepares a statement.
// The provided context is used for the preparation of the statement, not for
// the execution of the statement.
PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
// PrepareNamedContext returns an sqlx.NamedStmt
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
// Rebind rebind query to adapte SQL Driver
Rebind(query string) string
}
// PreparexBuilder preparex builder interface for sqlx
type PreparexBuilder interface {
PreparexContext
QueryHook(query string) string
}
type Yesql struct {
TagsFromNames string `yesql:"tags_from_names"`
UpdateTagQuote *sqlx.Stmt `yesql:"update_tag_quote"`
}
func BuildYesql(p PreparexBuilder, ctx ...context.Context) (obj *Yesql, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &Yesql{
TagsFromNames: p.QueryHook(_TagsFromNames),
}
if obj.UpdateTagQuote, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_UpdateTagQuote))); err != nil {
return
}
return
}

@ -13,7 +13,7 @@ import (
"github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
"github.com/rocboss/paopao-ce/pkg/types"
)
@ -374,13 +374,13 @@ func (s *commentManageSrv) ThumbsDownReply(userId int64, tweetId, commentId, rep
func newCommentService(db *sqlx.DB) core.CommentService {
return &commentSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildComment),
q: ccBuild(db, cc.BuildComment),
}
}
func newCommentManageService(db *sqlx.DB) core.CommentManageService {
return &commentManageSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildCommentManage),
q: ccBuild(db, cc.BuildCommentManage),
}
}

@ -11,7 +11,7 @@ import (
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs"
"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/auto/cc"
"github.com/sirupsen/logrus"
)
@ -182,6 +182,6 @@ func (s *contactManageSrv) fetchOrNewContact(tx *sqlx.Tx, userId int64, friendId
func newContactManageService(db *sqlx.DB) core.ContactManageService {
return &contactManageSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildContactManager),
q: ccBuild(db, cc.BuildContactManager),
}
}

@ -10,7 +10,7 @@ import (
"github.com/bitbus/sqlx"
"github.com/rocboss/paopao-ce/internal/core"
"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/auto/cc"
)
var (
@ -97,6 +97,6 @@ func (s *followingManageSrv) IsFollow(userId int64, followId int64) (yn bool) {
func newFollowingManageService(db *sqlx.DB) core.FollowingManageService {
return &followingManageSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildFollowingManager),
q: ccBuild(db, cc.BuildFollowingManager),
}
}

@ -11,7 +11,7 @@ import (
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
)
var (
@ -75,6 +75,6 @@ func (s *messageSrv) GetMessageCount(r *ms.ConditionsT) (res int64, err error) {
func newMessageService(db *sqlx.DB) core.MessageService {
return &messageSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildMessage),
q: ccBuild(db, cc.BuildMessage),
}
}

@ -13,7 +13,7 @@ import (
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
)
var (
@ -63,7 +63,7 @@ func (s *securitySrv) SendPhoneCaptcha(phone string) error {
func newSecurityService(db *sqlx.DB, phoneVerify core.PhoneVerifyService) core.SecurityService {
return &securitySrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildSecurity),
q: ccBuild(db, cc.BuildSecurity),
rand: rand.New(rand.NewSource(time.Now().UnixNano())),
phoneVerify: phoneVerify,
}

@ -11,7 +11,9 @@ import (
"github.com/alimy/yesql"
"github.com/bitbus/sqlx"
"github.com/rocboss/paopao-ce/internal/conf"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
yc "github.com/rocboss/paopao-ce/internal/dao/sakila/auto"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/ac"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
"github.com/sirupsen/logrus"
)
@ -22,13 +24,13 @@ var (
type sqlxSrv struct {
db *sqlx.DB
y *cc.Yesql
y *yc.Yesql
}
func newSqlxSrv(db *sqlx.DB) *sqlxSrv {
return &sqlxSrv{
db: db,
y: mustBuild(db, cc.BuildYesql),
y: mustBuild(db, yc.BuildYesql),
}
}
@ -92,7 +94,7 @@ func yesqlScan[T any](query yesql.SQLQuery, obj T) T {
return obj
}
func mustBuild[T any](db *sqlx.DB, fn func(cc.PreparexBuilder, ...context.Context) (T, error)) T {
func mustBuild[T any](db *sqlx.DB, fn func(yc.PreparexBuilder, ...context.Context) (T, error)) T {
p := yesql.NewPreparexBuilder(db, t)
obj, err := fn(p)
if err != nil {
@ -101,7 +103,43 @@ func mustBuild[T any](db *sqlx.DB, fn func(cc.PreparexBuilder, ...context.Contex
return obj
}
func mustBuildFn[T any](db *sqlx.DB, fn func(cc.PreparexBuilder) (T, error)) T {
func mustBuildFn[T any](db *sqlx.DB, fn func(yc.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 acBuild[T any](db *sqlx.DB, fn func(ac.PreparexBuilder, ...context.Context) (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 acBuildFn[T any](db *sqlx.DB, fn func(ac.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 ccBuild[T any](db *sqlx.DB, fn func(cc.PreparexBuilder, ...context.Context) (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 ccBuildFn[T any](db *sqlx.DB, fn func(cc.PreparexBuilder) (T, error)) T {
p := yesql.NewPreparexBuilder(db, t)
obj, err := fn(p)
if err != nil {

@ -9,7 +9,8 @@ import (
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs"
"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/auto/ac"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
"github.com/rocboss/paopao-ce/pkg/debug"
"github.com/sirupsen/logrus"
)
@ -39,13 +40,13 @@ type shipIndexSrvA struct {
*sqlxSrv
ams core.AuthorizationManageService
ths core.TweetHelpServantA
q *cc.ShipIndexA
q *ac.ShipIndexA
}
type simpleIndexPostsSrvA struct {
*sqlxSrv
ths core.TweetHelpServantA
q *cc.SimpleIndexA
q *ac.SimpleIndexA
}
// IndexPosts 根据userId查询广场推文列表简单做到不同用户的主页都是不同的
@ -115,7 +116,7 @@ func newShipIndexService(db *sqlx.DB, ams core.AuthorizationManageService, ths c
ams: ams,
ths: ths,
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildShipIndex),
q: ccBuild(db, cc.BuildShipIndex),
}
}
@ -123,7 +124,7 @@ func newSimpleIndexPostsService(db *sqlx.DB, ths core.TweetHelpService) core.Ind
return &simpleIndexPostsSrv{
ths: ths,
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildSimpleIndex),
q: ccBuild(db, cc.BuildSimpleIndex),
}
}
@ -133,7 +134,7 @@ func newShipIndexServantA(db *sqlx.DB, ams core.AuthorizationManageService, ths
ams: ams,
ths: ths,
sqlxSrv: newSqlxSrv(db),
q: mustBuildFn(db, cc.BuildShipIndexA),
q: acBuildFn(db, ac.BuildShipIndexA),
}
}
@ -142,6 +143,6 @@ func newSimpleIndexPostsServantA(db *sqlx.DB, ths core.TweetHelpServantA) core.I
return &simpleIndexPostsSrvA{
ths: ths,
sqlxSrv: newSqlxSrv(db),
q: mustBuildFn(db, cc.BuildSimpleIndexA),
q: acBuildFn(db, ac.BuildSimpleIndexA),
}
}

@ -11,7 +11,7 @@ import (
"github.com/bitbus/sqlx"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/ac"
)
var (
@ -26,7 +26,7 @@ type topicInfo struct {
type topicSrvA struct {
*sqlxSrv
q *cc.TopicA
q *ac.TopicA
}
func (s *topicSrvA) UpsertTags(userId int64, tags []string) (res cs.TagInfoList, xerr error) {
@ -190,13 +190,13 @@ func (s *topicSrvA) tagsFormatA(userId int64, tags cs.TagList) (cs.TagList, erro
func newTopicService(db *sqlx.DB) core.TopicService {
return &topicSrvA{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildTopicA),
q: acBuild(db, ac.BuildTopicA),
}
}
func newTopicServantA(db *sqlx.DB) core.TopicServantA {
return &topicSrvA{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildTopicA),
q: acBuild(db, ac.BuildTopicA),
}
}

@ -13,18 +13,13 @@ import (
"github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
"github.com/rocboss/paopao-ce/pkg/debug"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
)
var (
_ core.TweetService = (*tweetSrv)(nil)
_ core.TweetManageService = (*tweetManageSrv)(nil)
_ core.TweetHelpService = (*tweetHelpSrv)(nil)
_ core.TweetServantA = (*tweetSrvA)(nil)
_ core.TweetManageServantA = (*tweetManageSrvA)(nil)
_ core.TweetHelpServantA = (*tweetHelpSrvA)(nil)
)
type tweetSrv struct {
@ -43,22 +38,6 @@ type tweetHelpSrv struct {
q *cc.TweetHelp
}
type tweetSrvA struct {
*sqlxSrv
q *cc.TweetA
}
type tweetManageSrvA struct {
*sqlxSrv
cis core.CacheIndexService
q *cc.TweetManageA
}
type tweetHelpSrvA struct {
*sqlxSrv
q *cc.TweetHelpA
}
// MergePosts post数据整合
func (s *tweetHelpSrv) MergePosts(posts []*ms.Post) ([]*ms.PostFormated, error) {
postIds := make([]int64, 0, len(posts))
@ -480,110 +459,10 @@ func (s *tweetSrv) GetPostContentByID(id int64) (res *ms.PostContent, err error)
return
}
func (s *tweetSrvA) TweetInfoById(id int64) (*cs.TweetInfo, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) TweetItemById(id int64) (*cs.TweetItem, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) UserTweets(visitorId, userId int64) (res cs.TweetList, err error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetManageSrvA) CreateAttachment(obj *cs.Attachment) (int64, error) {
// TODO
return 0, debug.ErrNotImplemented
}
func (s *tweetManageSrvA) CreateTweet(userId int64, req *cs.NewTweetReq) (*cs.TweetItem, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetManageSrvA) DeleteTweet(userId int64, tweetId int64) ([]string, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetManageSrvA) LockTweet(userId int64, tweetId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) StickTweet(userId int64, tweetId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) VisibleTweet(userId int64, visibility cs.TweetVisibleType) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) CreateReaction(userId int64, tweetId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) DeleteReaction(userId int64, reactionId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) CreateFavorite(userId int64, tweetId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) DeleteFavorite(userId int64, favoriteId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetHelpSrvA) RevampTweets(tweets cs.TweetList) (cs.TweetList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetHelpSrvA) MergeTweets(tweets cs.TweetInfo) (cs.TweetList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func newTweetService(db *sqlx.DB) core.TweetService {
return &tweetSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildTweet),
q: ccBuild(db, cc.BuildTweet),
}
}
@ -591,35 +470,13 @@ func newTweetManageService(db *sqlx.DB, cacheIndex core.CacheIndexService) core.
return &tweetManageSrv{
sqlxSrv: newSqlxSrv(db),
cis: cacheIndex,
q: mustBuild(db, cc.BuildTweetManage),
q: ccBuild(db, cc.BuildTweetManage),
}
}
func newTweetHelpService(db *sqlx.DB) core.TweetHelpService {
return &tweetHelpSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuildFn(db, cc.BuildTweetHelp),
}
}
func newTweetServantA(db *sqlx.DB) core.TweetServantA {
return &tweetSrvA{
sqlxSrv: newSqlxSrv(db),
q: mustBuildFn(db, cc.BuildTweetA),
}
}
func newTweetManageServantA(db *sqlx.DB, cacheIndex core.CacheIndexService) core.TweetManageServantA {
return &tweetManageSrvA{
sqlxSrv: newSqlxSrv(db),
cis: cacheIndex,
q: mustBuildFn(db, cc.BuildTweetManageA),
}
}
func newTweetHelpServantA(db *sqlx.DB) core.TweetHelpServantA {
return &tweetHelpSrvA{
sqlxSrv: newSqlxSrv(db),
q: mustBuildFn(db, cc.BuildTweetHelpA),
q: ccBuildFn(db, cc.BuildTweetHelp),
}
}

@ -0,0 +1,157 @@
// Copyright 2023 ROC. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package sakila
import (
"github.com/bitbus/sqlx"
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/cs"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/ac"
"github.com/rocboss/paopao-ce/pkg/debug"
)
var (
_ core.TweetServantA = (*tweetSrvA)(nil)
_ core.TweetManageServantA = (*tweetManageSrvA)(nil)
_ core.TweetHelpServantA = (*tweetHelpSrvA)(nil)
)
type tweetSrvA struct {
*sqlxSrv
q *ac.TweetA
}
type tweetManageSrvA struct {
*sqlxSrv
cis core.CacheIndexService
q *ac.TweetManageA
}
type tweetHelpSrvA struct {
*sqlxSrv
q *ac.TweetHelpA
}
func (s *tweetSrvA) TweetInfoById(id int64) (*cs.TweetInfo, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) TweetItemById(id int64) (*cs.TweetItem, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) UserTweets(visitorId, userId int64) (res cs.TweetList, err error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) UserReactions(userId int64, limit int, offset int) (cs.ReactionList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) FavoriteByTweetId(userId int64, tweetId int64) (*cs.FavoriteItem, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) UserFavorites(userId int64, limit int, offset int) (cs.FavoriteList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetSrvA) AttachmentByTweetId(userId int64, tweetId int64) (*cs.AttachmentBill, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetManageSrvA) CreateAttachment(obj *cs.Attachment) (int64, error) {
// TODO
return 0, debug.ErrNotImplemented
}
func (s *tweetManageSrvA) CreateTweet(userId int64, req *cs.NewTweetReq) (*cs.TweetItem, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetManageSrvA) DeleteTweet(userId int64, tweetId int64) ([]string, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetManageSrvA) LockTweet(userId int64, tweetId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) StickTweet(userId int64, tweetId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) VisibleTweet(userId int64, visibility cs.TweetVisibleType) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) CreateReaction(userId int64, tweetId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) DeleteReaction(userId int64, reactionId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) CreateFavorite(userId int64, tweetId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetManageSrvA) DeleteFavorite(userId int64, favoriteId int64) error {
// TODO
return debug.ErrNotImplemented
}
func (s *tweetHelpSrvA) RevampTweets(tweets cs.TweetList) (cs.TweetList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func (s *tweetHelpSrvA) MergeTweets(tweets cs.TweetInfo) (cs.TweetList, error) {
// TODO
return nil, debug.ErrNotImplemented
}
func newTweetServantA(db *sqlx.DB) core.TweetServantA {
return &tweetSrvA{
sqlxSrv: newSqlxSrv(db),
q: acBuildFn(db, ac.BuildTweetA),
}
}
func newTweetManageServantA(db *sqlx.DB, cacheIndex core.CacheIndexService) core.TweetManageServantA {
return &tweetManageSrvA{
sqlxSrv: newSqlxSrv(db),
cis: cacheIndex,
q: acBuildFn(db, ac.BuildTweetManageA),
}
}
func newTweetHelpServantA(db *sqlx.DB) core.TweetHelpServantA {
return &tweetHelpSrvA{
sqlxSrv: newSqlxSrv(db),
q: acBuildFn(db, ac.BuildTweetHelpA),
}
}

@ -11,7 +11,7 @@ import (
"github.com/bitbus/sqlx"
"github.com/rocboss/paopao-ce/internal/core"
"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/auto/cc"
)
var (
@ -73,6 +73,6 @@ func (s *userManageSrv) UpdateUser(r *ms.User) error {
func newUserManageService(db *sqlx.DB) core.UserManageService {
return &userManageSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildUserManage),
q: ccBuild(db, cc.BuildUserManage),
}
}

@ -12,7 +12,7 @@ import (
"github.com/rocboss/paopao-ce/internal/core"
"github.com/rocboss/paopao-ce/internal/core/ms"
"github.com/rocboss/paopao-ce/internal/dao/jinzhu/dbr"
"github.com/rocboss/paopao-ce/internal/dao/sakila/yesql/cc"
"github.com/rocboss/paopao-ce/internal/dao/sakila/auto/cc"
)
var (
@ -126,6 +126,6 @@ func (s *walletSrv) HandlePostAttachmentBought(post *ms.Post, user *ms.User) err
func newWalletService(db *sqlx.DB) core.WalletService {
return &walletSrv{
sqlxSrv: newSqlxSrv(db),
q: mustBuild(db, cc.BuildWallet),
q: ccBuild(db, cc.BuildWallet),
}
}

@ -21,7 +21,13 @@ func main() {
query.Query = strings.TrimRight(query.Query, ";")
return query, nil
})
if err := yesql.Generate("yesql.sql", "cc", "cc", yesql.SqlxPkgName("github.com/bitbus/sqlx")); err != nil {
opt := yesql.SqlxPkgName("github.com/bitbus/sqlx")
sqlInfos := []yesql.SqlInfo{
yesql.NewSqlInfo("yesql.sql", "../auto", "yesql"),
yesql.NewSqlInfo("yesql_ac.sql", "../auto/ac", "ac"),
yesql.NewSqlInfo("yesql_cc.sql", "../auto/cc", "cc"),
}
if err := yesql.GenerateFrom(sqlInfos, opt); err != nil {
log.Fatalf("generate code occurs error: %s", err)
}
log.Println("[Yesql] generate code finish")

File diff suppressed because it is too large Load Diff

@ -0,0 +1,226 @@
--------------------------------------------------------------------------------
-- file yesql_ac.sql
-- this sql file define all sql dml for next "A" version data logic
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- ship_index_a sql dml
--------------------------------------------------------------------------------
-- name: user_info@ship_index_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
--------------------------------------------------------------------------------
-- simple_index_a sql dml
--------------------------------------------------------------------------------
-- name: user_info@simple_index_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
--------------------------------------------------------------------------------
-- tweet_a sql dml
--------------------------------------------------------------------------------
-- name: user_info@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: tweet_info_by_id@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: tweet_item_by_id@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: user_tweets_by_admin@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: user_tweets_by_self@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: user_tweets_by_friend@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: user_tweets_by_guest@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: reaction_by_tweet_id@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: user_reactions@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: favorite_by_tweet_id@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: user_favorites@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
-- name: attachment_by_tweet_id@tweet_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
--------------------------------------------------------------------------------
-- tweet_manage_a sql dml
--------------------------------------------------------------------------------
-- name: user_info@tweet_manage_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
--------------------------------------------------------------------------------
-- tweet_help_a sql dml
--------------------------------------------------------------------------------
-- name: user_info@tweet_help_a
-- prepare: raw
SELECT * FROM @user WHERE username=?
--------------------------------------------------------------------------------
-- topic_a sql dml
--------------------------------------------------------------------------------
-- name: newest_tags@topic_a
-- get newest tag information
-- prepare: stmt
SELECT t.id id,
t.user_id user_id,
t.tag tag,
t.quote_num quote_num,
u.id "u.id",
u.nickname "u.nickname",
u.username "u.username",
u.status "u.status",
u.avatar "u.avatar",
u.is_admin "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.id DESC
LIMIT ? OFFSET ?;
-- name: hot_tags@topic_a
-- get get host tag information
-- prepare: stmt
SELECT t.id id,
t.user_id user_id,
t.tag tag,
t.quote_num quote_num,
u.id "u.id",
u.nickname "u.nickname",
u.username "u.username",
u.status "u.status",
u.avatar "u.avatar",
u.is_admin "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 ?;
-- name: follow_tags@topic_a
-- get get follow tag information
-- prepare: stmt
SELECT t.id id,
t.user_id user_id,
t.tag tag,
t.quote_num quote_num,
u.id "u.id",
1 as is_following,
c.is_top,
u.nickname "u.nickname",
u.username "u.username",
u.status "u.status",
u.avatar "u.avatar",
u.is_admin "u.is_admin"
FROM @topic_user c
JOIN @user u ON c.user_id = u.id
JOIN @tag t ON c.topic_id = t.id
WHERE c.is_del = 0 AND t.quote_num > 0 AND AND c.user_id=?
ORDER BY t.quote_num DESC
LIMIT ? OFFSET ?;
-- name: topic_infos@topic_a
-- prepare: raw
-- clause: in
SELECT topic_id, is_top
FROM @topic_user
WHERE is_del=0 AND user_id=? AND topic_id IN ?;
-- name: exist_topic_user@topic_a
-- prepare: stmt
SELECT 1 FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0;
-- name: follow_topic@topic_a
-- prepare: stmt
INSERT INTO @topic_user(user_id, topic_id, created_on) VALUES (?, ?, ?)
-- name: unfollow_topic@topic_a
-- prepare: stmt
UPDATE @topic_user
SET is_del=1, deleted_on=?
WHERE user_id=? AND topic_id=? AND is_del=0;
-- name: stick_topic@topic_a
-- prepare: stmt
UPDATE @topic_user
SET is_top=1-is_top; modified_on=?
WHERE user_id=? AND topic_id=? AND is_del=0;
-- name: topic_is_top@topic_a
-- prepare: stmt
SELECT is_top FROM @topic_user WHERE user_id=? AND topic_id=? AND is_del=0;
-- name: tags_by_keyword_a@topic_a
-- get tags by keyword
SELECT id, user_id, tag, quote_num
FROM @tag
WHERE is_del = 0
ORDER BY quote_num DESC
LIMIT 6;
-- name: tags_by_keyword_b@topic_a
SELECT id, user_id, tag, quote_num
FROM @tag WHERE is_del = 0 AND tag LIKE ?
ORDER BY quote_num DESC
LIMIT 6;
-- name: insert_tag@topic_a
INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num)
VALUES (?, ?, ?, ?, 1);
-- name: tags_by_id_a@topic_a
-- prepare: raw
-- clause: in
SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0;
-- name: tags_by_id_b@topic_a
-- prepare: raw
-- clause: in
SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?);
-- name: decr_tags_by_id@topic_a
-- prepare: raw
-- clause: in
UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?);
-- name: tags_for_incr@topic_a
-- prepare: raw
-- clause: in
SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?);
-- name: incr_tags_by_id@topic_a
-- prepare: raw
-- clause: in
UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?);

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save