diff --git a/message/infrastructure/message.go b/message/infrastructure/message.go index ee3c168..33dfa9a 100644 --- a/message/infrastructure/message.go +++ b/message/infrastructure/message.go @@ -387,7 +387,7 @@ func (s *messageAdapter) GetInnerMessageQuick(cmd CmdToGetInnerMessageQuick, query.Count(&Count) var response []MessageListDAO - if result := query.Debug().Limit(cmd.CountPerPage).Offset(offsetNum). + if result := query.Limit(cmd.CountPerPage).Offset(offsetNum). Order("cloud_event_message.time DESC"). Scan(&response); result.Error != nil { return []MessageListDAO{}, 0, xerrors.Errorf("get inner message failed, err:%v", diff --git a/message/infrastructure/subscribe.go b/message/infrastructure/subscribe.go index 7c5c91c..82ce3de 100644 --- a/message/infrastructure/subscribe.go +++ b/message/infrastructure/subscribe.go @@ -42,14 +42,14 @@ func (ctl *messageSubscribeAdapter) GetSubsConfig(userName string) ([]MessageSub var response []MessageSubscribeDAOWithPushConfig query := postgresql.DB().Table("message_center.subscribe_config"). - Select("subscribe_config.*, push_config.need_mail"). - Joins("JOIN message_center.push_config ON subscribe_config.id = push_config.subscribe_id"). - Where(gorm.Expr("subscribe_config.is_deleted = ?", false)). - Where("subscribe_config.user_name = ?", userName) + Select("subscribe_config.*, (SELECT push_config.need_mail FROM message_center."+ + "push_config WHERE push_config.subscribe_id = subscribe_config.id LIMIT 1) AS need_mail"). + Where("subscribe_config.is_deleted = ? AND subscribe_config.user_name = ?", + false, userName) var Count int64 query.Count(&Count) - if result := query.Order("subscribe_config.id").Find(&response); result.Error != nil { + if result := query.Debug().Order("subscribe_config.id").Find(&response); result.Error != nil { return []MessageSubscribeDAOWithPushConfig{}, 0, xerrors.Errorf("查询失败") }