feat:完善信息
This commit is contained in:
78
app/enterprise/api/technology.go
Normal file
78
app/enterprise/api/technology.go
Normal file
@ -0,0 +1,78 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/api"
|
||||
"SciencesServer/app/enterprise/controller/technology"
|
||||
"SciencesServer/app/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Technology struct{}
|
||||
|
||||
type (
|
||||
// paperForm 论文参数
|
||||
paperForm struct {
|
||||
Title string `json:"title" form:"title" binding:"required"` // 题目
|
||||
Ext string `json:"ext" form:"ext" binding:"required"` // 格式
|
||||
Author string `json:"author" form:"author" binding:"required"` // 作者
|
||||
PublishAt string `json:"publish_at" form:"publish_at" binding:"required"` // 出版日期
|
||||
Keyword string `json:"keyword" form:"keyword"` // 关键词
|
||||
Tags []string `json:"tags" form:"tags"` // 标签
|
||||
Remark string `json:"remark" form:"remark"` // 备注
|
||||
}
|
||||
)
|
||||
|
||||
func (a *Technology) Paper(c *gin.Context) {
|
||||
form := &struct {
|
||||
Title string `json:"title"`
|
||||
api.PageForm
|
||||
}{}
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise)).List(form.Title, form.Page, form.PageSize)
|
||||
api.APIResponse(err, data)
|
||||
}
|
||||
|
||||
func (a *Technology) PaperAdd(c *gin.Context) {
|
||||
form := new(paperForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise)).Form(&technology.PaperParams{
|
||||
Title: form.Title, Ext: form.Ext, Author: form.Author, PublishAt: form.PublishAt,
|
||||
Keyword: form.Keyword, Tags: form.Tags, Remark: form.Remark,
|
||||
})
|
||||
api.APIResponse(err)
|
||||
}
|
||||
|
||||
func (a *Technology) PaperEdit(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
paperForm
|
||||
}{}
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise)).Form(&technology.PaperParams{
|
||||
ID: form.Convert(), Title: form.Title, Ext: form.Ext, Author: form.Author, PublishAt: form.PublishAt,
|
||||
Keyword: form.Keyword, Tags: form.Tags, Remark: form.Remark,
|
||||
})
|
||||
api.APIResponse(err)
|
||||
}
|
||||
|
||||
func (a *Technology) PaperDelete(c *gin.Context) {
|
||||
form := new(api.IDStringForm)
|
||||
|
||||
if err := api.Bind(form)(c); err != nil {
|
||||
api.APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise)).Delete(form.Convert())
|
||||
api.APIResponse(err)
|
||||
}
|
||||
Reference in New Issue
Block a user