61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package schema
|
|
|
|
import (
|
|
"github.guxuan/haibei/pkg/util"
|
|
)
|
|
|
|
// Defining the `Notice` struct.
|
|
type Notice struct {
|
|
util.BaseModel
|
|
Title string `json:"title" gorm:"size:128;not null;index"`
|
|
Content string `json:"content" gorm:"size:2048;not null"`
|
|
Sequence int `json:"sequence" gorm:"index;default:0"`
|
|
AreaID uint `json:"areaId" gorm:"index;comment:城市id"`
|
|
|
|
Status string `json:"status" gorm:"size:20;index"`
|
|
}
|
|
|
|
// Defining the query parameters for the `Notice` struct.
|
|
type NoticeQueryParam struct {
|
|
util.PaginationParam
|
|
AreaID uint `form:"areaId"`
|
|
}
|
|
|
|
// Defining the query options for the `Notice` struct.
|
|
type NoticeQueryOptions struct {
|
|
util.QueryOptions
|
|
}
|
|
|
|
// Defining the query result for the `Notice` struct.
|
|
type NoticeQueryResult struct {
|
|
Data Notices
|
|
PageResult *util.PaginationResult
|
|
}
|
|
|
|
// Defining the slice of `Notice` struct.
|
|
type Notices []*Notice
|
|
|
|
// Defining the data structure for creating a `Notice` struct.
|
|
type NoticeForm struct {
|
|
Title string `json:"title" `
|
|
Content string `json:"content"`
|
|
Sequence int `json:"sequence" `
|
|
Status string `json:"status"`
|
|
AreaID uint `json:"areaId"`
|
|
}
|
|
|
|
// A validation function for the `NoticeForm` struct.
|
|
func (a *NoticeForm) Validate() error {
|
|
return nil
|
|
}
|
|
|
|
// Convert `NoticeForm` to `Notice` object.
|
|
func (a *NoticeForm) FillTo(notice *Notice) error {
|
|
notice.Title = a.Title
|
|
notice.Content = a.Content
|
|
notice.Sequence = a.Sequence
|
|
notice.Status = a.Status
|
|
notice.AreaID = a.AreaID
|
|
return nil
|
|
}
|