feat:完善信息

This commit is contained in:
henry
2021-10-22 17:10:43 +08:00
parent fdda4b0209
commit e753e99fd8
6 changed files with 150 additions and 21 deletions

View File

@ -5,12 +5,33 @@ import (
"SciencesServer/app/basic/api"
"SciencesServer/app/basic/config"
"SciencesServer/app/service"
config2 "SciencesServer/config"
"github.com/gin-gonic/gin"
"strings"
)
type Technology struct{}
type (
// instanceForm 技术参数
instanceForm struct {
PatentID uint64 `json:"patent_id" form:"patent_id" binding:"required"`
Territory uint64 `json:"territory" form:"territory"`
Title string `json:"title" form:"title" binding:"required"`
Company string `json:"company" form:"company" binding:"required"`
api.ImageForm
ProveImages string `json:"prove_images" form:"prove_images" binding:"required"`
Introduce string `json:"introduce" form:"introduce" binding:"required"`
Purpose string `json:"purpose" form:"purpose" binding:"required"`
Remark string `json:"remark" form:"remark"`
Maturity int `json:"maturity" form:"maturity"`
Prototype int `json:"prototype" form:"prototype"`
Source int `json:"source" form:"source"`
Transaction int `json:"transaction" form:"transaction"`
Status int `json:"status" form:"status"`
Products []string `json:"products" form:"products"`
Keywords []string `json:"keywords" form:"keywords"`
}
// paperForm 论文参数
paperForm struct {
Title string `json:"title" form:"title" binding:"required"` // 题目
@ -70,6 +91,87 @@ type (
}
)
func (a *instanceForm) FilterProveImages() string {
return strings.Replace(a.ProveImages, config2.SettingInfo.Domain, "", -1)
}
func (a *Technology) Instance(c *gin.Context) {
form := &struct {
Status int `json:"status" form:"status"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology2.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
List(form.Status, form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (a *Technology) InstanceAdd(c *gin.Context) {
form := new(instanceForm)
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology2.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Form(&technology2.InstanceParams{
PatentID: form.PatentID, Territory: form.Territory, Title: form.Title, Company: form.Company,
Images: form.FilterImageURL(), ProveImages: form.FilterProveImages(), Introduce: form.Introduce, Purpose: form.Purpose,
Remark: form.Remark, Maturity: form.Maturity, Prototype: form.Prototype, Source: form.Source,
Transaction: form.Transaction, Status: form.Status, Products: form.Products, Keywords: form.Keywords,
})
api.APIResponse(err)(c)
}
func (a *Technology) InstanceEdit(c *gin.Context) {
form := &struct {
api.IDStringForm
instanceForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology2.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Form(&technology2.InstanceParams{
ID: form.Convert(),
PatentID: form.PatentID, Territory: form.Territory, Title: form.Title, Company: form.Company,
Images: form.FilterImageURL(), ProveImages: form.FilterProveImages(), Introduce: form.Introduce, Purpose: form.Purpose,
Remark: form.Remark, Maturity: form.Maturity, Prototype: form.Prototype, Source: form.Source,
Transaction: form.Transaction, Status: form.Status, Products: form.Products, Keywords: form.Keywords,
})
api.APIResponse(err)(c)
}
func (a *Technology) InstanceShelf(c *gin.Context) {
form := &struct {
api.IDStringForm
Status int `json:"status" form:"status"`
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology2.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Shelf(form.Convert(), form.Status)
api.APIResponse(err)(c)
}
func (a *Technology) InstanceDelete(c *gin.Context) {
form := new(api.IDStringForm)
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology2.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Delete(form.Convert())
api.APIResponse(err)(c)
}
func (a *Technology) Paper(c *gin.Context) {
form := &struct {
Title string `json:"title" form:"title"`

View File

@ -102,6 +102,9 @@ func (c *Topic) Form(params *TopicParams) error {
return errors.New("操作错误,课题信息不存在")
} else if mTechnologyTopic.UID != c.ManageUID {
return errors.New("无权限操作")
} else if mTechnologyTopic.Status != model2.TechnologyTopicStatusForDraft &&
mTechnologyTopic.Status != model2.TechnologyTopicStatusForRefuse {
return errors.New("操作错误,当前状态不允许修改")
}
}
mTechnologyTopic.Title = params.Title