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

@ -20,8 +20,8 @@ type (
) )
// handle 审核处理 // handle 审核处理
func (a *manageExamineForm) handle(session *session.Admin) error { func (a *manageExamineForm) handle(session *session.Admin, params map[string]interface{}) error {
return manage.NewExamine()(session).Launch(a.Convert(), a.Identity, a.Status) return manage.NewExamine()(session).Launch(a.Convert(), a.Identity, a.Status, params)
} }
func (*Manage) Company(c *gin.Context) { func (*Manage) Company(c *gin.Context) {
@ -29,14 +29,18 @@ func (*Manage) Company(c *gin.Context) {
} }
func (*Manage) CompanyExamine(c *gin.Context) { func (*Manage) CompanyExamine(c *gin.Context) {
form := new(manageExamineForm) form := &struct {
manageExamineForm
Kind int `json:"kind" form:"kind" binding:"required"`
}{}
if err := api.Bind(form)(c); err != nil { if err := api.Bind(form)(c); err != nil {
api.APIFailure(err.(error))(c) api.APIFailure(err.(error))(c)
return return
} }
form.Identity = config.TenantUserIdentityForCompany form.Identity = config.TenantUserIdentityForCompany
err := form.handle(api.GetSession()(c).(*session.Admin)) err := form.handle(api.GetSession()(c).(*session.Admin), map[string]interface{}{
"kind": form.Kind,
})
api.APIResponse(err) api.APIResponse(err)
} }
@ -63,7 +67,7 @@ func (*Manage) ExpertExamine(c *gin.Context) {
return return
} }
form.Identity = config.TenantUserIdentityForExpert form.Identity = config.TenantUserIdentityForExpert
err := form.handle(api.GetSession()(c).(*session.Admin)) err := form.handle(api.GetSession()(c).(*session.Admin), nil)
api.APIResponse(err) api.APIResponse(err)
} }
@ -79,7 +83,7 @@ func (*Manage) LaboratoryExamine(c *gin.Context) {
return return
} }
form.Identity = config.TenantUserIdentityForLaboratory form.Identity = config.TenantUserIdentityForLaboratory
err := form.handle(api.GetSession()(c).(*session.Admin)) err := form.handle(api.GetSession()(c).(*session.Admin), nil)
api.APIResponse(err) api.APIResponse(err)
} }
@ -95,7 +99,7 @@ func (*Manage) ResearchExamine(c *gin.Context) {
return return
} }
form.Identity = config.TenantUserIdentityForResearch form.Identity = config.TenantUserIdentityForResearch
err := form.handle(api.GetSession()(c).(*session.Admin)) err := form.handle(api.GetSession()(c).(*session.Admin), nil)
api.APIResponse(err) api.APIResponse(err)
} }
@ -111,6 +115,6 @@ func (*Manage) AgentExamine(c *gin.Context) {
return return
} }
form.Identity = config.TenantUserIdentityForAgent form.Identity = config.TenantUserIdentityForAgent
err := form.handle(api.GetSession()(c).(*session.Admin)) err := form.handle(api.GetSession()(c).(*session.Admin), nil)
api.APIResponse(err) api.APIResponse(err)
} }

View File

@ -167,7 +167,7 @@ func examineAgent(id, tenantID uint64) (*ExamineManageInfo, error) {
} }
// Launch 发起审核 // Launch 发起审核
func (c *Examine) Launch(id uint64, identity, status int) error { func (c *Examine) Launch(id uint64, identity, status int, params map[string]interface{}) error {
_status := model2.ExamineStatusKind(status) _status := model2.ExamineStatusKind(status)
if _status != model2.ExamineStatusForRefuse && _status != model2.ExamineStatusForAgree { if _status != model2.ExamineStatusForRefuse && _status != model2.ExamineStatusForAgree {
@ -184,7 +184,14 @@ func (c *Examine) Launch(id uint64, identity, status int) error {
return err return err
} }
return orm.GetDB().Transaction(func(tx *gorm.DB) error { return orm.GetDB().Transaction(func(tx *gorm.DB) error {
if err = model2.Updates(data.IModel, map[string]interface{}{"examine_status": status, "updated_at": time.Now()}, tx); err != nil { values := map[string]interface{}{"examine_status": status, "updated_at": time.Now()}
if identity == config.TenantUserIdentityForCompany {
for k, v := range params {
values[k] = v
}
}
if err = model2.Updates(data.IModel, values, tx); err != nil {
return err return err
} }
// 拒绝后,不执行以下数据 // 拒绝后,不执行以下数据

View File

@ -82,7 +82,6 @@ func (c *Company) Launch(params *BasicParams, inviterID uint64, other *config.Id
} }
mManageCompany.TenantID = c.tenantID mManageCompany.TenantID = c.tenantID
mManageCompany.InviterID = inviterID mManageCompany.InviterID = inviterID
mManageCompany.Kind = model2.ManageCompanyKind(other.Kind)
mManageCompany.Name = params.Name mManageCompany.Name = params.Name
mManageCompany.Code = params.Code mManageCompany.Code = params.Code
mManageCompany.Image = model2.Image{Image: params.Image} mManageCompany.Image = model2.Image{Image: params.Image}

View File

@ -128,8 +128,6 @@ func (c *Demand) Form(params *DemandParams) error {
mTechnologyDemand.Name = params.Name mTechnologyDemand.Name = params.Name
mTechnologyDemand.Mobile = params.Mobile mTechnologyDemand.Mobile = params.Mobile
mTechnologyDemand.Introduce = params.Introduce mTechnologyDemand.Introduce = params.Introduce
// TODO用户公司模式
mTechnologyDemand.Mode = params.Introduce
mTechnologyDemand.SetKindAttribute(params.Kinds) mTechnologyDemand.SetKindAttribute(params.Kinds)
mTechnologyDemand.SetIndustryAttribute(params.Industry) mTechnologyDemand.SetIndustryAttribute(params.Industry)
mTechnologyDemand.Budget = params.Budget mTechnologyDemand.Budget = params.Budget

View File

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

View File

@ -10,6 +10,32 @@ type TechnologyDemand struct {
*model.TechnologyDemand *model.TechnologyDemand
} }
type TechnologyDemandInfo struct {
*model.TechnologyDemand
CompanyKind int `json:"company_kind"`
}
func (m *TechnologyDemand) Demand(where ...*model.ModelWhere) ([]*TechnologyDemandInfo, error) {
out := make([]*TechnologyDemandInfo, 0)
db := orm.GetDB().Table(m.TableName()+" AS d").
Select("d.id", "d.title", "d.kind", "d.industry", "d.budget", "d.budget_mode", "d.deadline",
"c.kind AS company_kind").
Joins(fmt.Sprintf("LEFT JOIN %s AS u_c ON d.uid = u_c.uid AND u_c.is_deleted = %d",
model.NewUserCompany().TableName(), model.DeleteStatusForNot)).
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u_c.company_id = c.id", model.NewManageCompany().TableName())).
Where("d.status = ?", model.TechnologyDemandStatusForAgree)
if len(where) > 0 {
for _, v := range where {
db = db.Where(v.Condition, v.Value)
}
}
err := db.Order("d.id " + model.OrderModeToDesc).Scan(&out).Error
return out, err
}
// Distribution 分布信息 // Distribution 分布信息
func (m *TechnologyDemand) Distribution() ([]*DataAreaDistributionInfo, error) { func (m *TechnologyDemand) Distribution() ([]*DataAreaDistributionInfo, error) {
out := make([]*DataAreaDistributionInfo, 0) out := make([]*DataAreaDistributionInfo, 0)

View File

@ -34,10 +34,16 @@ type ManageCompanyBasic struct {
CompanyKeyword string `json:"company_keyword"` CompanyKeyword string `json:"company_keyword"`
} }
// ManageCompanyKind 公司类型
type ManageCompanyKind int type ManageCompanyKind int
const ( const (
ManageCompanyKindForMYQY ManageCompanyKind = iota + 1 // ManageCompanyKindForListedEnterprise 上市企业
ManageCompanyKindForListedEnterprise ManageCompanyKind = iota + 101
// ManageCompanyKindForHighQuality 优质企业
ManageCompanyKindForHighQuality
// ManageCompanyKindForOrdinary 普通企业
ManageCompanyKindForOrdinary
) )
func (m *ManageCompany) TableName() string { func (m *ManageCompany) TableName() string {

View File

@ -12,7 +12,6 @@ type TechnologyDemand struct {
ModelTenant ModelTenant
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"` UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
Title string `gorm:"column:title;type:varchar(50);default:'';comment:需求名称" json:"title"` Title string `gorm:"column:title;type:varchar(50);default:'';comment:需求名称" json:"title"`
Mode string `gorm:"column:mode;type:varchar(50);default:'';comment:需求模式(普通企业需求)" json:"-"`
Kind string `gorm:"column:kind;type:varchar(100);default:'';comment:需求类别" json:"-"` Kind string `gorm:"column:kind;type:varchar(100);default:'';comment:需求类别" json:"-"`
Name string `gorm:"column:name;type:varchar(30);default:'';comment:联系人" json:"name"` Name string `gorm:"column:name;type:varchar(30);default:'';comment:联系人" json:"name"`
Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"` Mobile string `gorm:"column:mobile;type:varchar(15);default:'';comment:联系方式" json:"mobile"`