_Comment_GetCommentReplyById=`SELECT * FROM @comment_reply WHERE id=? AND is_del=0`
_Comment_GetCommentThumbs=`SELECT user_id, tweet_id, comment_id, reply_id, comment_type, is_thumbs_up, is_thumbs_down FROM @tweet_comment_thumbs WHERE user_id=? AND tweet_id=?`
_Comment_GetCommmentRepliesByIds=`SELECT * FROM @comment_reply WHERE comment_id IN (?) ORDER BY id ASC`
_Comment_GetDefaultComments=`SELECT * FROM @comment WHERE post_id=? AND is_del=0 ORDER BY id ASC LIMIT ? OFFSET ?`
_Comment_GetHotsComments=`SELECT * FROM @comment WHERE post_id=? AND is_del=0 ORDER BY thumbs_up_count DESC, id DESC LIMIT ? OFFSET ?`
_Comment_GetNewestComments=`SELECT * FROM @comment WHERE post_id=? AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Comment_GetDefaultComments=`SELECT * FROM @comment WHERE post_id=? AND is_del=0 ORDER BY is_essence DESC, id ASC LIMIT ? OFFSET ?`
_Comment_GetHotsComments=`SELECT c.* FROM @comment c LEFT JOIN @comment_metric m ON c.id=m.comment_id WHERE c.post_id=? AND c.is_del=0 AND m.is_del=0 ORDER BY is_essence DESC, m.rank_score DESC, id DESC LIMIT ? OFFSET ?`
_Comment_GetNewestComments=`SELECT * FROM @comment WHERE post_id=? AND is_del=0 ORDER BY is_essence DESC, id DESC LIMIT ? OFFSET ?`
_Comment_GetUsersByIds=`SELECT id, nickname, username, status, avatar, is_admin FROM @user WHERE id IN (?)`
_CommentManage_DecrCommentReplyCount=`UPDATE @comment SET reply_count=reply_count-1, modified_on=? WHERE id=? AND is_del=0`
_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_IncrCommentReplyCount=`UPDATE @comment SET reply_count=reply_count+1, modified_on=? WHERE id=? 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`
_CommentMetrics_AddCommentMetric=`INSERT INTO @comment_metric (comment_id, created_on) VALUES (?, ?)`
_CommentMetrics_DeleteCommentMetric=`UPDATE @comment_metric SET is_del=1, deleted_on=? WHERE comment_id=? AND is_del=0`
_CommentMetrics_GetMotivationFactor=`SELECT motivation_factor FROM @comment_metric WHERE comment_id=? AND is_del=0`
_CommentMetrics_UpdateRankScore=`UPDATE @comment_metric SET rank_score=?, modified_on=? WHERE comment_id=? AND is_del=0`
_CommentMetrics_UpsertCommentMetric=`INSERT INTO @comment_metric (comment_id, rank_score, created_on) VALUES (?, ?, ?)`
_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 = ?`
_FollowingManager_ExistFollowing=`SELECT 1 FROM @following WHERE user_id=? AND follow_id=? AND is_del=0`
_FollowingManager_ListFollowings=`SELECT u.id user_id, u.username username, u.nickname nickname, u.avatar avatar, u.created_on created_on FROM @following f JOIN @user u ON f.user_id=u.id WHERE f.follow_id=? AND f.is_del=0 ORDER BY u.nickname ASC LIMIT ? OFFSET ?`
_FollowingManager_ListFollows=`SELECT u.id user_id, u.username username, u.nickname nickname, u.avatar avatar, u.created_on created_on FROM @following f JOIN @user u ON f.follow_id=u.id WHERE f.user_id=? AND f.is_del=0 ORDER BY u.nickname ASC LIMIT ? OFFSET ?`
_Message_CountAllMessages=`SELECT count(*) FROM @message WHERE (receiver_user_id=? OR (sender_user_id=? AND type=4)) AND is_del=0`
_Message_CountRequestingMessages=`SELECT count(*) FROM @message WHERE receiver_user_id=? AND type=5 AND is_del=0`
_Message_CountSystemMessages=`SELECT count(*) FROM @message WHERE receiver_user_id=? AND type IN (1, 2, 3, 99) AND is_del=0`
_Message_CountUnreadMessages=`SELECT count(*) FROM @message WHERE receiver_user_id=? AND is_read=0 AND is_del=0`
_Message_CountWhisperMessages=`SELECT count(*) FROM @message WHERE ((receiver_user_id=? OR sender_user_id=?) AND type=4) AND is_del=0`
_Message_GetAllMessages=`SELECT * FROM @message WHERE (receiver_user_id=? OR (sender_user_id=? AND type=4)) AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Message_GetMessageById=`SELECT * FROM @message WHERE id=? AND is_del=0`
_Message_GetMessageCount=`SELECT count(*) FROM @message WHERE (receiver_user_id=? OR (sender_user_id=? AND type=4)) AND is_del=0`
_Message_GetMessages=`SELECT * FROM @message WHERE (receiver_user_id=? OR (sender_user_id=? AND type=4)) AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Message_GetRequestingMessages =`SELECT * FROM @message WHERE receiver_user_id=? AND type=5 AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Message_GetSystemMessages =`SELECT * FROM @message WHERE receiver_user_id=? AND type IN (1, 2, 3, 99) AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Message_GetUnreadCount=`SELECT count(*) FROM @message WHERE receiver_user_id=? AND is_read=0 AND is_del=0`
_Message_GetUnreadMessages=`SELECT * FROM @message WHERE receiver_user_id=? AND is_read=0 AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Message_GetWhisperMessages=`SELECT * FROM @message WHERE ((receiver_user_id=? OR sender_user_id=?) AND type=4) AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?`
_Message_ReadMessage=`UPDATE @message SET is_read=1, modified_on=? WHERE id=?`
_Security_GetLatestPhoneCaptcha=`SELECT * FROM @captcha WHERE phone=? AND is_del=0`
@ -79,6 +94,8 @@ const (
_ShipIndex_IndexCountBySelf=`SELECT count(*) FROM @post WHERE is_del=0 AND (visibility=90 OR (visibility=0 AND user_id=?) OR (visibility=50 AND user_id IN (?)))`
_SimpleIndex_Index=`SELECT * FROM @post WHERE visibility=90 ORDER BY is_top DESC, latest_replied_on DESC LIMIT ? OFFSET ?`
_SimpleIndex_IndexCount=`SELECT count(*) FROM @post WHERE visibility=90`
_TrendsManager_CountIndexTrends=`SELECT count(*) FROM @contact c JOIN @user u ON c.friend_id=u.id JOIN @user_metric m ON c.friend_id=m.user_id WHERE c.user_id=? AND c.is_del=0 AND u.is_del=0 AND m.is_del=0 AND m.tweets_count>0`
_TrendsManager_GetIndexTrends=`SELECT u.username username, u.nickname nickname, u.avatar avatar FROM @contact c JOIN @user u ON c.friend_id=u.id JOIN @user_metric m ON c.friend_id=m.user_id WHERE c.user_id=? AND c.is_del=0 AND u.is_del=0 AND m.is_del=0 AND m.tweets_count>0 LIMIT ? OFFSET ?`
_Tweet_CountFollowingTweets=`SELECT count(*) FROM @post WHERE user_id=? AND is_del=0`
_Tweet_CountFollowingTweetsFollow=`SELECT count(*) FROM @post WHERE (user_id=? OR (visibility>=60 AND user_id IN(?))) AND is_del=0`
_Tweet_CountFollowingTweetsFriend=`SELECT count(*) FROM @post WHERE (user_id=? OR (visibility>=50 AND user_id IN(?))) AND is_del=0`
@ -137,6 +154,7 @@ const (
_TweetMetrics_DeleteTweetMetric=`UPDATE @post_metric SET is_del=1, deleted_on=? WHERE post_id=? AND is_del=0`
_TweetMetrics_GetMotivationFactor=`SELECT motivation_factor FROM @post_metric WHERE post_id=? AND is_del=0`
_TweetMetrics_UpdateRankScore=`UPDATE @post_metric SET rank_score=?, modified_on=? WHERE post_id=? AND is_del=0`
_TweetMetrics_UpsertTweetMetric=`INSERT INTO @post_metric (post_id, rank_score, created_on) VALUES (?, ?, ?)`
_Tweet_UserCommentTweetsByFriend=`SELECT id, user_id, comment_count, collection_count, upvote_count, share_count, visibility, is_top, is_essence, is_lock, latest_replied_on, tags, attachment_price, ip, ip_loc, created_on, modified_on, deleted_on, is_del FROM @post_by_comment WHERE is_del=0 AND comment_user_id=? AND visibility>=50 ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserCommentTweetsByGuest=`SELECT id, user_id, comment_count, collection_count, upvote_count, share_count, visibility, is_top, is_essence, is_lock, latest_replied_on, tags, attachment_price, ip, ip_loc, created_on, modified_on, deleted_on, is_del FROM @post_by_comment WHERE is_del=0 AND comment_user_id=? AND visibility>=90 ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
_Tweet_UserCommentTweetsBySelf=`SELECT id, user_id, comment_count, collection_count, upvote_count, share_count, visibility, is_top, is_essence, is_lock, latest_replied_on, tags, attachment_price, ip, ip_loc, created_on, modified_on, deleted_on, is_del FROM @post_by_comment WHERE is_del=0 AND comment_user_id=? ORDER BY latest_replied_on DESC LIMIT ? OFFSET ?`
@ -166,6 +184,12 @@ const (
_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`
_UserMetrics_AddUserMetric=`INSERT INTO @user_metric (user_id, created_on) VALUES (?, ?)`
_UserMetrics_DeleteUserMetric=`UPDATE @user_metric SET is_del=1, deleted_on=? WHERE user_id=? AND is_del=0`
_UserMetrics_GetTweetsCount=`SELECT tweets_count FROM @user_metric WHERE user_id=? AND is_del=0`
_UserMetrics_UpdateUserMetric=`UPDATE @user_metric SET tweets_count=?, modified_on=? WHERE user_id=? AND is_del=0`
_UserRelation_MyFollowIds=`SELECT follow_id FROM @following WHERE user_id=? AND is_del=0`
_UserRelation_MyFriendIds=`SELECT friend_id FROM @contact WHERE user_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 (?, ?, ?)`
_Comment_GetHotsComments=`SELECT c.* FROM @comment c LEFT JOIN @comment_metric m ON c.id=m.comment_id WHERE c.post_id=? AND c.is_del=0 AND m.is_del=0 ORDER BY is_essence DESC, m.rank_score DESC NULLS LAST, id DESC LIMIT ? OFFSET ?`