2025-06-19 10:35:26 +08:00

69 lines
1.9 KiB
Go

package schema
import (
"github.com/google/uuid"
"gitlab.guxuan.icu/jinshan_community/pkg/util"
"gorm.io/gorm"
)
// Defining the `Reciprocity` struct.
type Reciprocity struct {
util.BaseModel
CustomerID string `json:"customerId" gorm:"type:char(36);index;comment:客户id"`
Title string `json:"title" gorm:"size:128;not null;index;comment:标题"`
Images *[]string `json:"images" gorm:"serializer:json;comment:详图数组"`
Content string `json:"content" gorm:"type:text;not null;comment:活动详情"`
Status string `json:"status" gorm:"size:20;index;comment:状态"`
}
func (c *Reciprocity) BeforeCreate(tx *gorm.DB) (err error) {
if c.ID == "" {
c.ID = uuid.New().String()
}
return
}
// Defining the query parameters for the `Reciprocity` struct.
type ReciprocityQueryParam struct {
util.PaginationParam
}
// Defining the query options for the `Reciprocity` struct.
type ReciprocityQueryOptions struct {
util.QueryOptions
}
// Defining the query result for the `Reciprocity` struct.
type ReciprocityQueryResult struct {
Data Reciprocities
PageResult *util.PaginationResult
}
// Defining the slice of `Reciprocity` struct.
type Reciprocities []*Reciprocity
// Defining the data structure for creating a `Reciprocity` struct.
type ReciprocityForm struct {
CustomerID string `json:"customerId"`
Title string `json:"title"`
Images *[]string `json:"images"`
Content string `json:"content"`
Status string `json:"status"`
}
// A validation function for the `ReciprocityForm` struct.
func (a *ReciprocityForm) Validate() error {
return nil
}
// Convert `ReciprocityForm` to `Reciprocity` object.
func (a *ReciprocityForm) FillTo(reciprocity *Reciprocity) error {
reciprocity.CustomerID = a.CustomerID
reciprocity.Title = a.Title
reciprocity.Images = a.Images
reciprocity.Content = a.Content
reciprocity.Status = a.Status
return nil
}