feat:完善信息

This commit is contained in:
henry
2021-10-14 16:40:23 +08:00
parent 456b8a849e
commit 1fa9adbd25
2 changed files with 40 additions and 1 deletions

View File

@ -43,7 +43,7 @@ type (
func (a *Technology) Paper(c *gin.Context) {
form := &struct {
Title string `json:"title"`
Title string `json:"title" form:"title"`
api.PageForm
}{}
if err := api.Bind(form)(c); err != nil {
@ -113,6 +113,18 @@ func (a *Technology) Demand(c *gin.Context) {
api.APIResponse(err, data)(c)
}
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)
}
func (a *Technology) DemandAdd(c *gin.Context) {
form := new(demandForm)

View File

@ -30,6 +30,14 @@ type (
Deadline time.Time `json:"deadline"`
CreatedAt time.Time `json:"created_at"`
}
// DemandDetailInfo 需求详细信息
DemandDetailInfo struct {
ID string `json:"id"`
*model2.TechnologyDemand
Kinds []string `json:"kinds"`
Industry []string `json:"industry"`
*model2.TechnologyDemandOther
}
// DemandParams 需求参数信息
DemandParams struct {
ID uint64
@ -77,6 +85,25 @@ func (c *Demand) List(status, page, pageSize int) (*controller.ReturnPages, erro
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 详细信息
func (c *Demand) Detail(id uint64) (*DemandDetailInfo, error) {
mTechnologyDemand := model.NewTechnologyDemand()
mTechnologyDemand.ID = id
isExist, err := model2.First(mTechnologyDemand.TechnologyDemand)
if err != nil {
return nil, err
} else if !isExist {
return nil, errors.New("操作错误,数据不存在")
}
return &DemandDetailInfo{
ID: mTechnologyDemand.GetEncodeID(), TechnologyDemand: mTechnologyDemand.TechnologyDemand,
Kinds: mTechnologyDemand.GetKindAttribute(), Industry: mTechnologyDemand.GetIndustryAttribute(),
TechnologyDemandOther: mTechnologyDemand.GetOtherAttribute(),
}, nil
}
// Form 数据操作
func (c *Demand) Form(params *DemandParams) error {
mTechnologyDemand := model.NewTechnologyDemand()