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,6 +22,8 @@ type (
ResearchInstance struct { ResearchInstance struct {
ID string `json:"id"` ID string `json:"id"`
*model.ManageResearchInfo *model.ManageResearchInfo
Industrys []string `json:"industrys"`
Researchs []string `json:"researchs"`
Address string `json:"address"` Address string `json:"address"`
Area string `json:"area"` Area string `json:"area"`
} }
@ -69,8 +71,18 @@ 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,
Industrys: _industrys,
Researchs: mManageResearch.GetResearchAttribute(),
Address: v.FormatBasic(), Area: (&model2.Area{ Address: v.FormatBasic(), Area: (&model2.Area{
Province: v.TenantProvince, Province: v.TenantProvince,
City: v.TenantCity, City: v.TenantCity,
@ -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

@ -33,7 +33,7 @@ type (
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 {
@ -199,7 +199,7 @@ func (c *Expert) Match(title string, industrys, keywords []string) (*controller.
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
@ -221,7 +221,7 @@ func (c *Expert) Detail(id uint64) (*ExpertDetailInfo, error) {
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

@ -28,13 +28,15 @@ type (
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
ResearchName string `json:"research_name"`
Researchs []string `json:"researchs"` Researchs []string `json:"researchs"`
Introduce string `json:"introduce"` Introduce string `json:"introduce"`
Videos []string `json:"videos"`
} }
) )
@ -81,8 +83,9 @@ func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
Major: out.Major, Major: out.Major,
Industrys: _industrys, Industrys: _industrys,
Keywords: out.GetKeywordAttribute(), Keywords: out.GetKeywordAttribute(),
PatentTitles: patentTitles, PatentTitle: patentTitles,
}, },
ResearchName: out.ResearchName,
Researchs: out.GetResearchAttribute(), Researchs: out.GetResearchAttribute(),
Introduce: out.Introduce, Introduce: out.Introduce,
}, nil }, nil

View File

@ -75,7 +75,7 @@ func expert(ids []uint64) (interface{}, error) {
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
} }