48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"SciencesServer/app/api/website/controller"
|
|
"SciencesServer/app/basic/api"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Activity struct{}
|
|
|
|
func (*Activity) Instance(c *gin.Context) {
|
|
form := &struct {
|
|
Title string `json:"title" form:"title"`
|
|
Mode int `json:"mode" form:"mode"`
|
|
api.PageForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := controller.NewActivity()(nil, "").Instance(form.Title, form.Mode, form.Page, form.PageSize)
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Activity) Detail(c *gin.Context) {
|
|
form := &struct {
|
|
api.IDStringForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
data, err := controller.NewActivity()(nil, "").Detail(form.Convert())
|
|
api.APIResponse(err, data)(c)
|
|
}
|
|
|
|
func (*Activity) Join(c *gin.Context) {
|
|
form := &struct {
|
|
api.IDStringForm
|
|
}{}
|
|
if err := api.Bind(form)(c); err != nil {
|
|
api.APIFailure(err.(error))(c)
|
|
return
|
|
}
|
|
err := controller.NewActivity()(nil, "").Join(form.Convert())
|
|
api.APIResponse(err)(c)
|
|
}
|