mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
cloudcommon: extend interface for fetching metadata
This commit is contained in:
@@ -129,6 +129,9 @@ type IModel interface {
|
||||
object.IObject
|
||||
|
||||
GetName() string
|
||||
GetUpdateVersion() int
|
||||
GetUpdatedAt() time.Time
|
||||
GetDeleted() bool
|
||||
|
||||
KeywordPlural() string
|
||||
|
||||
@@ -283,6 +286,7 @@ type IVirtualModelManager interface {
|
||||
|
||||
type IVirtualModel interface {
|
||||
IStandaloneModel
|
||||
IPendingDeletable
|
||||
|
||||
IsOwner(userCred mcclient.TokenCredential) bool
|
||||
// IsAdmin(userCred mcclient.TokenCredential) bool
|
||||
|
||||
@@ -412,6 +412,18 @@ func (model *SModelBase) GetName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (model *SModelBase) GetUpdatedAt() time.Time {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (model *SModelBase) GetUpdateVersion() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (model *SModelBase) GetDeleted() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (model *SModelBase) SetModelManager(man IModelManager, virtual IModel) {
|
||||
model.manager = man
|
||||
model.SetVirtualObject(virtual)
|
||||
|
||||
@@ -329,6 +329,14 @@ func (opslog *SOpsLog) GetName() string {
|
||||
return fmt.Sprintf("%s-%s", opslog.ObjType, opslog.Action)
|
||||
}
|
||||
|
||||
func (opslog *SOpsLog) GetUpdatedAt() time.Time {
|
||||
return opslog.OpsTime
|
||||
}
|
||||
|
||||
func (opslog *SOpsLog) GetUpdateVersion() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func (opslog *SOpsLog) GetModelManager() IModelManager {
|
||||
return OpsLog
|
||||
}
|
||||
|
||||
@@ -128,3 +128,15 @@ func (manager *SResourceBaseManager) ListItemFilter(ctx context.Context, q *sqlc
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (model *SResourceBase) GetUpdateVersion() int {
|
||||
return model.UpdateVersion
|
||||
}
|
||||
|
||||
func (model *SResourceBase) GetUpdatedAt() time.Time {
|
||||
return model.UpdatedAt
|
||||
}
|
||||
|
||||
func (model *SResourceBase) GetDeleted() bool {
|
||||
return model.Deleted
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user