feat:完善项目信息

This commit is contained in:
henry
2022-01-18 17:31:20 +08:00
parent 10224e8db6
commit 26a3205c08
8 changed files with 75 additions and 49 deletions

View File

@ -10,14 +10,14 @@ import (
type (
// DemandInfo 需求信息
DemandInfo struct {
ID string `json:"id"`
Title string `json:"title"`
Mode string `json:"mode"`
Kind string `json:"kind"`
Industrys []string `json:"industrys"`
Budget float64 `json:"budget"`
BudgetMode model2.TechnologyDemandBudgetMode `json:"budget_mode"`
Deadline time.Time `json:"deadline"`
ID string `json:"id"`
Title string `json:"title"`
Kind string `json:"kind"`
Industrys []string `json:"industrys"`
Budget float64 `json:"budget"`
BudgetMode model2.TechnologyDemandBudgetMode `json:"budget_mode"`
Deadline time.Time `json:"deadline"`
CompanyKind int `json:"company_kind"`
}
)
@ -25,36 +25,23 @@ type (
func searchDemand(page, pageSize int, keyword, industry string, params map[string]interface{}) (interface{}, error) {
mTechnologyDemand := model.NewTechnologyDemand()
out := make([]*model2.TechnologyDemand, 0)
where := []*model2.ModelWhereOrder{
&model2.ModelWhereOrder{
Where: model2.NewWhere("status", model2.TechnologyDemandStatusForAgree),
Order: model2.NewOrder("id", model2.OrderModeToDesc),
},
}
where := make([]*model2.ModelWhere, 0)
if keyword != "" {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhereLike("title", keyword),
})
where = append(where, model2.NewWhereLike("d.title", keyword))
}
if industry != "" {
where = append(where, &model2.ModelWhereOrder{Where: model2.NewWhereCondition("industry", "LIKE",
"%"+fmt.Sprintf(`"%v`, industry)+"%")})
where = append(where, model2.NewWhereCondition("d.industry", "LIKE", "%"+fmt.Sprintf(`"%v`, industry)+"%"))
}
if len(params) > 0 {
for k, v := range params {
where = append(where, &model2.ModelWhereOrder{
Where: model2.NewWhere(k, v),
})
where = append(where, model2.NewWhere(k, v))
}
}
var count int64
out, err := mTechnologyDemand.Demand(where...)
if err := model2.PagesFields(mTechnologyDemand.TechnologyDemand, &out, []string{"id", "title", "mode", "kind", "industry",
"budget", "budget_mode", "deadline"}, page, pageSize, &count, where...); err != nil {
if err != nil {
return nil, err
}
list := make([]*DemandInfo, 0)
@ -62,12 +49,12 @@ func searchDemand(page, pageSize int, keyword, industry string, params map[strin
for _, v := range out {
list = append(list, &DemandInfo{
ID: v.GetEncodeID(), Title: v.Title,
Mode: v.Mode,
Kind: v.Kind,
Industrys: v.GetIndustryAttribute(),
Budget: v.Budget,
BudgetMode: v.BudgetMode,
Deadline: v.Deadline,
Kind: v.Kind,
Industrys: v.GetIndustryAttribute(),
Budget: v.Budget,
BudgetMode: v.BudgetMode,
Deadline: v.Deadline,
CompanyKind: v.CompanyKind,
})
}
return list, nil