67 lines
2.0 KiB
Go
67 lines
2.0 KiB
Go
package schema
|
|
|
|
import (
|
|
"github.guxuan/haibei/pkg/util"
|
|
)
|
|
|
|
// Defining the `QeustionDetail` struct.
|
|
type QeustionDetail struct {
|
|
util.BaseModel
|
|
QuestionID uint `json:"questionId" gorm:"index;"`
|
|
CustomerID uint `json:"customerId" gorm:"index;"`
|
|
Content *[]QuestionDetailTable `json:"content" gorm:"serializer:json;comment:问卷表单详情"`
|
|
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
|
}
|
|
type QuestionDetailTable struct {
|
|
Label string `json:"label"`
|
|
Typer string `json:"type"`
|
|
Required bool `json:"required"`
|
|
Options []string `json:"options"`
|
|
Answer string `json:"answer"`
|
|
}
|
|
|
|
// Defining the query parameters for the `QeustionDetail` struct.
|
|
type QeustionDetailQueryParam struct {
|
|
util.PaginationParam
|
|
QuestionID uint `form:"questionId" `
|
|
CustomerID uint `form:"customerId" `
|
|
Status string `form:"status" `
|
|
}
|
|
|
|
// Defining the query options for the `QeustionDetail` struct.
|
|
type QeustionDetailQueryOptions struct {
|
|
util.QueryOptions
|
|
}
|
|
|
|
// Defining the query result for the `QeustionDetail` struct.
|
|
type QeustionDetailQueryResult struct {
|
|
Data QeustionDetails
|
|
PageResult *util.PaginationResult
|
|
}
|
|
|
|
// Defining the slice of `QeustionDetail` struct.
|
|
type QeustionDetails []*QeustionDetail
|
|
|
|
// Defining the data structure for creating a `QeustionDetail` struct.
|
|
type QeustionDetailForm struct {
|
|
QuestionID uint `json:"questionId" `
|
|
CustomerID uint `json:"customerId" `
|
|
Content *[]QuestionDetailTable `json:"content" `
|
|
Status string `json:"status" `
|
|
}
|
|
|
|
// A validation function for the `QeustionDetailForm` struct.
|
|
func (a *QeustionDetailForm) Validate() error {
|
|
return nil
|
|
}
|
|
|
|
// Convert `QeustionDetailForm` to `QeustionDetail` object.
|
|
func (a *QeustionDetailForm) FillTo(qeustionDetail *QeustionDetail) error {
|
|
qeustionDetail.CustomerID = a.CustomerID
|
|
qeustionDetail.QuestionID = a.QuestionID
|
|
qeustionDetail.Content = a.Content
|
|
qeustionDetail.Status = a.Status
|
|
|
|
return nil
|
|
}
|