mirror of https://gitee.com/answerdev/answer.git
36 lines
923 B
Go
36 lines
923 B
Go
package activity
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/answerdev/answer/internal/base/data"
|
|
"github.com/answerdev/answer/internal/base/reason"
|
|
"github.com/answerdev/answer/internal/entity"
|
|
"github.com/answerdev/answer/internal/service/activity"
|
|
"github.com/segmentfault/pacman/errors"
|
|
)
|
|
|
|
// activityRepo activity repository
|
|
type activityRepo struct {
|
|
data *data.Data
|
|
}
|
|
|
|
// NewActivityRepo new repository
|
|
func NewActivityRepo(
|
|
data *data.Data,
|
|
) activity.ActivityRepo {
|
|
return &activityRepo{
|
|
data: data,
|
|
}
|
|
}
|
|
|
|
func (ar *activityRepo) GetObjectAllActivity(ctx context.Context, objectID string, showVote bool) (
|
|
activityList []*entity.Activity, err error) {
|
|
activityList = make([]*entity.Activity, 0)
|
|
err = ar.data.DB.Find(&activityList, &entity.Activity{OriginalObjectID: objectID})
|
|
if err != nil {
|
|
return nil, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
|
|
}
|
|
return activityList, nil
|
|
}
|