feat:完善信息

This commit is contained in:
henry
2022-01-26 10:34:29 +08:00
parent 5c1278a500
commit 180f63de42
8 changed files with 83 additions and 63 deletions

View File

@ -18,7 +18,7 @@ type (
api.ImageForm api.ImageForm
Name string `json:"name" form:"name" binding:"required"` Name string `json:"name" form:"name" binding:"required"`
Code string `json:"code" form:"code"` Code string `json:"code" form:"code"`
Mobile string `json:"mobile" form:"mobile" binding:"required"` Mobile string `json:"mobile" form:"mobile"`
config.Area config.Area
Industrys []string `json:"industrys" form:"industrys"` Industrys []string `json:"industrys" form:"industrys"`
Keywords []string `json:"keywords" form:"keywords"` Keywords []string `json:"keywords" form:"keywords"`

View File

@ -22,8 +22,10 @@ type (
ResearchInstance struct { ResearchInstance struct {
ID string `json:"id"` ID string `json:"id"`
*model.ManageResearchInfo *model.ManageResearchInfo
Address string `json:"address"` Industrys []string `json:"industrys"`
Area string `json:"area"` Researchs []string `json:"researchs"`
Address string `json:"address"`
Area string `json:"area"`
} }
// ResearchSelect 科研机构筛选信息 // ResearchSelect 科研机构筛选信息
ResearchSelect struct { ResearchSelect struct {
@ -69,9 +71,19 @@ func (c *Research) Instance(tenantID uint64, name string, examineStatus, page, p
list := make([]*ResearchInstance, 0) list := make([]*ResearchInstance, 0)
for _, v := range out { for _, v := range out {
mManageResearch.Industry = v.Industry
mManageResearch.ManageResearch.Research = v.Research
_industrys := make([]string, 0)
for _, v := range mManageResearch.GetIndustryAttribute() {
_industrys = append(_industrys, config.GetIndustryInfo(v, "-", ">").Value)
}
list = append(list, &ResearchInstance{ list = append(list, &ResearchInstance{
ID: v.GetEncodeID(), ManageResearchInfo: v, ID: v.GetEncodeID(), ManageResearchInfo: v,
Address: v.FormatBasic(), Area: (&model2.Area{ Industrys: _industrys,
Researchs: mManageResearch.GetResearchAttribute(),
Address: v.FormatBasic(), Area: (&model2.Area{
Province: v.TenantProvince, Province: v.TenantProvince,
City: v.TenantCity, City: v.TenantCity,
}).FormatBasic(), }).FormatBasic(),
@ -174,7 +186,7 @@ func (c *Research) Detail(id uint64) (*ResearchDetail, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} else if out.ManageResearch == nil { } else if out == nil {
return nil, errors.New("操作错误,科研机构信息不存在或已被删除") return nil, errors.New("操作错误,科研机构信息不存在或已被删除")
} }
_industrys := make([]*config.Industry, 0) _industrys := make([]*config.Industry, 0)
@ -187,7 +199,7 @@ func (c *Research) Detail(id uint64) (*ResearchDetail, error) {
return &ResearchDetail{ return &ResearchDetail{
ID: out.GetEncodeID(), TenantID: out.GetEncodeTenantID(), ID: out.GetEncodeID(), TenantID: out.GetEncodeTenantID(),
ManageResearch: out.ManageResearch, Industrys: _industrys, ManageResearch: out, Industrys: _industrys,
Keywords: out.GetKeywordAttribute(), Researchs: out.GetResearchAttribute(), Keywords: out.GetKeywordAttribute(), Researchs: out.GetResearchAttribute(),
}, nil }, nil
} }

View File

@ -4,6 +4,7 @@ import (
"SciencesServer/app/common/model" "SciencesServer/app/common/model"
"SciencesServer/serve/orm" "SciencesServer/serve/orm"
"fmt" "fmt"
"time"
) )
type ManageResearch struct { type ManageResearch struct {
@ -16,12 +17,13 @@ type (
model.Model model.Model
Name string `json:"name"` Name string `json:"name"`
Code string `json:"code"` Code string `json:"code"`
Industry string `json:"industry"` Industry string `json:"-"`
Research string `json:"research"` Research string `json:"-"`
ExamineStatus string `json:"examine_status"` ExamineStatus string `json:"examine_status"`
model.Area model.Area
TenantProvince string `json:"-"` TenantProvince string `json:"-"`
TenantCity string `json:"-"` TenantCity string `json:"-"`
CreatedAt time.Time `json:"created_at"`
} }
// ManageResearchDetail 详细信息 // ManageResearchDetail 详细信息
ManageResearchDetail struct { ManageResearchDetail struct {
@ -31,13 +33,13 @@ type (
) )
// Research 科研机构信息 // Research 科研机构信息
func (m *ManageResearch) Research(id uint64) (*ManageResearchDetail, error) { func (m *ManageResearch) Research(id uint64) (*model.ManageResearch, error) {
db := orm.GetDB().Table(m.TableName()+" AS r"). db := orm.GetDB().Table(m.TableName()+" AS r").
Select("r.*"). Select("r.*").
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())). Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())).
Where("r.id = ?", id) Where("r.id = ?", id)
out := new(ManageResearchDetail) out := new(model.ManageResearch)
err := db.Scan(out).Error err := db.Scan(out).Error
@ -48,7 +50,7 @@ func (m *ManageResearch) Research(id uint64) (*ManageResearchDetail, error) {
func (m *ManageResearch) Researchs(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageResearchInfo, error) { func (m *ManageResearch) Researchs(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageResearchInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS r"). db := orm.GetDB().Table(m.TableName()+" AS r").
Select("r.id", "r.name", "r.code", "r.industry", "r.research", "r.province", "r.city", "r.district", Select("r.id", "r.name", "r.code", "r.industry", "r.research", "r.province", "r.city", "r.district",
"r.examine_status", "t.province AS tenant_province", "t.city AS tenant_city"). "r.examine_status", "t.province AS tenant_province", "t.city AS tenant_city", "r.created_at").
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())). Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())).
Where("r.is_deleted = ?", model.DeleteStatusForNot) Where("r.is_deleted = ?", model.DeleteStatusForNot)

View File

@ -27,13 +27,13 @@ type (
} }
// ExpertMatchInfo 专家匹配信息 // ExpertMatchInfo 专家匹配信息
ExpertMatchInfo struct { ExpertMatchInfo struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
School string `json:"school"` School string `json:"school"`
Major string `json:"major"` Major string `json:"major"`
Industrys []string `json:"industrys"` Industrys []string `json:"industrys"`
Keywords []string `json:"keywords"` Keywords []string `json:"keywords"`
PatentTitles []string `json:"patent_titles"` PatentTitle []string `json:"patent_title"`
} }
// ExpertDetailInfo 专家详细信息 // ExpertDetailInfo 专家详细信息
ExpertDetailInfo struct { ExpertDetailInfo struct {
@ -193,13 +193,13 @@ func (c *Expert) Match(title string, industrys, keywords []string) (*controller.
for _, v := range experts { for _, v := range experts {
list = append(list, &ExpertMatchInfo{ list = append(list, &ExpertMatchInfo{
ID: v.GetEncodeID(), ID: v.GetEncodeID(),
Name: v.Name, Name: v.Name,
School: v.School, School: v.School,
Major: v.Major, Major: v.Major,
Industrys: v.GetIndustryAttribute(), Industrys: v.GetIndustryAttribute(),
Keywords: v.GetKeywordAttribute(), Keywords: v.GetKeywordAttribute(),
PatentTitles: strings.Split(v.PatentTitle, "&&"), PatentTitle: strings.Split(v.PatentTitle, "&&"),
}) })
} }
return &controller.ReturnPages{Data: list, Count: count}, nil return &controller.ReturnPages{Data: list, Count: count}, nil
@ -215,13 +215,13 @@ func (c *Expert) Detail(id uint64) (*ExpertDetailInfo, error) {
} }
return &ExpertDetailInfo{ return &ExpertDetailInfo{
ExpertMatchInfo: ExpertMatchInfo{ ExpertMatchInfo: ExpertMatchInfo{
ID: out.GetEncodeID(), ID: out.GetEncodeID(),
Name: out.Name, Name: out.Name,
School: out.School, School: out.School,
Major: out.Major, Major: out.Major,
Industrys: out.GetIndustryAttribute(), Industrys: out.GetIndustryAttribute(),
Keywords: out.GetKeywordAttribute(), Keywords: out.GetKeywordAttribute(),
PatentTitles: strings.Split(out.PatentTitle, "&&"), PatentTitle: strings.Split(out.PatentTitle, "&&"),
}, },
Researchs: out.GetResearchAttribute(), Researchs: out.GetResearchAttribute(),
Introduce: out.Introduce, Introduce: out.Introduce,

View File

@ -21,20 +21,22 @@ type ExpertHandle func(session *session.Enterprise) *Expert
type ( type (
// ExpertBasicInfo 基本信息 // ExpertBasicInfo 基本信息
ExpertBasicInfo struct { ExpertBasicInfo struct {
ID string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
School string `json:"school"` School string `json:"school"`
Image string `json:"image"` Image string `json:"image"`
Major string `json:"major"` Major string `json:"major"`
Industrys []string `json:"industrys"` Industrys []string `json:"industrys"`
Keywords []string `json:"keywords"` Keywords []string `json:"keywords"`
PatentTitles []string `json:"patent_titles"` PatentTitle []string `json:"patent_title"`
} }
// ExpertInstanceInfo 专家信息 // ExpertInstanceInfo 专家信息
ExpertInstanceInfo struct { ExpertInstanceInfo struct {
ExpertBasicInfo ExpertBasicInfo
Researchs []string `json:"researchs"` ResearchName string `json:"research_name"`
Introduce string `json:"introduce"` Researchs []string `json:"researchs"`
Introduce string `json:"introduce"`
Videos []string `json:"videos"`
} }
) )
@ -74,17 +76,18 @@ func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
} }
return &ExpertInstanceInfo{ return &ExpertInstanceInfo{
ExpertBasicInfo: ExpertBasicInfo{ ExpertBasicInfo: ExpertBasicInfo{
ID: out.GetEncodeID(), ID: out.GetEncodeID(),
Name: out.Name, Name: out.Name,
Image: out.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]), Image: out.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]),
School: out.School, School: out.School,
Major: out.Major, Major: out.Major,
Industrys: _industrys, Industrys: _industrys,
Keywords: out.GetKeywordAttribute(), Keywords: out.GetKeywordAttribute(),
PatentTitles: patentTitles, PatentTitle: patentTitles,
}, },
Researchs: out.GetResearchAttribute(), ResearchName: out.ResearchName,
Introduce: out.Introduce, Researchs: out.GetResearchAttribute(),
Introduce: out.Introduce,
}, nil }, nil
} }

View File

@ -69,13 +69,13 @@ func expert(ids []uint64) (interface{}, error) {
v.Image.Image = v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain]) v.Image.Image = v.Image.Analysis(config2.SystemConfig[config2.SysImageDomain])
list = append(list, &ExpertBasicInfo{ list = append(list, &ExpertBasicInfo{
ID: v.GetEncodeID(), ID: v.GetEncodeID(),
Name: v.Name, Name: v.Name,
School: v.School, School: v.School,
Major: v.Major, Major: v.Major,
Industrys: v.GetIndustryAttribute(), Industrys: v.GetIndustryAttribute(),
Keywords: v.GetKeywordAttribute(), Keywords: v.GetKeywordAttribute(),
PatentTitles: strings.Split(v.PatentTitle, "&&"), PatentTitle: strings.Split(v.PatentTitle, "&&"),
}) })
} }
return list, nil return list, nil

View File

@ -58,8 +58,8 @@ func (m *ManageExpert) Detail(limit int, id uint64) (*ManageExpertInfo, error) {
mUserPatent := model.NewUserPatent() mUserPatent := model.NewUserPatent()
db := orm.GetDB().Table(m.TableName()+" AS e"). db := orm.GetDB().Table(m.TableName()+" AS e").
Select("e.id", "e.name", "e.industry", "e.school", "e.major", "e.keyword", "e.research", "e.introduce", Select("e.id", "e.name", "e.industry", "e.image", "e.school", "e.major", "e.keyword", "e.research",
"p.title AS patent_title", "r.name AS research_name"). "e.introduce", "p.title AS patent_title", "r.name AS research_name").
Joins(fmt.Sprintf("LEFT JOIN %s AS e_u ON e.id = e_u.expert_id AND e_u.invalid_status = %d AND e_u.is_deleted = %d", Joins(fmt.Sprintf("LEFT JOIN %s AS e_u ON e.id = e_u.expert_id AND e_u.invalid_status = %d AND e_u.is_deleted = %d",
model.NewUserExpert().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)). model.NewUserExpert().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
Joins(fmt.Sprintf(`LEFT JOIN (SELECT u.uid, SUBSTRING_INDEX(GROUP_CONCAT(p.kind, '$$', p.title ORDER BY p.id DESC SEPARATOR '&&'), '&&', %d) AS title Joins(fmt.Sprintf(`LEFT JOIN (SELECT u.uid, SUBSTRING_INDEX(GROUP_CONCAT(p.kind, '$$', p.title ORDER BY p.id DESC SEPARATOR '&&'), '&&', %d) AS title

View File

@ -36,6 +36,9 @@ type Image struct {
} }
func (m *Image) Analysis(domain string) string { func (m *Image) Analysis(domain string) string {
if m.Image == "" {
return ""
}
return domain + m.Image return domain + m.Image
} }