forked from ariefdarmawan/kasset
-
Notifications
You must be signed in to change notification settings - Fork 1
/
asset.go
40 lines (34 loc) · 951 Bytes
/
asset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package kasset
import (
"git.kanosolution.net/kano/appkit"
"git.kanosolution.net/kano/dbflex"
"git.kanosolution.net/kano/dbflex/orm"
)
type Asset struct {
orm.DataModelBase `json:"-" bson:"-"`
ID string `json:"_id" bson:"_id"`
Title string `json:"title"`
OriginalFileName string `json:"originalfilename"`
NewFileName string `json:"newfilename"`
URI string `json:"uri"`
ContentType string `json:"contenttype"`
Size int `json:"size"`
Tags string `json:"tags"`
}
func (a *Asset) TableName() string {
return "assets"
}
func (a *Asset) GetID(c dbflex.IConnection) ([]string, []interface{}) {
return []string{"_id"}, []interface{}{a.ID}
}
func (a *Asset) SetID(keys ...interface{}) {
if len(keys) > 0 {
a.ID = keys[0].(string)
}
}
func (a *Asset) PreSave(c dbflex.IConnection) error {
if a.ID == "" {
a.ID = appkit.MakeID("", 32)
}
return nil
}