user_subscribe.go 2.0 KB
package domain

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

type UserSubscribe struct {
	Id        int64                 `json:"id"`                                       // 唯一标识
	Type      int                   `json:"type"`                                     // 分类(1评论回复 2获赞 3关注人更新)
	CompanyId int64                 `json:"companyId"`                                // 公司ID
	UserId    int64                 `json:"userId"`                                   // 用户ID
	Count     int                   `json:"count"`                                    // 订阅次数
	CreatedAt int64                 `json:",omitempty"`                               // 创建时间
	UpdatedAt int64                 `json:",omitempty"`                               // 更新时间
	DeletedAt int64                 `json:",omitempty"`                               // 删除时间
	Version   int                   `json:",omitempty"`                               // 版本
	IsDel     soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` // 删除标记
}

type UserSubscribeRepository interface {
	Insert(ctx context.Context, conn transaction.Conn, dm *UserSubscribe) (*UserSubscribe, error)
	Update(ctx context.Context, conn transaction.Conn, dm *UserSubscribe) (*UserSubscribe, error)
	UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *UserSubscribe) (*UserSubscribe, error)
	Delete(ctx context.Context, conn transaction.Conn, dm *UserSubscribe) (*UserSubscribe, error)
	FindOne(ctx context.Context, conn transaction.Conn, id int64) (*UserSubscribe, error)
	FindOneByType(ctx context.Context, conn transaction.Conn, companyId, userId int64, mType int) (*UserSubscribe, error)
	Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*UserSubscribe, error)
}

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