92 lines
2.7 KiB
Go
92 lines
2.7 KiB
Go
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.GetTenantID()(c).(uint64)).
|
|
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.GetTenantID()(c).(uint64)).
|
|
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.GetTenantID()(c).(uint64)).
|
|
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.GetTenantID()(c).(uint64)).
|
|
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.GetTenantID()(c).(uint64)).
|
|
Delete(form.Convert())
|
|
api.APIResponse(err)(c)
|
|
}
|