40 lines
1.4 KiB
Go
40 lines
1.4 KiB
Go
package form
|
|
|
|
import (
|
|
"time"
|
|
|
|
db "management/internal/db/sqlc"
|
|
)
|
|
|
|
type CustomerForm struct {
|
|
ID int64 `json:"id" validate:"min=0" comment:"ID"`
|
|
Name string `json:"name" validate:"required" comment:"名称"`
|
|
Category int32 `json:"category" validate:"min=0" comment:"类别"`
|
|
Source int32 `json:"source" validate:"min=0" comment:"来源"`
|
|
Address string `json:"address" comment:"地址"`
|
|
ContactName string `json:"contact_name" comment:"联系人姓名"`
|
|
ContactPhone string `json:"contact_phone" validate:"telephone" comment:"联系人手机"`
|
|
Status int16 `json:"status" validate:"min=-1" comment:"状态"`
|
|
Sort int32 `json:"sort" validate:"min=0" comment:"排序"`
|
|
CreatedAt time.Time `json:"created_at" comment:"创建时间"`
|
|
CreatedBy string `json:"created_by" comment:"创建人"`
|
|
UpdatedAt time.Time `json:"updated_at" comment:"更新时间"`
|
|
UpdatedBy string `json:"updated_by" comment:"更新人"`
|
|
}
|
|
|
|
func (f *CustomerForm) ToForm(c *db.Customer) *CustomerForm {
|
|
return &CustomerForm{
|
|
ID: c.ID,
|
|
Name: c.Name,
|
|
Category: c.Category,
|
|
Source: c.Source,
|
|
Address: c.Address,
|
|
ContactName: c.ContactName,
|
|
ContactPhone: c.ContactPhone,
|
|
Status: c.Status,
|
|
Sort: c.Sort,
|
|
CreatedAt: c.CreatedAt,
|
|
UpdatedAt: c.UpdatedAt,
|
|
}
|
|
}
|