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

71 lines
1.9 KiB
Go

package schema
import (
"github.com/google/uuid"
"gitlab.guxuan.icu/jinshan_community/pkg/util"
"gorm.io/gorm"
)
// Defining the `MettingRoom` struct.
type MettingRoom struct {
util.BaseModel
Title string `json:"title" gorm:"size:128;index;comment:标题"`
Desc string `json:"desc" gorm:"size:128;comment:介绍"`
Imgs []*string `json:"imgs" gorm:"size:2048;comment:图片"`
MaxNum int `json:"maxNum" gorm:"comment:容纳人数"`
Link string `json:"link" gorm:"size:2048;comment:链接"`
Status string `json:"status" gorm:"size:20;index;comment:状态"`
}
func (c *MettingRoom) BeforeCreate(tx *gorm.DB) (err error) {
if c.ID == "" {
c.ID = uuid.New().String()
}
return
}
// Defining the query parameters for the `MettingRoom` struct.
type MettingRoomQueryParam struct {
util.PaginationParam
}
// Defining the query options for the `MettingRoom` struct.
type MettingRoomQueryOptions struct {
util.QueryOptions
}
// Defining the query result for the `MettingRoom` struct.
type MettingRoomQueryResult struct {
Data MettingRooms
PageResult *util.PaginationResult
}
// Defining the slice of `MettingRoom` struct.
type MettingRooms []*MettingRoom
// Defining the data structure for creating a `MettingRoom` struct.
type MettingRoomForm struct {
Title string `json:"title"`
Desc string `json:"desc" `
Imgs []*string `json:"imgs" `
MaxNum int `json:"maxNum" `
Link string `json:"link" `
Status string `json:"status"`
}
// A validation function for the `MettingRoomForm` struct.
func (a *MettingRoomForm) Validate() error {
return nil
}
// Convert `MettingRoomForm` to `MettingRoom` object.
func (a *MettingRoomForm) FillTo(mettingRoom *MettingRoom) error {
mettingRoom.Title = a.Title
mettingRoom.Desc = a.Desc
mettingRoom.Imgs = a.Imgs
mettingRoom.MaxNum = a.MaxNum
mettingRoom.Link = a.Link
mettingRoom.Status = a.Status
return nil
}