feat:完善项目管理
This commit is contained in:
@ -1 +1,15 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/controller"
|
||||||
|
"SciencesServer/app/basic/api"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Docking struct{}
|
||||||
|
|
||||||
|
// Launch 联系客服对接
|
||||||
|
func (*Docking) Launch(c *gin.Context) {
|
||||||
|
err := controller.NewDocking()(nil, "").Form()
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
||||||
|
24
app/api/website/api/message.go
Normal file
24
app/api/website/api/message.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/controller"
|
||||||
|
"SciencesServer/app/basic/api"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Message struct{}
|
||||||
|
|
||||||
|
// Launch 留言发起
|
||||||
|
func (*Message) Launch(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
Name string `json:"name" form:"name" binding:"required"`
|
||||||
|
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
||||||
|
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)
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
@ -1,13 +1,33 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
type Docking struct{}
|
import (
|
||||||
|
"SciencesServer/app/api/website/model"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/session"
|
||||||
|
)
|
||||||
|
|
||||||
type DockingHandle func()
|
type Docking struct {
|
||||||
|
*session.Enterprise
|
||||||
|
local string
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Docking) Message() {
|
type DockingHandle func(session *session.Enterprise, local string) *Docking
|
||||||
|
|
||||||
|
// Form 联系客服对接
|
||||||
|
func (c *Docking) Form() error {
|
||||||
|
mServiceDocking := model.NewServiceDocking()
|
||||||
|
|
||||||
|
if c.Enterprise != nil {
|
||||||
|
mServiceDocking.UID = c.UID
|
||||||
|
}
|
||||||
|
return model2.Create(mServiceDocking.ServiceDocking)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDocking() DockingHandle {
|
func NewDocking() DockingHandle {
|
||||||
return nil
|
return func(session *session.Enterprise, local string) *Docking {
|
||||||
|
return &Docking{
|
||||||
|
Enterprise: session,
|
||||||
|
local: local,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
25
app/api/website/controller/message.go
Normal file
25
app/api/website/controller/message.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"SciencesServer/app/api/website/model"
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Message struct{}
|
||||||
|
|
||||||
|
type MessageHandle func() *Message
|
||||||
|
|
||||||
|
// Form 留言发起
|
||||||
|
func (c *Message) Form(name, mobile, content string) error {
|
||||||
|
mServiceMessage := model.NewServiceMessage()
|
||||||
|
mServiceMessage.Name = name
|
||||||
|
mServiceMessage.Mobile = mobile
|
||||||
|
mServiceMessage.Content = content
|
||||||
|
return model2.Create(mServiceMessage.ServiceMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMessage() MessageHandle {
|
||||||
|
return func() *Message {
|
||||||
|
return &Message{}
|
||||||
|
}
|
||||||
|
}
|
11
app/api/website/model/service_message.go
Normal file
11
app/api/website/model/service_message.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type ServiceMessage struct {
|
||||||
|
*model.ServiceMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServiceMessage() *ServiceMessage {
|
||||||
|
return &ServiceMessage{model.NewServiceMessage()}
|
||||||
|
}
|
19
app/common/model/service_message.go
Normal file
19
app/common/model/service_message.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// ServiceMessage 留言数据模型
|
||||||
|
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"`
|
||||||
|
Content string `gorm:"column:content;type:varchar(255);default:'';comment:联系内容" json:"content"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ServiceMessage) TableName() string {
|
||||||
|
return "service_message"
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServiceMessage() *ServiceMessage {
|
||||||
|
return &ServiceMessage{}
|
||||||
|
}
|
@ -29,6 +29,18 @@ func registerAPI(app *gin.Engine) {
|
|||||||
activityV1.POST("/detail", _api.Detail)
|
activityV1.POST("/detail", _api.Detail)
|
||||||
activityV1.POST("/join", _api.Join)
|
activityV1.POST("/join", _api.Join)
|
||||||
}
|
}
|
||||||
|
// Docking 对接信息管理
|
||||||
|
dockingV1 := v1.Group("/docking")
|
||||||
|
{
|
||||||
|
_api := new(api2.Docking)
|
||||||
|
dockingV1.POST("/launch", _api.Launch)
|
||||||
|
}
|
||||||
|
// Message 数据信息管理
|
||||||
|
messageV1 := v1.Group("/message")
|
||||||
|
{
|
||||||
|
_api := new(api2.Message)
|
||||||
|
messageV1.POST("/launch", _api.Launch)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerAdminAPI 注册API
|
// registerAdminAPI 注册API
|
||||||
|
Reference in New Issue
Block a user