feat:完善网站信息

This commit is contained in:
henry
2021-12-22 14:11:14 +08:00
parent b0a9ef3569
commit 332f67d1c1
14 changed files with 637 additions and 28 deletions

40
app/api/website/api/es.go Normal file
View File

@ -0,0 +1,40 @@
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"`
Title string `json:"title" form:"title"`
Keyword string `json:"keyword" form:"keyword"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
manage := service.NewManage(
service.WithManageID(form.ID),
service.WithManageTitle(form.Title),
service.WithManageKeyword(form.Keyword),
)
api.APIResponse(manage.Create())(c)
}
func (*ES) Search(c *gin.Context) {
form := &struct {
Params map[string]interface{} `json:"params" form:"params"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
manage := service.NewManage()
data, err := manage.Search(form.Params)
api.APIResponse(err, data)(c)
}

View File

@ -0,0 +1,62 @@
package api
import (
"SciencesServer/app/api/website/controller/technology"
"SciencesServer/app/basic/api"
"github.com/gin-gonic/gin"
)
type Technology struct{}
func (*Technology) Patent(c *gin.Context) {
form := &struct {
Title string `json:"title" form:"title"`
Industry string `json:"industry" form:"industry"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology.NewPatent()().Instance(form.Title, form.Industry, form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (*Technology) PatentDetail(c *gin.Context) {
form := &struct {
api.IDStringForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology.NewPatent()().Detail(form.Convert())
api.APIResponse(err, data)(c)
}
func (*Technology) Demand(c *gin.Context) {
form := &struct {
Title string `json:"title" form:"title"`
Industry string `json:"industry" form:"industry"`
Kind string `json:"kind" form:"kind"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology.NewDemand()(nil).Instance(form.Title, form.Industry, form.Kind, form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (*Technology) DemandDetail(c *gin.Context) {
form := &struct {
api.IDStringForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology.NewDemand()(nil).Detail(form.Convert())
api.APIResponse(err, data)(c)
}