feat:完善项目信息

This commit is contained in:
henry
2022-01-19 16:03:47 +08:00
parent 417d7961ec
commit 6adf1381d0
9 changed files with 271 additions and 25 deletions

View File

@ -11,11 +11,6 @@ type ManageExpert struct {
}
type (
// ManageExpertBasic 专家基本信息
ManageExpertBasic struct {
*model.ManageExpert
model.Area
}
// ManageExpertInfo 专家信息
ManageExpertInfo struct {
*model.ManageExpert
@ -23,17 +18,24 @@ type (
ResearchName string `json:"research_name"`
LaboratoryName string `json:"laboratory_name"`
model.Area
TenantProvince string `json:"-"`
TenantCity string `json:"-"`
}
// ManageExpertDetail 专家信息
ManageExpertDetail struct {
*model.ManageExpert
model.Area
}
)
// Expert 专家信息
func (m *ManageExpert) Expert(id uint64) (*ManageExpertBasic, error) {
func (m *ManageExpert) Expert(id uint64) (*ManageExpertDetail, error) {
db := orm.GetDB().Table(m.TableName()+" AS e").
Select("e.*", "t.province", "t.city").
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON e.tenant_id = t.id", model.NewSysTenant().TableName())).
Where("e.id = ?", id)
out := new(ManageExpertBasic)
out := new(ManageExpertDetail)
err := db.Scan(out).Error
@ -44,7 +46,8 @@ func (m *ManageExpert) Expert(id uint64) (*ManageExpertBasic, error) {
func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageExpertInfo, error) {
db := orm.GetDB().Table(m.TableName()+" AS e").
Select("e.id", "e.name", "e.industry", "r.name AS research_name", "l.name AS laboratory_name",
"t.province", "t.city", "e.address", "e.created_at").
"e.province", "e.city", "e.address", "e.created_at",
"t.province AS tenant_province", "t.city AS tenant_city").
Joins(fmt.Sprintf("LEFT JOIN %s AS r ON e.research_id = r.id", model.NewManageResearch().TableName())).
Joins(fmt.Sprintf("LEFT JOIN %s AS l ON e.laboratory_id = l.id", model.NewManageLaboratory().TableName())).
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON e.tenant_id = t.id", model.NewSysTenant().TableName())).