feat:完善项目
This commit is contained in:
@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"ArmedPolice/serve/orm"
|
||||
"ArmedPolice/utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@ -12,13 +13,14 @@ import (
|
||||
// IModel
|
||||
type IModel interface {
|
||||
GetID() uint64
|
||||
GetEncodeID() string
|
||||
TableName() string
|
||||
SetDatabase(database string, key ...string)
|
||||
}
|
||||
|
||||
// Model
|
||||
type Model struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;comment:主键" json:"id" form:"id"`
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement;comment:主键" json:"-" form:"id"`
|
||||
|
||||
Database string `json:"-" gorm:"-"`
|
||||
}
|
||||
@ -58,14 +60,14 @@ const (
|
||||
FieldsForDeleted string = "is_deleted"
|
||||
)
|
||||
|
||||
const (
|
||||
SubDatabase string = "tenant"
|
||||
)
|
||||
|
||||
func (m *Model) GetID() uint64 {
|
||||
return m.ID
|
||||
}
|
||||
|
||||
func (m *Model) GetEncodeID() string {
|
||||
return utils.HASHIDEncode(int(m.ID))
|
||||
}
|
||||
|
||||
func (m *Model) SetDatabase(database string, key ...string) {
|
||||
m.Database = database + "_" + strings.Join(key, "_")
|
||||
}
|
||||
|
Reference in New Issue
Block a user