feat:完善项目信息
This commit is contained in:
@ -21,6 +21,7 @@ type (
|
||||
ID string `json:"id"`
|
||||
*model.ManageCompanyInfo
|
||||
Industrys []string `json:"industrys"`
|
||||
Address string `json:"address"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// CompanyDetail 公司企业详细信息
|
||||
@ -68,8 +69,17 @@ func (c *Company) Instance(tenantID uint64, name string, status int, page, pageS
|
||||
for _, v := range out {
|
||||
mManageCompany.Industry = v.Industry
|
||||
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range mManageCompany.GetIndustryAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "/"))
|
||||
}
|
||||
list = append(list, &CompanyInstance{
|
||||
ID: v.GetEncodeID(), ManageCompanyInfo: v, Industrys: mManageCompany.GetIndustryAttribute(), Area: v.FormatBasic(),
|
||||
ID: v.GetEncodeID(), ManageCompanyInfo: v, Industrys: _industrys,
|
||||
Address: v.FormatBasic(), Area: (&model2.Area{
|
||||
Province: v.TenantProvince,
|
||||
City: v.TenantCity,
|
||||
}).FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -72,13 +71,16 @@ func (c *Expert) Instance(tenantID uint64, name string, examineStatus int, page,
|
||||
for _, v := range out {
|
||||
_industrys := make([]string, 0)
|
||||
|
||||
for _, v := range strings.Split(v.Industry, ";") {
|
||||
for _, v := range mManageExpert.GetIndustryAttribute() {
|
||||
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", "/"))
|
||||
}
|
||||
// 研究机构,实验室
|
||||
list = append(list, &ExpertInstance{ID: v.GetEncodeID(), Name: v.Name, Industrys: _industrys,
|
||||
ResearchName: v.ResearchName, LaboratoryName: v.LaboratoryName, ExamineStatus: v.ExamineStatus,
|
||||
Address: v.FormatBasic(), CreatedAt: v.CreatedAt, Area: v.FormatBasic(),
|
||||
Address: v.FormatBasic(), CreatedAt: v.CreatedAt, Area: (&model2.Area{
|
||||
Province: v.TenantProvince,
|
||||
City: v.TenantCity,
|
||||
}).FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
|
128
app/api/admin/controller/manage/research.go
Normal file
128
app/api/admin/controller/manage/research.go
Normal file
@ -0,0 +1,128 @@
|
||||
package manage
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/admin/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Research struct {
|
||||
*session.Admin
|
||||
}
|
||||
|
||||
type ResearchHandle func(session *session.Admin) *Research
|
||||
|
||||
type (
|
||||
// ResearchInstance 科研机构信息
|
||||
ResearchInstance struct {
|
||||
ID string `json:"id"`
|
||||
*model.ManageResearchInfo
|
||||
Address string `json:"address"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// ResearchSelect 科研机构筛选信息
|
||||
ResearchSelect struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
// ResearchDetail 科研机构详细信息
|
||||
ResearchDetail struct {
|
||||
ID string `json:"id"`
|
||||
TenantID string `json:"tenant_id"`
|
||||
*model2.ManageResearch
|
||||
Area string `json:"area"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Research) Instance(tenantID uint64, name string, examineStatus, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
where := make([]*model2.ModelWhere, 0)
|
||||
|
||||
if c.TenantID > 0 {
|
||||
where = append(where, model2.NewWhere("r.tenant_id", c.TenantID))
|
||||
}
|
||||
if tenantID > 0 {
|
||||
where = append(where, model2.NewWhere("r.tenant_id", tenantID))
|
||||
}
|
||||
if name != "" {
|
||||
where = append(where, model2.NewWhereLike("r.name", name))
|
||||
}
|
||||
if examineStatus > 0 {
|
||||
where = append(where, model2.NewWhere("r.examine_status", examineStatus))
|
||||
}
|
||||
var count int64
|
||||
|
||||
out, err := mManageResearch.Researchs(page, pageSize, &count, where...)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ResearchInstance, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ResearchInstance{
|
||||
ID: v.GetEncodeID(), ManageResearchInfo: v,
|
||||
Address: v.FormatBasic(), Area: (&model2.Area{
|
||||
Province: v.TenantProvince,
|
||||
City: v.TenantCity,
|
||||
}).FormatBasic(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
// Select 筛选信息
|
||||
func (c *Research) Select(tenantID uint64) ([]*ResearchSelect, error) {
|
||||
if tenantID <= 0 {
|
||||
tenantID = c.TenantID
|
||||
}
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
out := make([]*model2.ManageResearch, 0)
|
||||
|
||||
if err := model2.ScanFields(mManageResearch.ManageResearch, &out, []string{"id", "name"}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("tenant_id", tenantID)}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("examine_status", model2.ExamineStatusForAgree)}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*ResearchSelect, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &ResearchSelect{
|
||||
ID: v.GetEncodeID(),
|
||||
Name: v.Name,
|
||||
})
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
|
||||
func (c *Research) Form() {
|
||||
|
||||
}
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *Research) Detail(id uint64) (*ResearchDetail, error) {
|
||||
mManageResearch := model.NewManageResearch()
|
||||
|
||||
out, err := mManageResearch.Research(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if out.ManageResearch == nil {
|
||||
return nil, errors.New("操作错误,科研机构信息不存在或已被删除")
|
||||
}
|
||||
return &ResearchDetail{
|
||||
ID: out.GetEncodeID(), TenantID: out.GetEncodeTenantID(),
|
||||
ManageResearch: out.ManageResearch, Area: out.FormatBasic(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewResearch() ResearchHandle {
|
||||
return func(session *session.Admin) *Research {
|
||||
return &Research{session}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user