This commit is contained in:
Joe
2026-01-16 15:49:34 +08:00
commit 550d3e1f42
380 changed files with 62024 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package models
import (
"github.com/goravel/framework/database/orm"
)
type <<.ModelName>> struct {
orm.Model
orm.SoftDeletes
<<range .Fields>>
<<.FieldName>> <<.GoType>> `gorm:"<<.Name>>" json:"<<.JsonName>>"<<if .Comment>> comment:"<<.Comment>>"<<end>><<if .Relation>> json:"<<.Relation.Table>>_<<.Relation.DisplayField>>" gorm:"<<.Relation.Table>>;foreignKey:<<.Relation.ForeignKey>>"<<end>>`
<<- end>>
}
func (<<.ModelName>>) TableName() string {
return "<<.TableName>>"
}
func (r *<<.ModelName>>) Serialize() map[string]any {
return map[string]any{
"id": r.ID,
"created_at": r.CreatedAt,
"updated_at": r.UpdatedAt,
<<range .Fields>>
"<<.JsonName>>": r.<<.FieldName>>,
<<end>>
}
}
func (r *<<.ModelName>>) Deserialize(data map[string]any) {
<<range .Fields>>
if val, ok := data["<<.JsonName>>"]; ok {
r.<<.FieldName>> = val.(<<.GoType>>)
}
<<end>>
}