feat:完善信息

This commit is contained in:
henry
2021-10-14 15:58:51 +08:00
parent cb130b6081
commit 456b8a849e
8 changed files with 382 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package api
import (
"SciencesServer/app/basic/api"
"SciencesServer/app/basic/config"
"SciencesServer/app/enterprise/controller/technology"
"SciencesServer/app/service"
"github.com/gin-gonic/gin"
@ -20,6 +21,24 @@ type (
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) {
@ -79,3 +98,71 @@ func (a *Technology) PaperDelete(c *gin.Context) {
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)
}