fix: query im kafka tables with gf raw helpers
This commit is contained in:
@@ -16,11 +16,6 @@ import (
|
||||
"github.com/gogf/gf/v2/util/guid"
|
||||
)
|
||||
|
||||
const (
|
||||
adminCommandTable = "im_admin_commands"
|
||||
adminOutboxTable = "im_admin_outbox"
|
||||
)
|
||||
|
||||
func PublishAdminCommand(ctx context.Context, in AdminCommandInput) (res *AdminCommandModel, err error) {
|
||||
if in.TenantID <= 0 || in.TenantCode == "" {
|
||||
return nil, gerror.New("IM租户信息不完整")
|
||||
@@ -106,9 +101,9 @@ func PublishAdminCommand(ctx context.Context, in AdminCommandInput) (res *AdminC
|
||||
}
|
||||
|
||||
func DispatchOutboxByEvent(ctx context.Context, eventID string) error {
|
||||
var row gdb.Record
|
||||
if err := g.DB().Raw(`SELECT * FROM im_admin_outbox WHERE event_id=? AND status=? LIMIT 1`,
|
||||
eventID, consts.ImAdminOutboxStatusPending).Scan(&row); err != nil {
|
||||
row, err := g.DB().GetOne(ctx, `SELECT * FROM im_admin_outbox WHERE event_id=? AND status=? LIMIT 1`,
|
||||
eventID, consts.ImAdminOutboxStatusPending)
|
||||
if err != nil {
|
||||
return gerror.Wrap(err, "读取IM命令Outbox失败")
|
||||
}
|
||||
if row.IsEmpty() {
|
||||
@@ -221,10 +216,9 @@ func DispatchPendingOutbox(ctx context.Context, limit int) (sent int, err error)
|
||||
if limit <= 0 {
|
||||
limit = 100
|
||||
}
|
||||
var rows []gdb.Record
|
||||
err = g.DB().Raw(`SELECT * FROM im_admin_outbox
|
||||
rows, err := g.DB().GetAll(ctx, `SELECT * FROM im_admin_outbox
|
||||
WHERE status IN (?,?) AND (next_retry_at IS NULL OR next_retry_at <= NOW())
|
||||
ORDER BY id ASC LIMIT ?`, consts.ImAdminOutboxStatusPending, consts.ImAdminOutboxStatusFailed, limit).Scan(&rows)
|
||||
ORDER BY id ASC LIMIT ?`, consts.ImAdminOutboxStatusPending, consts.ImAdminOutboxStatusFailed, limit)
|
||||
if err != nil {
|
||||
return 0, gerror.Wrap(err, "读取待投递IM命令Outbox失败")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user