object_table.go 2.4 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 ObjectTable struct {
	Id            int                   `json:"id"`                            // ID
	TableId       int                   `json:"tableId" `                      //表ID
	Name          string                `json:"name"`                          //表名
	TableType     string                `json:"tableType" `                    //模块
	CompanyId     int64                 `json:"companyId"`                     //公司id
	ParentId      int                   `json:"parentId"`                      //父id
	Flag          string                `json:"flag"`                          //分组:Group 集合:Set
	Fields        []*bytelib.Field      `json:"fields" gorm:"serializer:json"` //表字段
	Version       int                   `json:"version,omitempty"`             //版本
	RemoteDeleted int                   `json:"remoteDeleted"`                 //远端删除
	IsDel         soft_delete.DeletedAt `json:"isDel,omitempty"`               //删除标记
	CreatedAt     int64                 `json:"createdAt,omitempty"`           //创建时间
	UpdatedAt     int64                 `json:"updatedAt,omitempty"`           //更新时间
	DeletedAt     int64                 `json:"deletedAt,omitempty"`           //删除时间
}

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

type ObjectTableDataRepository interface {
	InsertWithTableData(ctx context.Context, conn transaction.Conn, tableDataPreview bytelib.TableData) error
}

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