package api import ( "SciencesServer/app/basic/api" "SciencesServer/app/basic/config" "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"` // 备注 } // demandForm 需求参数 demandForm struct { Title string `json:"title"` Introduce string `json:"introduce"` Name string `json:"name"` Mobile string `json:"mobile"` Deadline string `json:"deadline"` Industry []string `json:"industry"` Kinds []string `json:"kinds"` config.Area Budget float64 `json:"budget"` BudgetMode int `json:"budget_mode"` Expect []string `json:"expect"` // 期望合作的企业及模式 DemandBasic string `json:"demand_basic"` // 基础 DemandExpect string `json:"demand_expect"` // 预期 DemandBenefit string `json:"demand_benefit"` // 效益 Status int `json:"status"` } ) 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), api.GetLocal()(c).(string)). List(form.Title, form.Page, form.PageSize) api.APIResponse(err, data)(c) } 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), api.GetLocal()(c).(string)). 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)(c) } 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), api.GetLocal()(c).(string)). 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)(c) } 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), api.GetLocal()(c).(string)). Delete(form.Convert()) api.APIResponse(err)(c) } func (a *Technology) Demand(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 := technology.NewDemand()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)). List(form.Status, form.Page, form.PageSize) api.APIResponse(err, data)(c) } func (a *Technology) DemandAdd(c *gin.Context) { form := new(demandForm) if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := technology.NewDemand()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)). Form(&technology.DemandParams{ Title: form.Title, Introduce: form.Introduce, Name: form.Name, Mobile: form.Mobile, Deadline: form.Deadline, Industry: form.Industry, Kinds: form.Kinds, Area: form.Area, Budget: form.Budget, BudgetMode: form.BudgetMode, Expect: form.Expect, Demand: struct { Basic string `json:"basic"` Expect string `json:"expect"` Benefit string `json:"benefit"` }{Basic: form.DemandBasic, Expect: form.DemandExpect, Benefit: form.DemandBenefit}, Status: form.Status, }) api.APIResponse(err)(c) } func (a *Technology) DemandEdit(c *gin.Context) { form := &struct { api.IDStringForm demandForm }{} if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := technology.NewDemand()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)). Form(&technology.DemandParams{ ID: form.Convert(), Title: form.Title, Introduce: form.Introduce, Name: form.Name, Mobile: form.Mobile, Deadline: form.Deadline, Industry: form.Industry, Kinds: form.Kinds, Area: form.Area, Budget: form.Budget, BudgetMode: form.BudgetMode, Expect: form.Expect, Demand: struct { Basic string `json:"basic"` Expect string `json:"expect"` Benefit string `json:"benefit"` }{Basic: form.DemandBasic, Expect: form.DemandExpect, Benefit: form.DemandBenefit}, Status: form.Status, }) api.APIResponse(err)(c) } func (a *Technology) DemandDelete(c *gin.Context) { form := new(api.IDStringForm) if err := api.Bind(form)(c); err != nil { api.APIFailure(err.(error))(c) return } err := technology.NewDemand()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)). Delete(form.Convert()) api.APIResponse(err)(c) }