Files

271 lines
9.3 KiB
Go
Raw Normal View History

2021-10-09 11:55:54 +08:00
package api
import (
"SciencesServer/app/basic/api"
2021-10-14 15:58:51 +08:00
"SciencesServer/app/basic/config"
2021-10-09 11:55:54 +08:00
"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"` // 备注
}
2021-10-15 11:05:38 +08:00
// patentForm 专利参数
patentForm struct {
Title string `json:"title" form:"title"`
IPCCode string `json:"ipc_code" form:"ipc_code"`
CPCCode string `json:"cpc_code" form:"cpc_code"`
ApplyCode string `json:"apply_code" form:"apply_code"`
ApplyName string `json:"apply_name" form:"apply_name"`
ApplyAddress string `json:"apply_address" form:"apply_address"`
ApplyZipCode string `json:"apply_zip_code" form:"apply_zip_code"`
Inventor string `json:"inventor" form:"inventor"`
PriorityCode string `json:"priority_code" form:"priority_code"`
OpenCode string `json:"open_code" form:"open_code"`
ApplyAt string `json:"apply_at" form:"apply_at"`
PriorityAt string `json:"priority_at" form:"priority_at"`
OpenAt string `json:"open_at" form:"open_at"`
}
2021-10-14 15:58:51 +08:00
// 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"`
}
2021-10-09 11:55:54 +08:00
)
func (a *Technology) Paper(c *gin.Context) {
form := &struct {
2021-10-14 16:40:23 +08:00
Title string `json:"title" form:"title"`
2021-10-09 11:55:54 +08:00
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
2021-10-13 14:41:46 +08:00
data, err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
2021-10-13 11:23:55 +08:00
List(form.Title, form.Page, form.PageSize)
2021-10-13 14:35:24 +08:00
api.APIResponse(err, data)(c)
2021-10-09 11:55:54 +08:00
}
func (a *Technology) PaperAdd(c *gin.Context) {
form := new(paperForm)
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
2021-10-13 14:41:46 +08:00
err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
2021-10-13 11:23:55 +08:00
Form(&technology.PaperParams{
Title: form.Title, Ext: form.Ext, Author: form.Author, PublishAt: form.PublishAt,
Keyword: form.Keyword, Tags: form.Tags, Remark: form.Remark,
})
2021-10-13 14:35:24 +08:00
api.APIResponse(err)(c)
2021-10-09 11:55:54 +08:00
}
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
}
2021-10-13 14:41:46 +08:00
err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
2021-10-13 11:23:55 +08:00
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,
})
2021-10-13 14:35:24 +08:00
api.APIResponse(err)(c)
2021-10-09 11:55:54 +08:00
}
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
}
2021-10-13 14:41:46 +08:00
err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
2021-10-13 11:23:55 +08:00
Delete(form.Convert())
2021-10-13 14:35:24 +08:00
api.APIResponse(err)(c)
2021-10-09 11:55:54 +08:00
}
2021-10-14 15:58:51 +08:00
2021-10-15 11:05:38 +08:00
func (a *Technology) Patent(c *gin.Context) {
form := &struct {
Title string `json:"title" form:"title"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
List(form.Title, form.Page, form.PageSize)
api.APIResponse(err, data)(c)
}
func (a *Technology) PatentDetail(c *gin.Context) {
form := new(api.IDStringForm)
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
data, err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Detail(form.Convert())
api.APIResponse(err, data)(c)
}
func (a *Technology) PatentAdd(c *gin.Context) {
form := new(patentForm)
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Form(&technology.PatentParams{
Title: form.Title, IPCCode: form.IPCCode, CPCCode: form.CPCCode, ApplyCode: form.ApplyCode,
ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress, ApplyZipCode: form.ApplyZipCode,
Inventor: form.Inventor, PriorityCode: form.PriorityCode, OpenCode: form.OpenCode, ApplyAt: form.ApplyAt,
PriorityAt: form.PriorityAt, OpenAt: form.OpenAt,
})
api.APIResponse(err)(c)
}
func (a *Technology) PatentEdit(c *gin.Context) {
form := &struct {
api.IDStringForm
patentForm
}{}
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Form(&technology.PatentParams{
ID: form.Convert(), Title: form.Title, IPCCode: form.IPCCode, CPCCode: form.CPCCode,
ApplyCode: form.ApplyCode, ApplyName: form.ApplyName, ApplyAddress: form.ApplyAddress,
ApplyZipCode: form.ApplyZipCode, Inventor: form.Inventor, PriorityCode: form.PriorityCode, OpenCode: form.OpenCode,
ApplyAt: form.ApplyAt, PriorityAt: form.PriorityAt, OpenAt: form.OpenAt,
})
api.APIResponse(err)(c)
}
func (a *Technology) PatentDelete(c *gin.Context) {
form := new(api.IDStringForm)
if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c)
return
}
err := technology.NewPatent()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)).
Delete(form.Convert())
api.APIResponse(err)(c)
}
2021-10-14 15:58:51 +08:00
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)
2021-10-14 16:40:23 +08:00
}
func (a *Technology) DemandDetail(c *gin.Context) {
form := new(api.IDStringForm)
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)).
Detail(form.Convert())
api.APIResponse(err, data)(c)
2021-10-14 15:58:51 +08:00
}
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)
}