JeshuaRen 1 year ago
parent
commit
2d71acf748
2 changed files with 30 additions and 30 deletions
  1. +12
    -12
      common/models/models.go
  2. +18
    -18
      common/pkgs/db2/model/model.go

+ 12
- 12
common/models/models.go View File

@@ -7,10 +7,10 @@ import (
)

type ObjectBlock struct {
ObjectID cdssdk.ObjectID `gorm:"column:ObjectID; primaryKey" json:"objectID"`
Index int `gorm:"column:Index; primaryKey" json:"index"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey" json:"storageID"` // 这个块应该在哪个节点上
FileHash cdssdk.FileHash `gorm:"column:FileHash" json:"fileHash"`
ObjectID cdssdk.ObjectID `gorm:"column:ObjectID; primaryKey; type:bigint" json:"objectID"`
Index int `gorm:"column:Index; primaryKey; type:int" json:"index"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey; type:bigint" json:"storageID"` // 这个块应该在哪个节点上
FileHash cdssdk.FileHash `gorm:"column:FileHash; type:char(64); not null" json:"fileHash"`
}

func (ObjectBlock) TableName() string {
@@ -106,10 +106,10 @@ type LocalMachineInfo struct {
}

type PackageAccessStat struct {
PackageID cdssdk.PackageID `gorm:"column:PackageID; primaryKey" json:"packageID"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey" json:"storageID"`
Amount float64 `gorm:"column:Amount" json:"amount"` // 前一日的读取量的滑动平均值
Counter float64 `gorm:"column:Counter" json:"counter"` // 当日的读取量
PackageID cdssdk.PackageID `gorm:"column:PackageID; primaryKey; type:bigint" json:"packageID"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey; type:bigint" json:"storageID"`
Amount float64 `gorm:"column:Amount; type:double" json:"amount"` // 前一日的读取量的滑动平均值
Counter float64 `gorm:"column:Counter; type:double" json:"counter"` // 当日的读取量
}

func (PackageAccessStat) TableName() string {
@@ -117,10 +117,10 @@ func (PackageAccessStat) TableName() string {
}

type ObjectAccessStat struct {
ObjectID cdssdk.ObjectID `gorm:"column:ObjectID; primaryKey" json:"objectID"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey" json:"storageID"`
Amount float64 `gorm:"column:Amount" json:"amount"` // 前一日的读取量的滑动平均值
Counter float64 `gorm:"column:Counter" json:"counter"` // 当日的读取量
ObjectID cdssdk.ObjectID `gorm:"column:ObjectID; primaryKey; type:bigint" json:"objectID"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey; type:bigint" json:"storageID"`
Amount float64 `gorm:"column:Amount; type:float; not null" json:"amount"` // 前一日的读取量的滑动平均值
Counter float64 `gorm:"column:Counter; type:float; not null" json:"counter"` // 当日的读取量
}

func (ObjectAccessStat) TableName() string {


+ 18
- 18
common/pkgs/db2/model/model.go View File

@@ -14,8 +14,8 @@ import (
type Storage = cdssdk.Storage

type User struct {
UserID cdssdk.UserID `gorm:"column:UserID" json:"userID"`
Password string `gorm:"column:Password" json:"password"`
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey; type:bigint" json:"userID"`
Password string `gorm:"column:Password; type:varchar(255); not null" json:"password"`
}

func (User) TableName() string {
@@ -23,8 +23,8 @@ func (User) TableName() string {
}

type UserBucket struct {
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey" json:"userID"`
BucketID cdssdk.BucketID `gorm:"column:BucketID; primaryKey" json:"bucketID"`
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey; type:bigint" json:"userID"`
BucketID cdssdk.BucketID `gorm:"column:BucketID; primaryKey; type:bigint" json:"bucketID"`
}

func (UserBucket) TableName() string {
@@ -32,8 +32,8 @@ func (UserBucket) TableName() string {
}

type UserNode struct {
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey" json:"userID"`
NodeID cdssdk.NodeID `gorm:"column:NodeID; primaryKey" json:"nodeID"`
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey; type:bigint" json:"userID"`
NodeID cdssdk.NodeID `gorm:"column:NodeID; primaryKey; type:bigint" json:"nodeID"`
}

func (UserNode) TableName() string {
@@ -41,8 +41,8 @@ func (UserNode) TableName() string {
}

type UserStorage struct {
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey" json:"userID"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey" json:"storageID"`
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey; type:bigint" json:"userID"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey; type:bigint" json:"storageID"`
}

func (UserStorage) TableName() string {
@@ -92,10 +92,10 @@ func (o *RedundancyWarpper) Scan(src interface{}) error {
type ObjectBlock = stgmod.ObjectBlock

type Cache struct {
FileHash cdssdk.FileHash `gorm:"column:FileHash; primaryKey" json:"fileHash"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey" json:"storageID"`
CreateTime time.Time `gorm:"column:CreateTime" json:"createTime"`
Priority int `gorm:"column:Priority" json:"priority"`
FileHash cdssdk.FileHash `gorm:"column:FileHash; primaryKey; type: char(64)" json:"fileHash"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey; type: bigint" json:"storageID"`
CreateTime time.Time `gorm:"column:CreateTime; type:datetime" json:"createTime"`
Priority int `gorm:"column:Priority; type:int" json:"priority"`
}

func (Cache) TableName() string {
@@ -110,10 +110,10 @@ const (

// Storage当前加载的Package
type StoragePackage struct {
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey" json:"storageID"`
PackageID cdssdk.PackageID `gorm:"column:PackageID; primaryKey" json:"packageID"`
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey" json:"userID"`
State string `gorm:"column:State" json:"state"`
StorageID cdssdk.StorageID `gorm:"column:StorageID; primaryKey; type:bigint" json:"storageID"`
PackageID cdssdk.PackageID `gorm:"column:PackageID; primaryKey; type:bigint" json:"packageID"`
UserID cdssdk.UserID `gorm:"column:UserID; primaryKey; type:bigint" json:"userID"`
State string `gorm:"column:State; type:varchar(255); not null" json:"state"`
}

func (StoragePackage) TableName() string {
@@ -121,8 +121,8 @@ func (StoragePackage) TableName() string {
}

type Location struct {
LocationID cdssdk.LocationID `gorm:"column:LocationID; primaryKey; autoIncrement" json:"locationID"`
Name string `gorm:"column:Name" json:"name"`
LocationID cdssdk.LocationID `gorm:"column:LocationID; primaryKey; type:bigint; autoIncrement" json:"locationID"`
Name string `gorm:"column:Name; type:varchar(255); not null" json:"name"`
}

func (Location) TableName() string {


Loading…
Cancel
Save