Files

51 lines
1.4 KiB
Go

package api
import (
"SciencesServer/app/basic/api"
"SciencesServer/app/service"
"github.com/gin-gonic/gin"
)
type ES struct{}
func (*ES) Create(c *gin.Context) {
form := &struct {
ID uint64 `json:"id" form:"id"`
Identity int `json:"identity" form:"identity"`
Title string `json:"title" form:"title"`
Keyword string `json:"keyword" form:"keyword"`
Research string `json:"research" form:"research"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
manage := service.NewESManage(
service.WithManageID(form.ID),
service.WithManageIdentity(form.Identity),
service.WithManageTitle(form.Title),
service.WithManageKeyword(form.Keyword),
service.WithManageResearch(form.Research),
)
api.APIResponse(manage.Create())(c)
}
func (*ES) Search(c *gin.Context) {
form := &struct {
Identity int `json:"identity" form:"identity" binding:"required"`
Industry string `json:"industry" form:"industry"`
Param string `json:"param" form:"params"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
manage := service.NewESManage(service.WithManageIdentity(form.Identity),
service.WithManageTitle(form.Param),
service.WithManageIndustry(form.Industry),
service.WithManageKeyword(form.Param),
service.WithManageResearch(form.Param))
data, err := manage.Search(1, 1)
api.APIResponse(err, data)(c)
}