feat:完善网站信息,修改留言信息模块
This commit is contained in:
@ -13,12 +13,14 @@ func (*Message) Launch(c *gin.Context) {
|
||||
form := &struct {
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
||||
Email string `json:"email" form:"email"`
|
||||
Company string `json:"company" form:"company"`
|
||||
Content string `json:"content" form:"content" binding:"required"`
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := controller.NewMessage()().Form(form.Name, form.Mobile, form.Content)
|
||||
err := controller.NewMessage()().Form(form.Name, form.Mobile, form.Email, form.Company, form.Content)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
@ -10,10 +10,12 @@ type Message struct{}
|
||||
type MessageHandle func() *Message
|
||||
|
||||
// Form 留言发起
|
||||
func (c *Message) Form(name, mobile, content string) error {
|
||||
func (c *Message) Form(name, mobile, email, company, content string) error {
|
||||
mServiceMessage := model.NewServiceMessage()
|
||||
mServiceMessage.Name = name
|
||||
mServiceMessage.Mobile = mobile
|
||||
mServiceMessage.Email = email
|
||||
mServiceMessage.Company = company
|
||||
mServiceMessage.Content = content
|
||||
return model2.Create(mServiceMessage.ServiceMessage)
|
||||
}
|
||||
|
@ -5,11 +5,24 @@ type ServiceMessage struct {
|
||||
Model
|
||||
Name string `gorm:"column:name;type:varchar(20);default:'';comment:联系人" json:"name"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"`
|
||||
Email string `gorm:"column:email;type:varchar(50);default:'';comment:邮箱" json:"email"`
|
||||
Company string `gorm:"column:company;type:varchar(100);default:'';comment:公司名称" json:"company"`
|
||||
Content string `gorm:"column:content;type:varchar(255);default:'';comment:联系内容" json:"content"`
|
||||
Status int `gorm:"column:status;type:tinyint(1);default:0;comment:状态" json:"status"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// ServiceMessageStatus 留言数据状态
|
||||
type ServiceMessageStatus int
|
||||
|
||||
const (
|
||||
// ServiceMessageStatusForProcessing 处理中
|
||||
ServiceMessageStatusForProcessing ServiceMessageStatus = iota
|
||||
// ServiceMessageStatusForProcessed 已处理
|
||||
ServiceMessageStatusForProcessed
|
||||
)
|
||||
|
||||
func (m *ServiceMessage) TableName() string {
|
||||
return "service_message"
|
||||
}
|
||||
|
Reference in New Issue
Block a user