-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity.go
40 lines (33 loc) · 1.01 KB
/
entity.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 text_lang
import (
"time"
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/go-ozzo/ozzo-validation/v4/is"
"gorm.io/gorm"
)
const (
EntityName = "textLang"
TableName = "text_lang"
)
// TextLang ...
type TextLang struct {
ID uint `gorm:"type:serial;primaryKey" json:"id"`
Code string `gorm:"type:varchar(100) not null;unique;index" json:"code"`
Name string `gorm:"type:varchar(100) not null" json:"name"`
Cfgname string `gorm:"type:varchar(100) not null" json:"cfgname"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
}
func (e *TextLang) TableName() string {
return TableName
}
// New func is a constructor for the EntityType
func New() *TextLang {
return &TextLang{}
}
func (e TextLang) Validate() error {
return validation.ValidateStruct(&e,
validation.Field(&e.Code, validation.Length(0, 3), is.Alpha, is.LowerCase),
)
}