user_follow.go 1.4 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"`   // 被关注的人
	LastReadAt int64 `json:"lastReadAt,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)
	FindOneUserFollowing(ctx context.Context, conn transaction.Conn, userId int64, followingId 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
}