From 1a3edd3f8f3a30fb0f53081b85bb9643d02fd466 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Sat, 5 Aug 2023 15:37:04 +0800 Subject: [PATCH] sqlx: just format yesql.sql --- internal/dao/sakila/yesql/cc/yesql.go | 2 +- internal/dao/sakila/yesql/yesql.sql | 134 +++++++++++++++++++------- 2 files changed, 102 insertions(+), 34 deletions(-) diff --git a/internal/dao/sakila/yesql/cc/yesql.go b/internal/dao/sakila/yesql/cc/yesql.go index fae1338f..b1da4914 100644 --- a/internal/dao/sakila/yesql/cc/yesql.go +++ b/internal/dao/sakila/yesql/cc/yesql.go @@ -48,7 +48,7 @@ const ( _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 LIMIT ? OFFSET ?` + _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=?` diff --git a/internal/dao/sakila/yesql/yesql.sql b/internal/dao/sakila/yesql/yesql.sql index 5944830c..6c6c941f 100644 --- a/internal/dao/sakila/yesql/yesql.sql +++ b/internal/dao/sakila/yesql/yesql.sql @@ -63,15 +63,19 @@ UPDATE @comment SET deleted_on=?, is_del=1 WHERE id=? AND is_del=0; -- name: delete_comment_thumbs@comment_manage -- prepare: stmt -UPDATE @tweet_comment_thumbs SET deleted_on=?, is_del=1 WHERE user_id=? AND tweet_id=? AND comment_id=? AND is_del=0; +UPDATE @tweet_comment_thumbs +SET deleted_on=?, is_del=1 +WHERE user_id=? AND tweet_id=? AND comment_id=? AND is_del=0; -- name: create_comment@comment_manage -- prepare: stmt -INSERT INTO @comment (post_id, user_id, ip, ip_loc, created_on) VALUES (?, ?, ?, ?, ?); +INSERT INTO @comment (post_id, user_id, ip, ip_loc, created_on) +VALUES (?, ?, ?, ?, ?); -- name: create_comment_reply@comment_manage -- prepare: stmt -INSERT INTO @comment_reply (comment_id, user_id, content, at_user_id, ip, ip_loc, created_on) VALUES (?, ?, ?, ?, ?, ?, ?); +INSERT INTO @comment_reply (comment_id, user_id, content, at_user_id, ip, ip_loc, created_on) +VALUES (?, ?, ?, ?, ?, ?, ?); -- name: delete_comment_reply@comment_manage -- prepare: stmt @@ -79,35 +83,49 @@ UPDATE @comment_reply SET deleted_on=?, is_del=1 WHERE id=? AND is_del=0; -- name: delete_reply_thumbs@comment_manage -- prepare: stmt -UPDATE @tweet_comment_thumbs SET deleted_on=?, is_del=1 WHERE user_id=? AND comment_id=? AND reply_id=? AND is_del=0; +UPDATE @tweet_comment_thumbs +SET deleted_on=?, is_del=1 +WHERE user_id=? AND comment_id=? AND reply_id=? AND is_del=0; -- name: create_comment_content@comment_manage -- prepare: stmt -INSERT INTO @comment_content (comment_id, user_id, content, type, sort, created_on) VALUES (?, ?, ?, ?, ?, ?); +INSERT INTO @comment_content (comment_id, user_id, content, type, sort, created_on) +VALUES (?, ?, ?, ?, ?, ?); -- name: update_thumbs_updown_comment@comment_manage -- prepare: named_stmt -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; +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; -- name: create_thumbs_updown_comment@comment_manage -- prepare: named_stmt -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); +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); -- name: update_comment_thumbs_count@comment_manage -- prepare: stmt -UPDATE @comment SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? WHERE id=? AND is_del=0; +UPDATE @comment +SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? +WHERE id=? AND is_del=0; -- name: get_tweet_comment_thumb@comment_manage -- prepare: stmt -SELECT * FROM @tweet_comment_thumbs WHERE user_id=? AND tweet_id=? AND comment_id=? AND comment_type=0 AND is_del=0; +SELECT * +FROM @tweet_comment_thumbs +WHERE user_id=? AND tweet_id=? AND comment_id=? AND comment_type=0 AND is_del=0; -- name: get_comment_reply_thumb@comment_manage -- prepare: stmt -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; +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; -- name: update_reply_thumbs_count@comment_manage -- prepare: stmt -UPDATE @comment_reply SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? WHERE id=? AND is_del=0; +UPDATE @comment_reply +SET thumbs_up_count=?, thumbs_down_count=?, modified_on=? +WHERE id=? AND is_del=0; -------------------------------------------------------------------------------- -- contact_manager sql dml @@ -123,15 +141,20 @@ UPDATE @contact SET status=?, modified_on=?, is_del=0 WHERE id=?; -- name: create_message@contact_manager -- prepare: named_stmt -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); +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); -- name: add_friend_msgs_update@contact_manager -- prepare: stmt -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 = ?; +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 = ?; -- name: reject_friend_msgs_update@contact_manager -- prepare: stmt -UPDATE @message SET reply_id=?, modified_on=? WHERE sender_user_id = ? AND receiver_user_id = ? AND type = ? AND reply_id = ?; +UPDATE @message +SET reply_id=?, modified_on=? +WHERE sender_user_id = ? AND receiver_user_id = ? AND type = ? AND reply_id = ?; -- name: del_friend@contact_manager -- prepare: stmt @@ -139,23 +162,36 @@ UPDATE @contact SET status=4, is_del=1, deleted_on=? WHERE id=?; -- name: list_friend@contact_manager -- prepare: stmt -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 ?; +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 ?; -- name: total_friends_by_id@contact_manager -- prepare: stmt -SELECT count(*) FROM @contact WHERE user_id=? AND status=2 AND is_del=0 LIMIT ? OFFSET ?; +SELECT count(*) +FROM @contact +WHERE user_id=? AND status=2 AND is_del=0; -- name: get_contacts@contact_manager -- prepare: stmt -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=?); +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=?); -- name: get_user_friend@contact_manager -- prepare: stmt -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; +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; -- name: get_contact@contact_manager -- prepare: stmt -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=?; +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=?; -- name: is_friend@contact_manager -- prepare: stmt @@ -167,7 +203,8 @@ SELECT true FROM @contact WHERE user_id=? AND friend_id=? AND is_del=0 AND statu -- name: create_message@message -- prepare: named_stmt -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); +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); -- name: get_unread_count@message -- prepare: stmt @@ -183,7 +220,11 @@ UPDATE @message SET is_read=1, modified_on=? WHERE id=?; -- name: get_messages@message -- prepare: named_stmt -SELECT * FROM @message WHERE receiver_user_id=:recerver_user_id AND is_del=0 ORDER BY id DESC LIMIT :limit OFFSET :offset +SELECT * +FROM @message +WHERE receiver_user_id=:recerver_user_id AND is_del=0 +ORDER BY id DESC +LIMIT :limit OFFSET :offset -- name: get_message_count@message -- prepare: named_stmt @@ -203,7 +244,8 @@ UPDATE @captcha SET use_times=use_times+1, modified_on=? WHERE id=? AND is_del=0 -- name: create_phone_captcha@security -- prepare: named_stmt -INSERT INTO @captcha (phone, captcha, expired_on, created_on) VALUES (:phone, :captcha, :expired_on, :created_on); +INSERT INTO @captcha (phone, captcha, expired_on, created_on) +VALUES (:phone, :captcha, :expired_on, :created_on); -------------------------------------------------------------------------------- -- friend_index sql dml @@ -482,13 +524,21 @@ LIMIT ? OFFSET ?; -- 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; +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; +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); +INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) +VALUES (?, ?, ?, ?, 1); -- name: tags_by_id_a@topic_a -- prepare: raw @@ -546,13 +596,23 @@ SELECT * FROM @user WHERE is_del=0 ORDER BY id ASC limit 6; -- name: create_user@user_manage -- prepare: named_stmt -INSERT INTO @user (username, nickname, password, salt, avatar, status, created_on) VALUES (:username, :nickname, :password, :salt, :avatar, :status, :created_on); +INSERT INTO @user (username, nickname, password, salt, avatar, status, created_on) +VALUES (:username, :nickname, :password, :salt, :avatar, :status, :created_on); -- name: update_user@user_manage -- prepare: named_stmt -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; +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 sql dml @@ -560,7 +620,11 @@ UPDATE @user SET username=:username, nickname=:nickname, phone=:phone, -- name: get_user_wallet_bills@wallet -- prepare: stmt -SELECT * FROM @wallet_statement WHERE user_id=? AND is_del=0 ORDER BY id DESC LIMIT ? OFFSET ?; +SELECT * +FROM @wallet_statement +WHERE user_id=? AND is_del=0 +ORDER BY id DESC +LIMIT ? OFFSET ?; -- name: get_user_wallet_bill_count@wallet -- prepare: stmt @@ -588,7 +652,8 @@ UPDATE @user SET balance=balance-?, modified_on=? WHERE id=? AND is_del=0; -- name: create_wallet_statement@wallet -- prepare: stmt -INSERT INTO @wallet_statement (user_id, change_amount, balance_snapshot, reason, created_on) VALUES (?, ?, ?, ?, ?); +INSERT INTO @wallet_statement (user_id, change_amount, balance_snapshot, reason, created_on) +VALUES (?, ?, ?, ?, ?); -- name: get_user_balance@wallet -- prepare: stmt @@ -596,7 +661,9 @@ SELECT balance FROM @user WHERE id=? AND is_del=0; -- name: mark_success_recharge@wallet -- prepare: stmt -UPDATE @wallet_recharge SET trade_no=?, trade_status='TRADE_SUCCESS', modified_on=? WHERE id=? AND is_del=0; +UPDATE @wallet_recharge +SET trade_no=?, trade_status='TRADE_SUCCESS', modified_on=? +WHERE id=? AND is_del=0; -- name: new_post_attachment_bill -- prepare: stmt @@ -604,4 +671,5 @@ INSERT INTO @post_attachment_bill (post_id, user_id, paid_amount) VALUES (?, ?, -- name: new_post_bill@wallet -- prepare: stmt -INSERT INTO @wallet_statement (post_id, user_id, change_amount, balance_snapshot, reason, created_on) VALUES (?, ?, ?, ?, ?, ?); +INSERT INTO @wallet_statement (post_id, user_id, change_amount, balance_snapshot, reason, created_on) +VALUES (?, ?, ?, ?, ?, ?);