user_follow.go 1.2 KB
package domain

import (
	"context"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)

type UserFollow struct {
	Id         int64 `json:"id,omitempty"`         // 唯一标识
	FromUserId int64 `json:"fromUserId,omitempty"` /// 发起关注的人
	ToUserId   int64 `json:"toUserId,omitempty"`   /// 被关注的人
	CreatedAt  int64 `json:"createdAt,omitempty"`
	UpdatedAt  int64 `json:"updatedAt,omitempty"`
	DeletedAt  int64 `json:"deletedAt,omitempty"`
	Version    int   `json:"version,omitempty"`
}

type UserFollowRepository interface {
	Insert(ctx context.Context, conn transaction.Conn, dm *UserFollow) (*UserFollow, error)
	Update(ctx context.Context, conn transaction.Conn, dm *UserFollow) (*UserFollow, error)
	UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *UserFollow) (*UserFollow, error)
	Delete(ctx context.Context, conn transaction.Conn, dm *UserFollow) (*UserFollow, error)
	FindOne(ctx context.Context, conn transaction.Conn, id int64) (*UserFollow, error)
	Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*UserFollow, error)
}

func (m *UserFollow) Identify() interface{} {
	if m.Id == 0 {
		return nil
	}
	return m.Id
}