sqlx: tweet logic is implemented complete. WIP %85

r/paopao-ce-plus
Michael Li 1 year ago
parent b203ab3541
commit 2f9077c941
No known key found for this signature in database

@ -13,7 +13,7 @@ import (
type PostCollection struct {
*Model
Post *Post `json:"-"`
Post *Post `db:"post" json:"-"`
PostID int64 `db:"post_id" json:"post_id"`
UserID int64 `db:"user_id" json:"user_id"`
}

@ -13,7 +13,7 @@ import (
type PostStar struct {
*Model
Post *Post `json:"-"`
Post *Post `db:"post" json:"-"`
PostID int64 `json:"post_id"`
UserID int64 `json:"user_id"`
}

@ -225,9 +225,32 @@ func (s *tweetManageSrv) DeletePost(post *ms.Post) (mediaContents []string, err
return
}
func (s *tweetManageSrv) deleteCommentByPostId(tx *sqlx.Tx, postId int64) ([]string, error) {
// TODO
return nil, nil
func (s *tweetManageSrv) deleteCommentByPostId(tx *sqlx.Tx, postId int64) (mediaContents []string, err error) {
var commentIds []int64
// 获取推文的所有评论id
err = tx.Stmtx(s.q.CommentIdsByPostId).Select(&commentIds, postId)
if err != nil {
return nil, err
}
// 获取评论的媒体内容
err = s.inSelectx(tx, &mediaContents, s.q.CommentMediaFromCommentIds, commentIds)
if err != nil {
return nil, err
}
// 删评论
now := time.Now().Unix()
if _, err = tx.Stmtx(s.q.DelCommentByPostId).Exec(now, postId); err != nil {
return nil, err
}
// 删评论内容
if _, err = s.inExecx(tx, s.q.DelCommentContentByCommentIds, now, commentIds); err != nil {
return nil, err
}
// 删评论的评论
if _, err = s.inExecx(tx, s.q.DelReplyByCommentIds, now, commentIds); err != nil {
return nil, err
}
return
}
func (s *tweetManageSrv) LockPost(r *ms.Post) error {
@ -332,44 +355,39 @@ func (s *tweetSrv) GetPostCount(c ms.ConditionsT) (res int64, err error) {
return
}
func (s *tweetSrv) GetUserPostStar(postID, userID int64) (*ms.PostStar, error) {
res := &ms.PostStar{}
err := s.q.GetUserPostStar.Get(res, postID, userID)
return res, err
func (s *tweetSrv) GetUserPostStar(postID, userID int64) (res *ms.PostStar, err error) {
err = s.q.GetUserPostStar.Get(res, postID, userID, userID)
return
}
func (s *tweetSrv) GetUserPostStars(userID int64, offset, limit int) ([]*ms.PostStar, error) {
res := []*ms.PostStar{}
err := s.q.GetUserPostStar.Select(&res, userID, limit, offset)
return res, err
func (s *tweetSrv) GetUserPostStars(userID int64, offset, limit int) (res []*ms.PostStar, err error) {
err = s.q.GetUserPostStar.Select(&res, userID, userID, limit, offset)
return
}
func (s *tweetSrv) GetUserPostStarCount(userID int64) (res int64, err error) {
err = s.q.GetUserPostStarCount.Get(&res, userID)
err = s.q.GetUserPostStarCount.Get(&res, userID, userID)
return
}
func (s *tweetSrv) GetUserPostCollection(postID, userID int64) (*ms.PostCollection, error) {
res := &ms.PostCollection{}
err := s.q.GetUserPostCollection.Get(res, postID, userID)
return res, err
func (s *tweetSrv) GetUserPostCollection(postID, userID int64) (res *ms.PostCollection, err error) {
err = s.q.GetUserPostCollection.Get(res, postID, userID, userID)
return
}
func (s *tweetSrv) GetUserPostCollections(userID int64, offset, limit int) ([]*ms.PostCollection, error) {
res := []*ms.PostCollection{}
err := s.q.GetUserPostCollections.Select(&res, userID, limit, offset)
func (s *tweetSrv) GetUserPostCollections(userID int64, offset, limit int) (res []*ms.PostCollection, err error) {
err = s.q.GetUserPostCollections.Select(&res, userID, userID, limit, offset)
return res, err
}
func (s *tweetSrv) GetUserPostCollectionCount(userID int64) (res int64, err error) {
err = s.q.GetUserPostCollectionCount.Get(&res)
err = s.q.GetUserPostCollectionCount.Get(&res, userID, userID)
return
}
func (s *tweetSrv) GetPostAttatchmentBill(postID, userID int64) (*ms.PostAttachmentBill, error) {
res := &ms.PostAttachmentBill{}
err := s.q.GetPostAttachmentBill.Get(res, postID, userID)
return res, err
func (s *tweetSrv) GetPostAttatchmentBill(postID, userID int64) (res *ms.PostAttachmentBill, err error) {
err = s.q.GetPostAttachmentBill.Get(res, postID, userID)
return
}
func (s *tweetSrv) GetPostContentsByIDs(ids []int64) (res []*ms.PostContent, err error) {
@ -377,10 +395,9 @@ func (s *tweetSrv) GetPostContentsByIDs(ids []int64) (res []*ms.PostContent, err
return
}
func (s *tweetSrv) GetPostContentByID(id int64) (*ms.PostContent, error) {
res := &ms.PostContent{}
err := s.q.GetPostContentById.Get(res, id)
return res, err
func (s *tweetSrv) GetPostContentByID(id int64) (res *ms.PostContent, err error) {
err = s.q.GetPostContentById.Get(res, id)
return
}
func (s *tweetSrvA) TweetInfoById(id int64) (*cs.TweetInfo, error) {

@ -12,134 +12,139 @@ 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`
_Comment_GetCommentById = `SELECT * FROM @comment WHERE id=? AND is_del=0`
_Comment_GetCommentContentsByIds = `SELECT * FROM @comment_content WHERE comment_id IN (?)`
_Comment_GetCommentCount = `SELECT count(*) FROM @comment WHERE post_id=:post_id AND is_del=0`
_Comment_GetCommentReplyById = `SELECT * FROM @comment_reply WHERE id=? AND is_del=0`
_Comment_GetCommentThumbs = `SELECT * FROM @tweet_comment_thumbs WHERE user_id=? AND tweet_id=?`
_Comment_GetComments = `SELECT * FROM @comment WHERE post_id=? AND is_del=0 ORDER BY %order% LIMIT ? OFFSET ?`
_Comment_GetCommmentRepliesByIds = `SELECT * FROM @comment_reply WHERE comment_id IN (?) ORDER BY id ASC`
_Comment_GetUsersByIds = `SELECT id, nickname, username, status, avatar, is_admin FROM @user WHERE id IN (?)`
_CommentManage_CreateComment = `INSERT INTO @comment (post_id, user_id, ip, ip_loc, created_on) VALUES (?, ?, ?, ?, ?)`
_CommentManage_CreateCommentContent = `INSERT INTO @comment_content (comment_id, user_id, content, type, sort, created_on) VALUES (?, ?, ?, ?, ?, ?)`
_CommentManage_CreateCommentReply = `INSERT INTO @comment_reply (comment_id, user_id, content, at_user_id, ip, ip_loc, created_on) VALUES (?, ?, ?, ?, ?, ?, ?)`
_CommentManage_CreateThumbsUpdownComment = `INSERT INTO @tweet_comment_thumbs (user_id, tweet_id, comment_id, reply_id, is_thumbs_up, is_thumbs_down, comment_type, created_on) VALUES (:user_id, :tweet_id, :comment_id, :reply_id, :is_thumbs_up, :is_thumbs_down, :comment_type, :created_on)`
_CommentManage_DeleteComment = `UPDATE @comment SET deleted_on=?, is_del=1 WHERE id=? AND is_del=0`
_CommentManage_DeleteCommentReply = `UPDATE @comment_reply SET deleted_on=?, is_del=1 WHERE id=? AND is_del=0`
_CommentManage_DeleteCommentThumbs = `UPDATE @tweet_comment_thumbs SET deleted_on=?, is_del=1 WHERE user_id=? AND tweet_id=? AND comment_id=? AND is_del=0`
_CommentManage_DeleteReplyThumbs = `UPDATE @tweet_comment_thumbs SET deleted_on=?, is_del=1 WHERE user_id=? AND comment_id=? AND reply_id=? AND is_del=0`
_CommentManage_GetCommentReplyThumb = `SELECT * FROM @tweet_comment_thumbs WHERE user_id=? AND tweet_id=? AND comment_id=? AND reply_id=? AND comment_type=1 AND is_del=0`
_CommentManage_GetTweetCommentThumb = `SELECT * FROM @tweet_comment_thumbs WHERE user_id=? AND tweet_id=? AND comment_id=? AND comment_type=0 AND is_del=0`
_CommentManage_UpdateCommentThumbsCount = `UPDATE @comment SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? WHERE id=? AND is_del=0`
_CommentManage_UpdateReplyThumbsCount = `UPDATE @comment_reply SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? WHERE id=? AND is_del=0`
_CommentManage_UpdateThumbsUpdownComment = `UPDATE @tweet_comment_thumbs SET is_thumbs_up=:is_thumbs_up, is_thumbs_down=:is_thumbs_down, modified_on=:modified_on WHERE id=:id AND is_del=0`
_ContactManager_AddFriendMsgsUpdate = `UPDATE @message SET reply_id=?, modified_on=? WHERE ((sender_user_id = ? AND receiver_user_id = ?) OR (sender_user_id = ? AND receiver_user_id = ?)) AND type = ? AND reply_id = ?`
_ContactManager_CreateContact = `INSERT INTO @contact (user_id, friend_id, status, created_on) VALUES (?, ?, ?, ?)`
_ContactManager_CreateMessage = `INSERT INTO @message (sender_user_id, receiver_user_id, type, brief, content, reply_id, created_on) VALUES (:sender_user_id, :receiver_user_id, :type, :brief, :content, :reply_id, :created_on)`
_ContactManager_DelFriend = `UPDATE @contact SET status=4, is_del=1, deleted_on=? WHERE id=?`
_ContactManager_FreshContactStatus = `UPDATE @contact SET status=?, modified_on=?, is_del=0 WHERE id=?`
_ContactManager_GetContact = `SELECT id, user_id, friend_id, group_id, remark, status, is_top, is_black, notice_enable, is_del FROM @contact WHERE user_id=? AND friend_id=?`
_ContactManager_GetContacts = `SELECT id, user_id, friend_id, group_id, remark, status, is_top, is_black, notice_enable, is_del FROM @contact WHERE (user_id=? AND friend_id=?) OR (user_id=? AND friend_id=?)`
_ContactManager_GetUserFriend = `SELECT id, user_id, friend_id, group_id, remark, status, is_top, is_black, notice_enable, is_del FROM @contact WHERE user_id=? AND friend_id=? AND is_del=0`
_ContactManager_IsFriend = `SELECT true FROM @contact WHERE user_id=? AND friend_id=? AND is_del=0 AND status=2`
_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_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=?`
_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_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_GetMessages = `SELECT * FROM @message WHERE receiver_user_id=:recerver_user_id AND is_del=0 ORDER BY id DESC LIMIT :limit OFFSET :offset`
_Message_GetUnreadCount = `SELECT count(*) FROM @message WHERE receiver_user_id=? AND is_read=0 AND is_del=0`
_Message_ReadMessage = `UPDATE @message SET is_read=1, modified_on=? WHERE id=?`
_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`
_SimpleIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_SimpleIndex_UserInfo = `SELECT * FROM @user WHERE username=?`
_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_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.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.id DESC LIMIT ? OFFSET ?`
_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 (?)`
_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 @user WHERE username=?`
_Tweet_GetPostById = `SELECT * FROM @post WHERE id=? AND is_del=0`
_Tweet_GetPostContentById = `SELECT * FROM @user WHERE username=?`
_Tweet_GetPostContentsByIds = `SELECT * FROM @post_content WHERE post_id IN (?) AND is_del=0`
_Tweet_GetUserPostCollection = `SELECT * FROM @user WHERE username=?`
_Tweet_GetUserPostCollectionCount = `SELECT * FROM @user WHERE username=?`
_Tweet_GetUserPostCollections = `SELECT * FROM @user WHERE username=?`
_Tweet_GetUserPostCount = `SELECT count(*) FROM @post WHERE user_id=? AND visibility IN (?)`
_Tweet_GetUserPostStar = `SELECT * FROM @user WHERE username=?`
_Tweet_GetUserPostStarCount = `SELECT * FROM @user WHERE username=?`
_Tweet_GetUserPostStars = `SELECT * FROM @user WHERE username=?`
_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 (?, ?, ?)`
_TweetManage_AddPostContent = `INSERT INTO @post_content (post_id, user_id, content, type, sort, created_on) VALUES (:post_id, :user_id, :content, :type, :sort, :created_on)`
_TweetManage_AddPostStar = `INSERT INTO @post_star (post_id, user_id, created_on) VALUES (?, ?, ?)`
_TweetManage_DelPostById = `UPDATE @post SET is_del=1, deleted_on=? WHERE id=? AND is_del=0`
_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_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_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`
_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`
_UserManage_GetUserByPhone = `SELECT * FROM @user WHERE phone=? AND is_del=0`
_UserManage_GetUserByUsername = `SELECT * FROM @user WHERE username=? AND is_del=0`
_UserManage_GetUsersByIds = `SELECT * FROM @user WHERE id IN (?) AND is_del=0`
_UserManage_GetUsersByKeyword = `SELECT * FROM @user WHERE username LIKE ? AND is_del=0 limit 6`
_UserManage_UpdateUser = `UPDATE @user SET username=:username, nickname=:nickname, phone=:phone, password=:password, salt=:salt, status=:status, avatar=:avatar, balance=:balance, is_admin=:is_admin, modified_on=:modified_on WHERE id=? AND is_del=0`
_Wallet_AddUserBalance = `UPDATE @user SET balance=balance+?, modified_on=? WHERE id=? AND is_del=0`
_Wallet_CreateRecharge = `INSERT INTO @wallet_recharge (user_id, amount, created_on) VALUES (?, ?, ?)`
_Wallet_CreateWalletStatement = `INSERT INTO @wallet_statement (user_id, change_amount, balance_snapshot, reason, created_on) VALUES (?, ?, ?, ?, ?)`
_Wallet_GetRechargeById = `SELECT * FROM @wallet_recharge WHERE id=? AND is_del=?`
_Wallet_GetUserBalance = `SELECT balance FROM @user WHERE id=? AND is_del=0`
_Wallet_GetUserByUid = `SELECT * FROM @user WHERE id=? AND is_del=0`
_Wallet_GetUserWalletBillCount = `SELECT count(*) FROM @wallet_statement WHERE user_id=? AND is_del=0`
_Wallet_GetUserWalletBills = `SELECT * FROM @wallet_statement WHERE user_id=? AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Wallet_MarkSuccessRecharge = `UPDATE @wallet_recharge SET trade_no=?, trade_status='TRADE_SUCCESS', modified_on=? WHERE id=? AND is_del=0`
_Wallet_MinusUserBalance = `UPDATE @user SET balance=balance-?, modified_on=? WHERE id=? AND is_del=0`
_Wallet_NewPostAttachmentBill = `INSERT INTO @post_attachment_bill (post_id, user_id, paid_amount, created_on) VALUES (?, ?, ?, ?)`
_Wallet_NewPostBill = `INSERT INTO @wallet_statement (post_id, user_id, change_amount, balance_snapshot, reason, created_on) VALUES (?, ?, ?, ?, ?, ?)`
_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`
_Comment_GetCommentById = `SELECT * FROM @comment WHERE id=? AND is_del=0`
_Comment_GetCommentContentsByIds = `SELECT * FROM @comment_content WHERE comment_id IN (?)`
_Comment_GetCommentCount = `SELECT count(*) FROM @comment WHERE post_id=:post_id AND is_del=0`
_Comment_GetCommentReplyById = `SELECT * FROM @comment_reply WHERE id=? AND is_del=0`
_Comment_GetCommentThumbs = `SELECT * FROM @tweet_comment_thumbs WHERE user_id=? AND tweet_id=?`
_Comment_GetComments = `SELECT * FROM @comment WHERE post_id=? AND is_del=0 ORDER BY %order% LIMIT ? OFFSET ?`
_Comment_GetCommmentRepliesByIds = `SELECT * FROM @comment_reply WHERE comment_id IN (?) ORDER BY id ASC`
_Comment_GetUsersByIds = `SELECT id, nickname, username, status, avatar, is_admin FROM @user WHERE id IN (?)`
_CommentManage_CreateComment = `INSERT INTO @comment (post_id, user_id, ip, ip_loc, created_on) VALUES (?, ?, ?, ?, ?)`
_CommentManage_CreateCommentContent = `INSERT INTO @comment_content (comment_id, user_id, content, type, sort, created_on) VALUES (?, ?, ?, ?, ?, ?)`
_CommentManage_CreateCommentReply = `INSERT INTO @comment_reply (comment_id, user_id, content, at_user_id, ip, ip_loc, created_on) VALUES (?, ?, ?, ?, ?, ?, ?)`
_CommentManage_CreateThumbsUpdownComment = `INSERT INTO @tweet_comment_thumbs (user_id, tweet_id, comment_id, reply_id, is_thumbs_up, is_thumbs_down, comment_type, created_on) VALUES (:user_id, :tweet_id, :comment_id, :reply_id, :is_thumbs_up, :is_thumbs_down, :comment_type, :created_on)`
_CommentManage_DeleteComment = `UPDATE @comment SET deleted_on=?, is_del=1 WHERE id=? AND is_del=0`
_CommentManage_DeleteCommentReply = `UPDATE @comment_reply SET deleted_on=?, is_del=1 WHERE id=? AND is_del=0`
_CommentManage_DeleteCommentThumbs = `UPDATE @tweet_comment_thumbs SET deleted_on=?, is_del=1 WHERE user_id=? AND tweet_id=? AND comment_id=? AND is_del=0`
_CommentManage_DeleteReplyThumbs = `UPDATE @tweet_comment_thumbs SET deleted_on=?, is_del=1 WHERE user_id=? AND comment_id=? AND reply_id=? AND is_del=0`
_CommentManage_GetCommentReplyThumb = `SELECT * FROM @tweet_comment_thumbs WHERE user_id=? AND tweet_id=? AND comment_id=? AND reply_id=? AND comment_type=1 AND is_del=0`
_CommentManage_GetTweetCommentThumb = `SELECT * FROM @tweet_comment_thumbs WHERE user_id=? AND tweet_id=? AND comment_id=? AND comment_type=0 AND is_del=0`
_CommentManage_UpdateCommentThumbsCount = `UPDATE @comment SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? WHERE id=? AND is_del=0`
_CommentManage_UpdateReplyThumbsCount = `UPDATE @comment_reply SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? WHERE id=? AND is_del=0`
_CommentManage_UpdateThumbsUpdownComment = `UPDATE @tweet_comment_thumbs SET is_thumbs_up=:is_thumbs_up, is_thumbs_down=:is_thumbs_down, modified_on=:modified_on WHERE id=:id AND is_del=0`
_ContactManager_AddFriendMsgsUpdate = `UPDATE @message SET reply_id=?, modified_on=? WHERE ((sender_user_id = ? AND receiver_user_id = ?) OR (sender_user_id = ? AND receiver_user_id = ?)) AND type = ? AND reply_id = ?`
_ContactManager_CreateContact = `INSERT INTO @contact (user_id, friend_id, status, created_on) VALUES (?, ?, ?, ?)`
_ContactManager_CreateMessage = `INSERT INTO @message (sender_user_id, receiver_user_id, type, brief, content, reply_id, created_on) VALUES (:sender_user_id, :receiver_user_id, :type, :brief, :content, :reply_id, :created_on)`
_ContactManager_DelFriend = `UPDATE @contact SET status=4, is_del=1, deleted_on=? WHERE id=?`
_ContactManager_FreshContactStatus = `UPDATE @contact SET status=?, modified_on=?, is_del=0 WHERE id=?`
_ContactManager_GetContact = `SELECT id, user_id, friend_id, group_id, remark, status, is_top, is_black, notice_enable, is_del FROM @contact WHERE user_id=? AND friend_id=?`
_ContactManager_GetContacts = `SELECT id, user_id, friend_id, group_id, remark, status, is_top, is_black, notice_enable, is_del FROM @contact WHERE (user_id=? AND friend_id=?) OR (user_id=? AND friend_id=?)`
_ContactManager_GetUserFriend = `SELECT id, user_id, friend_id, group_id, remark, status, is_top, is_black, notice_enable, is_del FROM @contact WHERE user_id=? AND friend_id=? AND is_del=0`
_ContactManager_IsFriend = `SELECT true FROM @contact WHERE user_id=? AND friend_id=? AND is_del=0 AND status=2`
_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_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=?`
_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_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_GetMessages = `SELECT * FROM @message WHERE receiver_user_id=:recerver_user_id AND is_del=0 ORDER BY id DESC LIMIT :limit OFFSET :offset`
_Message_GetUnreadCount = `SELECT count(*) FROM @message WHERE receiver_user_id=? AND is_read=0 AND is_del=0`
_Message_ReadMessage = `UPDATE @message SET is_read=1, modified_on=? WHERE id=?`
_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`
_SimpleIndexA_UserInfo = `SELECT * FROM @user WHERE username=?`
_SimpleIndex_UserInfo = `SELECT * FROM @user WHERE username=?`
_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_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.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.id DESC LIMIT ? OFFSET ?`
_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 (?)`
_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`
_Tweet_GetPostById = `SELECT * FROM @post WHERE id=? AND is_del=0`
_Tweet_GetPostContentById = `SELECT * FROM @post_content WHERE id=? AND is_del=0`
_Tweet_GetPostContentsByIds = `SELECT * FROM @post_content WHERE post_id IN (?) AND is_del=0`
_Tweet_GetUserPostCollection = `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_collection s JOIN @post P ON s.post_id = P.ID WHERE s.post_id = ? AND s.user_id = ? AND s.is_del = 0 AND ( visibility <> 1 OR ( visibility = 1 AND P.user_id = ? ) ) ORDER BY P.ID DESC`
_Tweet_GetUserPostCollectionCount = `SELECT count(*) FROM @post_collection 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_GetUserPostCollections = `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_collection 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_GetUserPostCount = `SELECT count(*) FROM @post WHERE user_id=? AND visibility IN (?)`
_Tweet_GetUserPostStar = `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.post_id = ? AND s.user_id = ? AND s.is_del = 0 AND ( visibility <> 1 OR ( visibility = 1 AND P.user_id = ? ) ) ORDER BY P.ID DESC`
_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 (?, ?, ?)`
_TweetManage_AddPostContent = `INSERT INTO @post_content (post_id, user_id, content, type, sort, created_on) VALUES (:post_id, :user_id, :content, :type, :sort, :created_on)`
_TweetManage_AddPostStar = `INSERT INTO @post_star (post_id, user_id, created_on) VALUES (?, ?, ?)`
_TweetManage_CommentIdsByPostId = `SELECT id FROM @comment WHERE post_id=? AND is_del=0`
_TweetManage_CommentMediaFromCommentIds = `SELECT content FROM @comment_content WHERE comment_id IN (?) AND type=3 AND is_del=0`
_TweetManage_DelCommentByPostId = `UPDATE @comment SET deleted_on=?, is_del=1 WHERE post_id=? AND is_del=0`
_TweetManage_DelCommentContentByCommentIds = `UPDATE @comment_content SET deleted_on=?, is_del=1 WHERE comment_id IN (?) AND is_del=0`
_TweetManage_DelPostById = `UPDATE @post SET is_del=1, deleted_on=? WHERE id=? AND is_del=0`
_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_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_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`
_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`
_UserManage_GetUserByPhone = `SELECT * FROM @user WHERE phone=? AND is_del=0`
_UserManage_GetUserByUsername = `SELECT * FROM @user WHERE username=? AND is_del=0`
_UserManage_GetUsersByIds = `SELECT * FROM @user WHERE id IN (?) AND is_del=0`
_UserManage_GetUsersByKeyword = `SELECT * FROM @user WHERE username LIKE ? AND is_del=0 limit 6`
_UserManage_UpdateUser = `UPDATE @user SET username=:username, nickname=:nickname, phone=:phone, password=:password, salt=:salt, status=:status, avatar=:avatar, balance=:balance, is_admin=:is_admin, modified_on=:modified_on WHERE id=? AND is_del=0`
_Wallet_AddUserBalance = `UPDATE @user SET balance=balance+?, modified_on=? WHERE id=? AND is_del=0`
_Wallet_CreateRecharge = `INSERT INTO @wallet_recharge (user_id, amount, created_on) VALUES (?, ?, ?)`
_Wallet_CreateWalletStatement = `INSERT INTO @wallet_statement (user_id, change_amount, balance_snapshot, reason, created_on) VALUES (?, ?, ?, ?, ?)`
_Wallet_GetRechargeById = `SELECT * FROM @wallet_recharge WHERE id=? AND is_del=?`
_Wallet_GetUserBalance = `SELECT balance FROM @user WHERE id=? AND is_del=0`
_Wallet_GetUserByUid = `SELECT * FROM @user WHERE id=? AND is_del=0`
_Wallet_GetUserWalletBillCount = `SELECT count(*) FROM @wallet_statement WHERE user_id=? AND is_del=0`
_Wallet_GetUserWalletBills = `SELECT * FROM @wallet_statement WHERE user_id=? AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Wallet_MarkSuccessRecharge = `UPDATE @wallet_recharge SET trade_no=?, trade_status='TRADE_SUCCESS', modified_on=? WHERE id=? AND is_del=0`
_Wallet_MinusUserBalance = `UPDATE @user SET balance=balance-?, modified_on=? WHERE id=? AND is_del=0`
_Wallet_NewPostAttachmentBill = `INSERT INTO @post_attachment_bill (post_id, user_id, paid_amount, created_on) VALUES (?, ?, ?, ?)`
_Wallet_NewPostBill = `INSERT INTO @wallet_statement (post_id, user_id, change_amount, balance_snapshot, reason, created_on) VALUES (?, ?, ?, ?, ?, ?)`
)
type Yesql struct {
@ -316,20 +321,25 @@ type TweetHelpA struct {
}
type TweetManage struct {
yesql.Namespace `yesql:"tweet_manage"`
AddAttachment *sqlx.Stmt `yesql:"add_attachment"`
AddPostCollection *sqlx.Stmt `yesql:"add_post_collection"`
AddPostStar *sqlx.Stmt `yesql:"add_post_star"`
DelPostById *sqlx.Stmt `yesql:"del_post_by_id"`
DelPostCollection *sqlx.Stmt `yesql:"del_post_collection"`
DelPostStar *sqlx.Stmt `yesql:"del_post_star"`
LockPost *sqlx.Stmt `yesql:"lock_post"`
MediaContentByPostId *sqlx.Stmt `yesql:"media_content_by_post_id"`
StickPost *sqlx.Stmt `yesql:"stick_post"`
VisiblePost *sqlx.Stmt `yesql:"visible_post"`
AddPost *sqlx.NamedStmt `yesql:"add_post"`
AddPostContent *sqlx.NamedStmt `yesql:"add_post_content"`
UpdatePost *sqlx.NamedStmt `yesql:"update_post"`
yesql.Namespace `yesql:"tweet_manage"`
CommentMediaFromCommentIds string `yesql:"comment_media_from_comment_ids"`
DelCommentContentByCommentIds string `yesql:"del_comment_content_by_comment_ids"`
DelReplyByCommentIds string `yesql:"del_reply_by_comment_ids"`
AddAttachment *sqlx.Stmt `yesql:"add_attachment"`
AddPostCollection *sqlx.Stmt `yesql:"add_post_collection"`
AddPostStar *sqlx.Stmt `yesql:"add_post_star"`
CommentIdsByPostId *sqlx.Stmt `yesql:"comment_ids_by_post_id"`
DelCommentByPostId *sqlx.Stmt `yesql:"del_comment_by_post_id"`
DelPostById *sqlx.Stmt `yesql:"del_post_by_id"`
DelPostCollection *sqlx.Stmt `yesql:"del_post_collection"`
DelPostStar *sqlx.Stmt `yesql:"del_post_star"`
LockPost *sqlx.Stmt `yesql:"lock_post"`
MediaContentByPostId *sqlx.Stmt `yesql:"media_content_by_post_id"`
StickPost *sqlx.Stmt `yesql:"stick_post"`
VisiblePost *sqlx.Stmt `yesql:"visible_post"`
AddPost *sqlx.NamedStmt `yesql:"add_post"`
AddPostContent *sqlx.NamedStmt `yesql:"add_post_content"`
UpdatePost *sqlx.NamedStmt `yesql:"update_post"`
}
type TweetManageA struct {
@ -839,7 +849,11 @@ func BuildTweetManage(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Twe
} else {
c = context.Background()
}
obj = &TweetManage{}
obj = &TweetManage{
CommentMediaFromCommentIds: p.QueryHook(_TweetManage_CommentMediaFromCommentIds),
DelCommentContentByCommentIds: p.QueryHook(_TweetManage_DelCommentContentByCommentIds),
DelReplyByCommentIds: p.QueryHook(_TweetManage_DelReplyByCommentIds),
}
if obj.AddAttachment, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_AddAttachment))); err != nil {
return
}
@ -849,6 +863,12 @@ func BuildTweetManage(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Twe
if obj.AddPostStar, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_AddPostStar))); err != nil {
return
}
if obj.CommentIdsByPostId, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_CommentIdsByPostId))); err != nil {
return
}
if obj.DelCommentByPostId, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_DelCommentByPostId))); err != nil {
return
}
if obj.DelPostById, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TweetManage_DelPostById))); err != nil {
return
}

@ -358,41 +358,180 @@ SELECT count(*) FROM @post WHERE visibility IN (?);
-- name: get_user_post_star@tweet
-- prepare: stmt
SELECT * FROM @user WHERE username=?
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.post_id = ?
AND s.user_id = ?
AND s.is_del = 0
AND ( visibility <> 1 OR ( visibility = 1 AND P.user_id = ? ) )
ORDER BY
P.ID DESC;
-- name: get_user_post_stars@tweet
-- prepare: stmt
SELECT * FROM @user WHERE username=?
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 ?;
-- name: get_user_post_star_count@tweet
-- prepare: stmt
SELECT * FROM @user WHERE username=?
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 = ? ) );
-- name: get_user_post_collection@tweet
-- prepare: stmt
SELECT * FROM @user WHERE username=?
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_collection s
JOIN @post P ON s.post_id = P.ID
WHERE
s.post_id = ?
AND s.user_id = ?
AND s.is_del = 0
AND ( visibility <> 1 OR ( visibility = 1 AND P.user_id = ? ) )
ORDER BY
P.ID DESC;
-- name: get_user_post_collections@tweet
-- prepare: stmt
SELECT * FROM @user WHERE username=?
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_collection 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 ?;
-- name: get_user_post_collection_count@tweet
-- prepare: stmt
SELECT * FROM @user WHERE username=?
SELECT
count(*)
FROM
@post_collection 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 = ? ) );
-- name: get_post_attachment_bill@tweet
-- prepare: stmt
SELECT * FROM @user WHERE username=?
SELECT * FROM @post_attachment_bill WHERE post_id=? AND user_id=? AND is_del=0;
-- name: get_post_contents_by_ids@tweet
-- prepare: raw
-- clause: in
SELECT * FROM @post_content
SELECT *
FROM @post_content
WHERE post_id IN (?) AND is_del=0;
-- name: get_post_content_by_id@tweet
-- prepare: stmt
SELECT * FROM @user WHERE username=?
SELECT * FROM @post_content WHERE id=? AND is_del=0;
--------------------------------------------------------------------------------
-- tweet_manage sql dml
@ -460,6 +599,29 @@ VALUES (:post_id, :user_id, :content, :type, :sort, :created_on);
INSERT INTO @attachment (user_id, file_size, img_width, img_height, type, content, created_on)
VALUES (?, ?, ?, ?, ?, ?, ?);
-- name: comment_ids_by_post_id@tweet_manage
-- prepare: stmt
SELECT id FROM @comment WHERE post_id=? AND is_del=0;
-- name: comment_media_from_comment_ids@tweet_manage
-- prepare: raw
-- clause: in
SELECT content FROM @comment_content WHERE comment_id IN (?) AND type=3 AND is_del=0;
-- name: del_comment_by_post_id@tweet_manage
-- prepare: stmt
UPDATE @comment SET deleted_on=?, is_del=1 WHERE post_id=? AND is_del=0;
-- name: del_comment_content_by_comment_ids@tweet_manage
-- prepare: raw
-- clause: in
UPDATE @comment_content SET deleted_on=?, is_del=1 WHERE comment_id IN (?) AND is_del=0;
-- name: del_reply_by_comment_ids@tweet_manage
-- prepare: raw
-- clause: in
UPDATE @comment_reply SET deleted_on=?, is_del=1 WHERE comment_id IN (?) AND is_del=0;
--------------------------------------------------------------------------------
-- tweet_help sql dml
--------------------------------------------------------------------------------

Loading…
Cancel
Save