object_field.go 1.6 KB
package domain

import (
	"context"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/transaction"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway/bytelib"
	"gorm.io/plugin/soft_delete"
)

type ObjectField struct {
	Id        int64                 `json:"id"`                  // ID
	Name      string                `json:"name"`                //表名
	Fields    []*bytelib.Field      `json:"fields"`              //表字段
	Version   int                   `json:"version,omitempty"`   //版本
	IsDel     soft_delete.DeletedAt `json:"isDel"`               //删除标记
	CreatedAt int64                 `json:"createdAt,omitempty"` //创建时间
	UpdatedAt int64                 `json:"updatedAt,omitempty"` //更新时间
	DeletedAt int64                 `json:"deletedAt,omitempty"` //删除时间
}

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

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