feat:完善项目管理

This commit is contained in:
henry
2021-12-16 09:44:59 +08:00
parent a59759379c
commit 8ab89cc051
7 changed files with 129 additions and 4 deletions

View File

@ -1 +1,15 @@
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)
}

View 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)
}

View File

@ -1,13 +1,33 @@
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 {
return nil
return func(session *session.Enterprise, local string) *Docking {
return &Docking{
Enterprise: session,
local: local,
}
}
}

View 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{}
}
}

View File

@ -0,0 +1,11 @@
package model
import "SciencesServer/app/common/model"
type ServiceMessage struct {
*model.ServiceMessage
}
func NewServiceMessage() *ServiceMessage {
return &ServiceMessage{model.NewServiceMessage()}
}

View 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{}
}

View File

@ -29,6 +29,18 @@ func registerAPI(app *gin.Engine) {
activityV1.POST("/detail", _api.Detail)
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