package schema import ( "github.com/google/uuid" "gitlab.guxuan.icu/jinshan_community/pkg/util" "gorm.io/gorm" ) // Defining the `WebSite` struct. type WebSite struct { util.BaseModel Phone string `json:"phone" gorm:"size:128;comment:联系电话"` } // Defining the query parameters for the `WebSite` struct. type WebSiteQueryParam struct { util.PaginationParam } func (c *WebSite) BeforeCreate(tx *gorm.DB) (err error) { if c.ID == "" { c.ID = uuid.New().String() } return } // Defining the query options for the `WebSite` struct. type WebSiteQueryOptions struct { util.QueryOptions } // Defining the query result for the `WebSite` struct. type WebSiteQueryResult struct { Data WebSites PageResult *util.PaginationResult } // Defining the slice of `WebSite` struct. type WebSites []*WebSite // Defining the data structure for creating a `WebSite` struct. type WebSiteForm struct { Phone string `json:"phone"` } // A validation function for the `WebSiteForm` struct. func (a *WebSiteForm) Validate() error { return nil } // Convert `WebSiteForm` to `WebSite` object. func (a *WebSiteForm) FillTo(webSite *WebSite) error { webSite.Phone = a.Phone return nil }