Skip to content

Commit

Permalink
feat: format messages_dao.go
Browse files Browse the repository at this point in the history
  • Loading branch information
teamgramio committed Mar 14, 2023
1 parent 0e468b8 commit 7253805
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 88 deletions.
46 changes: 0 additions & 46 deletions app/service/biz/message/internal/dal/dao/mysql_dao/messages_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,52 +909,6 @@ func (dao *MessagesDAO) SelectDialogMessageIdListWithCB(ctx context.Context, use
return
}

// SelectPeerMessageList
// select user_id, user_message_box_id, dialog_id1, dialog_id2, dialog_message_id, sender_user_id, peer_type, peer_id, random_id, message_filter_type, message_data, message, mentioned, media_unread, pinned, has_reaction, reaction, reaction_date, reaction_unread, date2 from messages where user_id != :user_id and dialog_message_id = :dialog_message_id and deleted = 0
// TODO(@benqi): sqlmap
func (dao *MessagesDAO) SelectPeerMessageList(ctx context.Context, user_id int64, dialog_message_id int64) (rList []dataobject.MessagesDO, err error) {
var (
query = "select user_id, user_message_box_id, dialog_id1, dialog_id2, dialog_message_id, sender_user_id, peer_type, peer_id, random_id, message_filter_type, message_data, message, mentioned, media_unread, pinned, has_reaction, reaction, reaction_date, reaction_unread, date2, ttl_period from " + dao.CalcTableName(user_id) + " where user_id != ? and dialog_message_id = ? and deleted = 0"
values []dataobject.MessagesDO
)
err = dao.db.QueryRowsPartial(ctx, &values, query, user_id, dialog_message_id)

if err != nil {
logx.WithContext(ctx).Errorf("queryx in SelectPeerMessageList(_), error: %v", err)
return
}

rList = values

return
}

// SelectPeerMessageListWithCB
// select user_id, user_message_box_id, dialog_id1, dialog_id2, dialog_message_id, sender_user_id, peer_type, peer_id, random_id, message_filter_type, message_data, message, mentioned, media_unread, pinned, has_reaction, reaction, reaction_date, reaction_unread, date2 from messages where user_id != :user_id and dialog_message_id = :dialog_message_id and deleted = 0
// TODO(@benqi): sqlmap
func (dao *MessagesDAO) SelectPeerMessageListWithCB(ctx context.Context, user_id int64, dialog_message_id int64, cb func(i int, v *dataobject.MessagesDO)) (rList []dataobject.MessagesDO, err error) {
var (
query = "select user_id, user_message_box_id, dialog_id1, dialog_id2, dialog_message_id, sender_user_id, peer_type, peer_id, random_id, message_filter_type, message_data, message, mentioned, media_unread, pinned, has_reaction, reaction, reaction_date, reaction_unread, date2, ttl_period from " + dao.CalcTableName(user_id) + " where user_id != ? and dialog_message_id = ? and deleted = 0"
values []dataobject.MessagesDO
)
err = dao.db.QueryRowsPartial(ctx, &values, query, user_id, dialog_message_id)

if err != nil {
logx.WithContext(ctx).Errorf("queryx in SelectPeerMessageList(_), error: %v", err)
return
}

rList = values

if cb != nil {
for i := 0; i < len(rList); i++ {
cb(i, &rList[i])
}
}

return
}

// UpdateMediaUnread
// update messages set media_unread = 0 where user_id = :user_id and user_message_box_id = :user_message_box_id
// TODO(@benqi): sqlmap
Expand Down
42 changes: 0 additions & 42 deletions app/service/biz/message/internal/dal/tables/messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,35 +188,6 @@
</sql>
</operation>

<!-- //
<operation name="SelectPeerDialogMessageIdList" result_set="list">
<params>
<param name="idList" type="[]int32" />
</params>
<sql>
<![CDATA[
SELECT
user_id, user_message_box_id, dialog_id1, dialog_id2, dialog_message_id, sender_user_id, peer_type, peer_id, random_id, message_filter_type, message_data, message, mentioned, media_unread, pinned, has_reaction, reaction, reaction_date, reaction_unread, date2
FROM
messages
WHERE
user_id <> :user_id AND dialog_message_id in (SELECT dialog_message_id FROM messages WHERE user_id = :user_id AND user_message_box_id in (:idList)) AND deleted = 0
]]>
</sql>
</operation>
<operation name="SelectDialogMessageListByMessageId" result_set="list">
<sql>
SELECT
user_id, user_message_box_id, dialog_id1, dialog_id2, dialog_message_id, sender_user_id, peer_type, peer_id, random_id, message_filter_type, message_data, message, mentioned, media_unread, pinned, has_reaction, reaction, reaction_date, reaction_unread, date2
FROM
messages
WHERE
dialog_message_id = (SELECT dialog_message_id FROM messages WHERE user_id = :user_id AND user_message_box_id = :user_message_box_id) AND deleted = 0
</sql>
</operation>
-->

<operation name="SelectDialogLastMessageId" result_set="single">
<sql>
SELECT
Expand Down Expand Up @@ -295,19 +266,6 @@
</sql>
</operation>

<operation name="SelectPeerMessageList" result_set="list">
<sql>
<![CDATA[
SELECT
user_id, user_message_box_id, dialog_id1, dialog_id2, dialog_message_id, sender_user_id, peer_type, peer_id, random_id, message_filter_type, message_data, message, mentioned, media_unread, pinned, has_reaction, reaction, reaction_date, reaction_unread, date2
FROM
messages
WHERE
user_id != :user_id AND dialog_message_id = :dialog_message_id AND deleted = 0
]]>
</sql>
</operation>

<operation name="UpdateMediaUnread">
<sql>
UPDATE
Expand Down

0 comments on commit 7253805

Please sign in to comment.