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
Name string `json:"name" form:"name" binding:"required"`
Code string `json:"code" form:"code"`
Mobile string `json:"mobile" form:"mobile" binding:"required"`
Mobile string `json:"mobile" form:"mobile"`
config.Area
Industrys []string `json:"industrys" form:"industrys"`
Keywords []string `json:"keywords" form:"keywords"`

View File

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

View File

@ -4,6 +4,7 @@ import (
"SciencesServer/app/common/model"
"SciencesServer/serve/orm"
"fmt"
"time"
)
type ManageResearch struct {
@ -16,12 +17,13 @@ type (
model.Model
Name string `json:"name"`
Code string `json:"code"`
Industry string `json:"industry"`
Research string `json:"research"`
Industry string `json:"-"`
Research string `json:"-"`
ExamineStatus string `json:"examine_status"`
model.Area
TenantProvince string `json:"-"`
TenantCity string `json:"-"`
CreatedAt time.Time `json:"created_at"`
}
// ManageResearchDetail 详细信息
ManageResearchDetail struct {
@ -31,13 +33,13 @@ type (
)
// 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").
Select("r.*").
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON r.tenant_id = t.id", model.NewSysTenant().TableName())).
Where("r.id = ?", id)
out := new(ManageResearchDetail)
out := new(model.ManageResearch)
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) {
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",
"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())).
Where("r.is_deleted = ?", model.DeleteStatusForNot)

View File

@ -33,7 +33,7 @@ type (
Major string `json:"major"`
Industrys []string `json:"industrys"`
Keywords []string `json:"keywords"`
PatentTitles []string `json:"patent_titles"`
PatentTitle []string `json:"patent_title"`
}
// ExpertDetailInfo 专家详细信息
ExpertDetailInfo struct {
@ -199,7 +199,7 @@ func (c *Expert) Match(title string, industrys, keywords []string) (*controller.
Major: v.Major,
Industrys: v.GetIndustryAttribute(),
Keywords: v.GetKeywordAttribute(),
PatentTitles: strings.Split(v.PatentTitle, "&&"),
PatentTitle: strings.Split(v.PatentTitle, "&&"),
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
@ -221,7 +221,7 @@ func (c *Expert) Detail(id uint64) (*ExpertDetailInfo, error) {
Major: out.Major,
Industrys: out.GetIndustryAttribute(),
Keywords: out.GetKeywordAttribute(),
PatentTitles: strings.Split(out.PatentTitle, "&&"),
PatentTitle: strings.Split(out.PatentTitle, "&&"),
},
Researchs: out.GetResearchAttribute(),
Introduce: out.Introduce,

View File

@ -28,13 +28,15 @@ type (
Major string `json:"major"`
Industrys []string `json:"industrys"`
Keywords []string `json:"keywords"`
PatentTitles []string `json:"patent_titles"`
PatentTitle []string `json:"patent_title"`
}
// ExpertInstanceInfo 专家信息
ExpertInstanceInfo struct {
ExpertBasicInfo
ResearchName string `json:"research_name"`
Researchs []string `json:"researchs"`
Introduce string `json:"introduce"`
Videos []string `json:"videos"`
}
)
@ -81,8 +83,9 @@ func (c *Expert) Instance(id uint64) (*ExpertInstanceInfo, error) {
Major: out.Major,
Industrys: _industrys,
Keywords: out.GetKeywordAttribute(),
PatentTitles: patentTitles,
PatentTitle: patentTitles,
},
ResearchName: out.ResearchName,
Researchs: out.GetResearchAttribute(),
Introduce: out.Introduce,
}, nil

View File

@ -75,7 +75,7 @@ func expert(ids []uint64) (interface{}, error) {
Major: v.Major,
Industrys: v.GetIndustryAttribute(),
Keywords: v.GetKeywordAttribute(),
PatentTitles: strings.Split(v.PatentTitle, "&&"),
PatentTitle: strings.Split(v.PatentTitle, "&&"),
})
}
return list, nil

View File

@ -58,8 +58,8 @@ func (m *ManageExpert) Detail(limit int, id uint64) (*ManageExpertInfo, error) {
mUserPatent := model.NewUserPatent()
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",
"p.title AS patent_title", "r.name AS research_name").
Select("e.id", "e.name", "e.industry", "e.image", "e.school", "e.major", "e.keyword", "e.research",
"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",
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

View File

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