-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity.go
42 lines (35 loc) · 1.33 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
41
42
package property_view_type
import (
"time"
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/yaruz/app/pkg/yarus_platform/reference/domain/sysname"
"gorm.io/gorm"
)
const (
EntityName = "propertyViewType"
TableName = "property_view_type"
)
// PropertyViewType ...
type PropertyViewType struct {
ID uint `gorm:"type:bigserial;primaryKey" json:"id"`
Sysname string `gorm:"type:varchar(100) not null;unique;index" json:"sysname"`
NameSourceID *uint `gorm:"type:bigint null REFERENCES \"text_source\"(id);index" json:"-"`
DescriptionSourceID *uint `gorm:"type:bigint null REFERENCES \"text_source\"(id);index" json:"-"`
Name *string `gorm:"-" json:"name"`
Description *string `gorm:"-" json:"description"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
}
func (e *PropertyViewType) TableName() string {
return TableName
}
// New func is a constructor for the EntityType
func New() *PropertyViewType {
return &PropertyViewType{}
}
func (e PropertyViewType) Validate() error {
return validation.ValidateStruct(&e,
validation.Field(&e.Sysname, sysname.ValidationRules...),
)
}