sqlx: add miss method for tweet data logic WIP: 95%

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

@ -263,9 +263,23 @@ func (s *tweetManageSrv) StickPost(r *ms.Post) error {
return err
}
func (s *tweetManageSrv) HighlightPost(userId, postId int64) (int, error) {
// TODO
return 0, cs.ErrNotImplemented
func (s *tweetManageSrv) HighlightPost(userId, postId int64) (is_essence int, err error) {
err = s.with(func(tx *sqlx.Tx) error {
var postUserId int64
err = tx.Stmtx(s.q.PostHighlightStatus).QueryRowx(postId).Scan(&postUserId, &is_essence)
if err != nil {
return err
}
if postUserId != userId {
return cs.ErrNoPermission
}
if _, err = tx.Stmtx(s.q.HighlightPost).Exec(postId); err != nil {
return err
}
is_essence = 1 - is_essence
return nil
})
return
}
func (s *tweetManageSrv) VisiblePost(post *ms.Post, visibility core.PostVisibleT) (err error) {
@ -370,19 +384,65 @@ func (s *tweetSrv) GetUserPostStars(userID int64, limit int, offset int) (res []
return
}
func (s *tweetSrv) ListUserStarTweets(user *cs.VistUser, limit int, offset int) ([]*ms.PostStar, int64, error) {
// TODO
return nil, 0, cs.ErrNotImplemented
func (s *tweetSrv) ListUserStarTweets(user *cs.VistUser, limit int, offset int) (res []*ms.PostStar, total int64, err error) {
switch user.RelTyp {
case cs.RelationAdmin:
if err = s.q.UserStarTweetsByAdmin.Select(&res, user.UserId, limit, offset); err == nil {
err = s.q.UserStarTweetsCountByAdmin.Get(&total, user.UserId)
}
case cs.RelationSelf:
// Fixed: 这里的查询有Bug没有考虑查询Friend star 时如果对方已经不是你好友时应该去除这个star
if err = s.q.UserStarTweetsBySelf.Select(&res, user.UserId, user.UserId, limit, offset); err == nil {
err = s.q.UserStarTweetsCountByAdmin.Get(&total, user.UserId, user.UserId)
}
case cs.RelationFriend:
if err = s.q.UserStarTweetsByFriend.Select(&res, user.UserId, limit, offset); err == nil {
err = s.q.UserStarTweetsByFriend.Get(&total, user.UserId)
}
case cs.RelationGuest:
fallthrough
default:
if err = s.q.UserStarTweetsByGuest.Select(&res, user.UserId, limit, offset); err == nil {
err = s.q.UserStarTweetsCountByGuest.Get(&total, user.UserId)
}
}
return
}
func (s *tweetSrv) ListUserMediaTweets(user *cs.VistUser, limit int, offset int) ([]*ms.Post, int64, error) {
// TODO
return nil, 0, cs.ErrNotImplemented
func (s *tweetSrv) ListUserMediaTweets(user *cs.VistUser, limit int, offset int) (res []*ms.Post, total int64, err error) {
gStmt, cStmt := s.q.UserMediaTweetsByGuest, s.q.UserMediaTweetsCountByGuest
switch user.RelTyp {
case cs.RelationAdmin, cs.RelationSelf:
gStmt, cStmt = s.q.UserMediaTweetsBySelf, s.q.UserMediaTweetsCountBySelf
case cs.RelationFriend:
gStmt, cStmt = s.q.UserMediaTweetsByFriend, s.q.UserMediaTweetsCountByFriend
case cs.RelationGuest:
fallthrough
default:
// nothing
}
if err = gStmt.Select(&res, user.UserId, limit, offset); err == nil {
err = cStmt.Get(&total, user.UserId)
}
return
}
func (s *tweetSrv) ListUserCommentTweets(user *cs.VistUser, limit int, offset int) ([]*ms.Post, int64, error) {
// TODO
return nil, 0, cs.ErrNotImplemented
func (s *tweetSrv) ListUserCommentTweets(user *cs.VistUser, limit int, offset int) (res []*ms.Post, total int64, err error) {
gStmt, cStmt := s.q.UserCommentTweetsByGuest, s.q.UserCommentTweetsCountByGuest
switch user.RelTyp {
case cs.RelationAdmin, cs.RelationSelf:
gStmt, cStmt = s.q.UserCommentTweetsBySelf, s.q.UserCommentTweetsCountBySelf
case cs.RelationFriend:
gStmt, cStmt = s.q.UserCommentTweetsByFriend, s.q.UserCommentTweetsCountByFriend
case cs.RelationGuest:
fallthrough
default:
// nothing
}
if err = gStmt.Select(&res, user.UserId, limit, offset); err == nil {
err = cStmt.Get(&total, user.UserId)
}
return
}
func (s *tweetSrv) GetUserPostStarCount(userID int64) (res int64, err error) {
@ -435,12 +495,6 @@ func (s *tweetSrvA) UserTweets(visitorId, userId int64) (res cs.TweetList, err e
return nil, debug.ErrNotImplemented
}
// checkRelationBy check the relation of visitor with user
func (s *tweetSrvA) checkRelationBy(visitorId, userId int64) uint {
// TODO
return 0
}
func (s *tweetSrvA) ReactionByTweetId(userId int64, tweetId int64) (*cs.ReactionItem, error) {
// TODO
return nil, debug.ErrNotImplemented

@ -123,11 +123,33 @@ const (
_TweetManage_DelPostCollection = `UPDATE @post_collection SET is_del=1, deleted_on=? WHERE id=? AND is_del=0`
_TweetManage_DelPostStar = `UPDATE @post_star SET is_del=1, deleted_on=? WHERE id=? AND is_del=0`
_TweetManage_DelReplyByCommentIds = `UPDATE @comment_reply SET deleted_on=?, is_del=1 WHERE comment_id IN (?) AND is_del=0`
_TweetManage_HighlightPost = `UPDATE @post SET is_essence=1-is_essence WHERE id=? AND is_del=0`
_TweetManage_LockPost = `UPDATE @post SET is_lock=1-is_lock, modified_on=? WHERE id=? AND is_del=0`
_TweetManage_MediaContentByPostId = `SELECT content FROM post_content WHERE post_id=? AND is_del=0 AND type IN (3, 4, 5, 7, 8)`
_TweetManage_PostHighlightStatus = `SELECT user_id, is_essence FROM @post WHERE id=? AND is_del=0`
_TweetManage_StickPost = `UPDATE @post SET is_top=1-is_top, modified_on=? WHERE id=? AND is_del=0`
_TweetManage_UpdatePost = `UPDATE @post SET comment_count=:comment_count, upvote_count=:upvote_count, collection_count=:collection_count, latest_replies_on=:latest_replies_on, modified_on=:modified_on WHERE id=:id AND is_del=0`
_TweetManage_VisiblePost = `UPDATE @post SET visibility=?, is_top=?, modified_on=? WHERE id=? AND is_del=0`
_Tweet_UserCommentTweetsByFriend = `SELECT * FROM @post_by_comment WHERE is_del=0 AND comment_user_id=? AND (visibility=0 OR visibility=2) ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserCommentTweetsByGuest = `SELECT * FROM @post_by_comment WHERE is_del=0 AND comment_user_id=? AND visibility=0 ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserCommentTweetsBySelf = `SELECT * FROM @post_by_comment WHERE is_del=0 AND comment_user_id=? ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserCommentTweetsCountByFriend = `SELECT count(*) FROM @post_by_comment WHERE is_del=0 AND comment_user_id=? AND (visibility=0 OR visibility=2)`
_Tweet_UserCommentTweetsCountByGuest = `SELECT count(*) FROM @post_by_comment WHERE is_del=0 AND comment_user_id=? AND visibility=0`
_Tweet_UserCommentTweetsCountBySelf = `SELECT count(*) FROM @post_by_comment WHERE is_del=0 AND comment_user_id=?`
_Tweet_UserMediaTweetsByFriend = `SELECT * FROM @post_by_media WHERE is_del=0 AND user_id=? AND (visibility=0 OR visibility=2) ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserMediaTweetsByGuest = `SELECT * FROM @post_by_media WHERE is_del=0 AND user_id=? AND visibility=0 ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserMediaTweetsBySelf = `SELECT * FROM @post_by_media WHERE is_del=0 AND user_id=? ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserMediaTweetsCountByFriend = `SELECT count(*) FROM @post_by_media WHERE is_del=0 AND user_id=? AND (visibility=0 OR visibility=2)`
_Tweet_UserMediaTweetsCountByGuest = `SELECT count(*) FROM @post_by_media WHERE is_del=0 AND user_id=? AND visibility=0`
_Tweet_UserMediaTweetsCountBySelf = `SELECT count(*) FROM @post_by_media WHERE is_del=0 AND user_id=?`
_Tweet_UserStarTweetsByAdmin = `SELECT star.*, post.ID "post.id", post.created_on "post.created_on", post.modified_on "post.modified_on", post.deleted_on "post.deleted_on", post.is_del "post.is_del", post.user_id "post.user_id", post.comment_count "post.comment_count", post.collection_count "post.collection_count", post.share_count "post.share_count", post.upvote_count "post.upvote_count", post.visibility "post.visibility", post.is_top "post.is_top", post.is_essence "post.is_essence", post.is_lock "post.is_lock", post.latest_replied_on "post.latest_replied_on", post.tags "post.tags", post.attachment_price "post.attachment_price", post.ip "post.ip", post.ip_loc "post.ip_loc" FROM @post_star star JOIN @post post ON star.post_id = post.ID WHERE star.is_del=0 AND star.user_id=? ORDER BY post.latest_replied_on DESC; LIMIT ? OFFSET ?`
_Tweet_UserStarTweetsByFriend = `SELECT star.*, post.ID "post.id", post.created_on "post.created_on", post.modified_on "post.modified_on", post.deleted_on "post.deleted_on", post.is_del "post.is_del", post.user_id "post.user_id", post.comment_count "post.comment_count", post.collection_count "post.collection_count", post.share_count "post.share_count", post.upvote_count "post.upvote_count", post.visibility "post.visibility", post.is_top "post.is_top", post.is_essence "post.is_essence", post.is_lock "post.is_lock", post.latest_replied_on "post.latest_replied_on", post.tags "post.tags", post.attachment_price "post.attachment_price", post.ip "post.ip", post.ip_loc "post.ip_loc" FROM @post_star star JOIN @post post ON star.post_id = post.ID WHERE star.is_del=0 AND star.user_id=? AND (post.visibility=0 OR post.visibility=2) ORDER BY post.latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserStarTweetsByGuest = `SELECT star.*, post.ID "post.id", post.created_on "post.created_on", post.modified_on "post.modified_on", post.deleted_on "post.deleted_on", post.is_del "post.is_del", post.user_id "post.user_id", post.comment_count "post.comment_count", post.collection_count "post.collection_count", post.share_count "post.share_count", post.upvote_count "post.upvote_count", post.visibility "post.visibility", post.is_top "post.is_top", post.is_essence "post.is_essence", post.is_lock "post.is_lock", post.latest_replied_on "post.latest_replied_on", post.tags "post.tags", post.attachment_price "post.attachment_price", post.ip "post.ip", post.ip_loc "post.ip_loc" FROM @post_star star JOIN @post post ON star.post_id = post.ID WHERE star.is_del = 0 AND star.user_id =? AND post.visibility = 0 ORDER BY post.latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserStarTweetsBySelf = `SELECT star.*, post.ID "post.id", post.created_on "post.created_on", post.modified_on "post.modified_on", post.deleted_on "post.deleted_on", post.is_del "post.is_del", post.user_id "post.user_id", post.comment_count "post.comment_count", post.collection_count "post.collection_count", post.share_count "post.share_count", post.upvote_count "post.upvote_count", post.visibility "post.visibility", post.is_top "post.is_top", post.is_essence "post.is_essence", post.is_lock "post.is_lock", post.latest_replied_on "post.latest_replied_on", post.tags "post.tags", post.attachment_price "post.attachment_price", post.ip "post.ip", post.ip_loc "post.ip_loc" FROM @post_star star JOIN @post post ON star.post_id = post.ID WHERE star.is_del=0 AND star.user_id=? AND (post.visibility<>0 (post.visibility=0 AND post.user_id=?)) ORDER BY post.latest_replied_on DESC; LIMIT ? OFFSET ?`
_Tweet_UserStarTweetsCountByAdmin = `SELECT count(*) FROM @post_star star JOIN @post post ON star.post_id = post.ID WHERE star.is_del=0 AND star.user_id=?`
_Tweet_UserStarTweetsCountByFriend = `SELECT count(*) FROM @post_star star JOIN @post post ON star.post_id = post.ID WHERE star.is_del=0 AND star.user_id=? AND (post.visibility=0 OR post.visibility=2)`
_Tweet_UserStarTweetsCountByGuest = `SELECT count(*) FROM @post_star star JOIN @post post ON star.post_id = post.ID WHERE star.is_del=0 AND star.user_id=? AND post.visibility=0`
_Tweet_UserStarTweetsCountBySelf = `SELECT count(*) FROM @post_star star JOIN @post post ON star.post_id = post.ID WHERE star.is_del=0 AND star.user_id=? AND (post.visibility<>0 (post.visibility=0 AND post.user_id=?))`
_UserManage_CreateUser = `INSERT INTO @user (username, nickname, password, salt, avatar, status, created_on) VALUES (:username, :nickname, :password, :salt, :avatar, :status, :created_on)`
_UserManage_GetAnyUsers = `SELECT * FROM @user WHERE is_del=0 ORDER BY id ASC limit 6`
_UserManage_GetUserById = `SELECT * FROM @user WHERE id=? AND is_del=0`
@ -270,21 +292,41 @@ type TopicA struct {
}
type Tweet struct {
yesql.Namespace `yesql:"tweet"`
GetAnyPostCount string `yesql:"get_any_post_count"`
GetAnyPosts string `yesql:"get_any_posts"`
GetPostContentsByIds string `yesql:"get_post_contents_by_ids"`
GetUserPostCount string `yesql:"get_user_post_count"`
GetUserPosts string `yesql:"get_user_posts"`
GetPostAttachmentBill *sqlx.Stmt `yesql:"get_post_attachment_bill"`
GetPostById *sqlx.Stmt `yesql:"get_post_by_id"`
GetPostContentById *sqlx.Stmt `yesql:"get_post_content_by_id"`
GetUserPostCollection *sqlx.Stmt `yesql:"get_user_post_collection"`
GetUserPostCollectionCount *sqlx.Stmt `yesql:"get_user_post_collection_count"`
GetUserPostCollections *sqlx.Stmt `yesql:"get_user_post_collections"`
GetUserPostStar *sqlx.Stmt `yesql:"get_user_post_star"`
GetUserPostStarCount *sqlx.Stmt `yesql:"get_user_post_star_count"`
GetUserPostStars *sqlx.Stmt `yesql:"get_user_post_stars"`
yesql.Namespace `yesql:"tweet"`
GetAnyPostCount string `yesql:"get_any_post_count"`
GetAnyPosts string `yesql:"get_any_posts"`
GetPostContentsByIds string `yesql:"get_post_contents_by_ids"`
GetUserPostCount string `yesql:"get_user_post_count"`
GetUserPosts string `yesql:"get_user_posts"`
GetPostAttachmentBill *sqlx.Stmt `yesql:"get_post_attachment_bill"`
GetPostById *sqlx.Stmt `yesql:"get_post_by_id"`
GetPostContentById *sqlx.Stmt `yesql:"get_post_content_by_id"`
GetUserPostCollection *sqlx.Stmt `yesql:"get_user_post_collection"`
GetUserPostCollectionCount *sqlx.Stmt `yesql:"get_user_post_collection_count"`
GetUserPostCollections *sqlx.Stmt `yesql:"get_user_post_collections"`
GetUserPostStar *sqlx.Stmt `yesql:"get_user_post_star"`
GetUserPostStarCount *sqlx.Stmt `yesql:"get_user_post_star_count"`
GetUserPostStars *sqlx.Stmt `yesql:"get_user_post_stars"`
UserCommentTweetsByFriend *sqlx.Stmt `yesql:"user_comment_tweets_by_friend"`
UserCommentTweetsByGuest *sqlx.Stmt `yesql:"user_comment_tweets_by_guest"`
UserCommentTweetsBySelf *sqlx.Stmt `yesql:"user_comment_tweets_by_self"`
UserCommentTweetsCountByFriend *sqlx.Stmt `yesql:"user_comment_tweets_count_by_friend"`
UserCommentTweetsCountByGuest *sqlx.Stmt `yesql:"user_comment_tweets_count_by_guest"`
UserCommentTweetsCountBySelf *sqlx.Stmt `yesql:"user_comment_tweets_count_by_self"`
UserMediaTweetsByFriend *sqlx.Stmt `yesql:"user_media_tweets_by_friend"`
UserMediaTweetsByGuest *sqlx.Stmt `yesql:"user_media_tweets_by_guest"`
UserMediaTweetsBySelf *sqlx.Stmt `yesql:"user_media_tweets_by_self"`
UserMediaTweetsCountByFriend *sqlx.Stmt `yesql:"user_media_tweets_count_by_friend"`
UserMediaTweetsCountByGuest *sqlx.Stmt `yesql:"user_media_tweets_count_by_guest"`
UserMediaTweetsCountBySelf *sqlx.Stmt `yesql:"user_media_tweets_count_by_self"`
UserStarTweetsByAdmin *sqlx.Stmt `yesql:"user_star_tweets_by_admin"`
UserStarTweetsByFriend *sqlx.Stmt `yesql:"user_star_tweets_by_friend"`
UserStarTweetsByGuest *sqlx.Stmt `yesql:"user_star_tweets_by_guest"`
UserStarTweetsBySelf *sqlx.Stmt `yesql:"user_star_tweets_by_self"`
UserStarTweetsCountByAdmin *sqlx.Stmt `yesql:"user_star_tweets_count_by_admin"`
UserStarTweetsCountByFriend *sqlx.Stmt `yesql:"user_star_tweets_count_by_friend"`
UserStarTweetsCountByGuest *sqlx.Stmt `yesql:"user_star_tweets_count_by_guest"`
UserStarTweetsCountBySelf *sqlx.Stmt `yesql:"user_star_tweets_count_by_self"`
}
type TweetA struct {
@ -327,8 +369,10 @@ type TweetManage struct {
DelPostById *sqlx.Stmt `yesql:"del_post_by_id"`
DelPostCollection *sqlx.Stmt `yesql:"del_post_collection"`
DelPostStar *sqlx.Stmt `yesql:"del_post_star"`
HighlightPost *sqlx.Stmt `yesql:"highlight_post"`
LockPost *sqlx.Stmt `yesql:"lock_post"`
MediaContentByPostId *sqlx.Stmt `yesql:"media_content_by_post_id"`
PostHighlightStatus *sqlx.Stmt `yesql:"post_highlight_status"`
StickPost *sqlx.Stmt `yesql:"stick_post"`
VisiblePost *sqlx.Stmt `yesql:"visible_post"`
AddPost *sqlx.NamedStmt `yesql:"add_post"`
@ -723,6 +767,66 @@ func BuildTweet(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Tweet, er
if obj.GetUserPostStars, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_GetUserPostStars))); err != nil {
return
}
if obj.UserCommentTweetsByFriend, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserCommentTweetsByFriend))); err != nil {
return
}
if obj.UserCommentTweetsByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserCommentTweetsByGuest))); err != nil {
return
}
if obj.UserCommentTweetsBySelf, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserCommentTweetsBySelf))); err != nil {
return
}
if obj.UserCommentTweetsCountByFriend, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserCommentTweetsCountByFriend))); err != nil {
return
}
if obj.UserCommentTweetsCountByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserCommentTweetsCountByGuest))); err != nil {
return
}
if obj.UserCommentTweetsCountBySelf, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserCommentTweetsCountBySelf))); err != nil {
return
}
if obj.UserMediaTweetsByFriend, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserMediaTweetsByFriend))); err != nil {
return
}
if obj.UserMediaTweetsByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserMediaTweetsByGuest))); err != nil {
return
}
if obj.UserMediaTweetsBySelf, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserMediaTweetsBySelf))); err != nil {
return
}
if obj.UserMediaTweetsCountByFriend, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserMediaTweetsCountByFriend))); err != nil {
return
}
if obj.UserMediaTweetsCountByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserMediaTweetsCountByGuest))); err != nil {
return
}
if obj.UserMediaTweetsCountBySelf, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserMediaTweetsCountBySelf))); err != nil {
return
}
if obj.UserStarTweetsByAdmin, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserStarTweetsByAdmin))); err != nil {
return
}
if obj.UserStarTweetsByFriend, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserStarTweetsByFriend))); err != nil {
return
}
if obj.UserStarTweetsByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserStarTweetsByGuest))); err != nil {
return
}
if obj.UserStarTweetsBySelf, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserStarTweetsBySelf))); err != nil {
return
}
if obj.UserStarTweetsCountByAdmin, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserStarTweetsCountByAdmin))); err != nil {
return
}
if obj.UserStarTweetsCountByFriend, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserStarTweetsCountByFriend))); err != nil {
return
}
if obj.UserStarTweetsCountByGuest, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserStarTweetsCountByGuest))); err != nil {
return
}
if obj.UserStarTweetsCountBySelf, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Tweet_UserStarTweetsCountBySelf))); err != nil {
return
}
return
}
@ -795,12 +899,18 @@ func BuildTweetManage(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Twe
if obj.DelPostStar, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_DelPostStar))); err != nil {
return
}
if obj.HighlightPost, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_HighlightPost))); err != nil {
return
}
if obj.LockPost, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_LockPost))); err != nil {
return
}
if obj.MediaContentByPostId, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_MediaContentByPostId))); err != nil {
return
}
if obj.PostHighlightStatus, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_PostHighlightStatus))); err != nil {
return
}
if obj.StickPost, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_StickPost))); err != nil {
return
}

@ -565,6 +565,245 @@ WHERE post_id IN (?) AND is_del=0;
-- prepare: stmt
SELECT * FROM @post_content WHERE id=? AND is_del=0;
-- name: user_media_tweets_by_guest@tweet
-- prepare: stmt
SELECT *
FROM @post_by_media
WHERE is_del=0 AND user_id=? AND visibility=0
ORDER BY latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_media_tweets_count_by_guest@tweet
-- prepare: stmt
SELECT count(*)
FROM @post_by_media
WHERE is_del=0 AND user_id=? AND visibility=0;
-- name: user_media_tweets_by_friend@tweet
-- prepare: stmt
SELECT *
FROM @post_by_media
WHERE is_del=0 AND user_id=? AND (visibility=0 OR visibility=2)
ORDER BY latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_media_tweets_count_by_friend@tweet
-- prepare: stmt
SELECT count(*)
FROM @post_by_media
WHERE is_del=0 AND user_id=? AND (visibility=0 OR visibility=2);
-- name: user_media_tweets_by_self@tweet
-- prepare: stmt
SELECT *
FROM @post_by_media
WHERE is_del=0 AND user_id=?
ORDER BY latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_media_tweets_count_by_self@tweet
-- prepare: stmt
SELECT count(*)
FROM @post_by_media
WHERE is_del=0 AND user_id=?;
-- name: user_comment_tweets_by_guest@tweet
-- prepare: stmt
SELECT *
FROM @post_by_comment
WHERE is_del=0 AND comment_user_id=? AND visibility=0
ORDER BY latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_comment_tweets_count_by_guest@tweet
-- prepare: stmt
SELECT count(*)
FROM @post_by_comment
WHERE is_del=0 AND comment_user_id=? AND visibility=0;
-- name: user_comment_tweets_by_friend@tweet
-- prepare: stmt
SELECT *
FROM @post_by_comment
WHERE is_del=0 AND comment_user_id=? AND (visibility=0 OR visibility=2)
ORDER BY latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_comment_tweets_count_by_friend@tweet
-- prepare: stmt
SELECT count(*)
FROM @post_by_comment
WHERE is_del=0 AND comment_user_id=? AND (visibility=0 OR visibility=2);
-- name: user_comment_tweets_by_self@tweet
-- prepare: stmt
SELECT *
FROM @post_by_comment
WHERE is_del=0 AND comment_user_id=?
ORDER BY latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_comment_tweets_count_by_self@tweet
-- prepare: stmt
SELECT count(*)
FROM @post_by_comment
WHERE is_del=0 AND comment_user_id=?;
-- name: user_star_tweets_by_guest@tweet
-- prepare: stmt
SELECT
star.*,
post.ID "post.id",
post.created_on "post.created_on",
post.modified_on "post.modified_on",
post.deleted_on "post.deleted_on",
post.is_del "post.is_del",
post.user_id "post.user_id",
post.comment_count "post.comment_count",
post.collection_count "post.collection_count",
post.share_count "post.share_count",
post.upvote_count "post.upvote_count",
post.visibility "post.visibility",
post.is_top "post.is_top",
post.is_essence "post.is_essence",
post.is_lock "post.is_lock",
post.latest_replied_on "post.latest_replied_on",
post.tags "post.tags",
post.attachment_price "post.attachment_price",
post.ip "post.ip",
post.ip_loc "post.ip_loc"
FROM
@post_star star
JOIN @post post ON star.post_id = post.ID
WHERE
star.is_del = 0
AND star.user_id =?
AND post.visibility = 0
ORDER BY post.latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_star_tweets_count_by_guest@tweet
-- prepare: stmt
SELECT count(*)
FROM
@post_star star
JOIN @post post ON star.post_id = post.ID
WHERE star.is_del=0 AND star.user_id=? AND post.visibility=0;
-- name: user_star_tweets_by_friend@tweet
-- prepare: stmt
SELECT
star.*,
post.ID "post.id",
post.created_on "post.created_on",
post.modified_on "post.modified_on",
post.deleted_on "post.deleted_on",
post.is_del "post.is_del",
post.user_id "post.user_id",
post.comment_count "post.comment_count",
post.collection_count "post.collection_count",
post.share_count "post.share_count",
post.upvote_count "post.upvote_count",
post.visibility "post.visibility",
post.is_top "post.is_top",
post.is_essence "post.is_essence",
post.is_lock "post.is_lock",
post.latest_replied_on "post.latest_replied_on",
post.tags "post.tags",
post.attachment_price "post.attachment_price",
post.ip "post.ip",
post.ip_loc "post.ip_loc"
FROM
@post_star star
JOIN @post post ON star.post_id = post.ID
WHERE star.is_del=0 AND star.user_id=? AND (post.visibility=0 OR post.visibility=2)
ORDER BY post.latest_replied_on DESC
LIMIT ? OFFSET ?;
-- name: user_star_tweets_count_by_friend@tweet
-- prepare: stmt
SELECT count(*)
FROM
@post_star star
JOIN @post post ON star.post_id = post.ID
WHERE star.is_del=0 AND star.user_id=? AND (post.visibility=0 OR post.visibility=2);
-- name: user_star_tweets_by_self@tweet
-- prepare: stmt
SELECT
star.*,
post.ID "post.id",
post.created_on "post.created_on",
post.modified_on "post.modified_on",
post.deleted_on "post.deleted_on",
post.is_del "post.is_del",
post.user_id "post.user_id",
post.comment_count "post.comment_count",
post.collection_count "post.collection_count",
post.share_count "post.share_count",
post.upvote_count "post.upvote_count",
post.visibility "post.visibility",
post.is_top "post.is_top",
post.is_essence "post.is_essence",
post.is_lock "post.is_lock",
post.latest_replied_on "post.latest_replied_on",
post.tags "post.tags",
post.attachment_price "post.attachment_price",
post.ip "post.ip",
post.ip_loc "post.ip_loc"
FROM
@post_star star
JOIN @post post ON star.post_id = post.ID
WHERE star.is_del=0 AND star.user_id=? AND (post.visibility<>0 (post.visibility=0 AND post.user_id=?))
ORDER BY post.latest_replied_on DESC;
LIMIT ? OFFSET ?;
-- name: user_star_tweets_count_by_self@tweet
-- prepare: stmt
SELECT count(*)
FROM
@post_star star
JOIN @post post ON star.post_id = post.ID
WHERE star.is_del=0 AND star.user_id=? AND (post.visibility<>0 (post.visibility=0 AND post.user_id=?));
-- name: user_star_tweets_by_admin@tweet
-- prepare: stmt
SELECT
star.*,
post.ID "post.id",
post.created_on "post.created_on",
post.modified_on "post.modified_on",
post.deleted_on "post.deleted_on",
post.is_del "post.is_del",
post.user_id "post.user_id",
post.comment_count "post.comment_count",
post.collection_count "post.collection_count",
post.share_count "post.share_count",
post.upvote_count "post.upvote_count",
post.visibility "post.visibility",
post.is_top "post.is_top",
post.is_essence "post.is_essence",
post.is_lock "post.is_lock",
post.latest_replied_on "post.latest_replied_on",
post.tags "post.tags",
post.attachment_price "post.attachment_price",
post.ip "post.ip",
post.ip_loc "post.ip_loc"
FROM
@post_star star
JOIN @post post ON star.post_id = post.ID
WHERE star.is_del=0 AND star.user_id=?
ORDER BY post.latest_replied_on DESC;
LIMIT ? OFFSET ?;
-- name: user_star_tweets_count_by_admin@tweet
-- prepare: stmt
SELECT count(*)
FROM
@post_star star
JOIN @post post ON star.post_id = post.ID
WHERE star.is_del=0 AND star.user_id=?;
--------------------------------------------------------------------------------
-- tweet_manage sql dml
--------------------------------------------------------------------------------
@ -594,6 +833,14 @@ UPDATE @post SET is_top=1-is_top, modified_on=? WHERE id=? AND is_del=0;
-- prepare: stmt
UPDATE @post SET visibility=?, is_top=?, modified_on=? WHERE id=? AND is_del=0;
-- name: highlight_post@tweet_manage
-- prepare: stmt
UPDATE @post SET is_essence=1-is_essence WHERE id=? AND is_del=0;
-- name: post_highlight_status@tweet_manage
-- prepare: stmt
SELECT user_id, is_essence FROM @post WHERE id=? AND is_del=0;
-- name: update_post@tweet_manage
-- prepare: named_stmt
UPDATE @post SET comment_count=:comment_count,

Loading…
Cancel
Save