PaymentCenter/app/http/entities/backend/merchant.go

67 lines
1.7 KiB
Go

package backend
import (
"PaymentCenter/app/http/entities"
"PaymentCenter/app/models/merchantmodel"
)
type MerchantListRequest struct {
entities.PageRequest
Name string `form:"name"`
Contact string `form:"contact"`
Phone string `form:"phone"`
GroupInfo string
}
type MerchantResponse struct {
Id int64 `json:"id"`
Name string `json:"name"`
Contact string `json:"contact"`
Phone string `json:"phone"`
Remark string `json:"remark"`
CreateTime string `json:"create_time"`
}
func (m *MerchantResponse) ResponseFromDb(db merchantmodel.Merchant) {
m.Id = db.Id
m.Name = db.Name
m.Contact = db.Contact
m.Phone = db.Phone
m.Remark = db.Remark
m.CreateTime = db.CreateTime.Format("2006-01-02 15:04:05")
}
type MerchantCreateRequest struct {
Name string `json:"name" validate:"required" label:"商户名称"`
Contact string `json:"contact" validate:"required" label:"联系人"`
Phone string `json:"phone" validate:"required,phoneValidation" label:"联系电话"`
Remark string `json:"remark" label:"备注"`
Creator int
}
func (m *MerchantCreateRequest) RequestToDb() (db merchantmodel.Merchant) {
db.Name = m.Name
db.Contact = m.Contact
db.Phone = m.Phone
db.Remark = m.Remark
db.Creator = m.Creator
return db
}
type MerchantUpdateRequest struct {
Id int64 `json:"id" validate:"required" label:"商户ID"`
Name string `json:"name"`
Contact string `json:"contact"`
Phone string `json:"phone" validate:"phoneValidation" label:"联系电话"`
Remark string `json:"remark"`
}
func (m *MerchantUpdateRequest) RequestToDb() (db merchantmodel.Merchant) {
db.Id = m.Id
db.Name = m.Name
db.Contact = m.Contact
db.Phone = m.Phone
db.Remark = m.Remark
return db
}