feat:增加用户服务需求数据模型
This commit is contained in:
91
app/api/enterprise/api/service.go
Normal file
91
app/api/enterprise/api/service.go
Normal file
@ -0,0 +1,91 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/controller/service"
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/session"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Service struct{}
|
||||
|
||||
type (
|
||||
// demandServiceForm 服务需求信息
|
||||
demandServiceForm struct {
|
||||
Kinds []int `json:"kinds" form:"kinds"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Name string `json:"name" form:"name" binding:"required"`
|
||||
Mobile string `json:"mobile" form:"mobile" binding:"required"`
|
||||
Description string `json:"description" form:"description" binding:"required"`
|
||||
IsSubmit int `json:"is_submit" form:"is_submit"`
|
||||
}
|
||||
)
|
||||
|
||||
func (*Service) Demand(c *gin.Context) {
|
||||
form := &struct {
|
||||
Title string `json:"title" form:"title"`
|
||||
Status int `json:"status" form:"status"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||
List(form.Title, form.Status, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) DemandDetail(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||
Detail(form.Convert())
|
||||
api.APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
func (*Service) DemandAdd(c *gin.Context) {
|
||||
form := new(demandServiceForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||
Form(&service.DemandParams{Kinds: form.Kinds, IsSubmit: form.IsSubmit, Title: form.Title,
|
||||
Name: form.Name, Mobile: form.Mobile, Description: form.Description,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) DemandEdit(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
demandServiceForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||
Form(&service.DemandParams{ID: form.Convert(), Kinds: form.Kinds, IsSubmit: form.IsSubmit, Title: form.Title,
|
||||
Name: form.Name, Mobile: form.Mobile, Description: form.Description,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
func (*Service) DemandDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := service.NewDemand()(api.GetSession()(c).(*session.Enterprise), api.GetLocal()(c).(string)).
|
||||
Delete(form.Convert())
|
||||
api.APIResponse(err)(c)
|
||||
}
|
Reference in New Issue
Block a user