init
This commit is contained in:
@ -1,11 +1,17 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
)
|
||||
|
||||
type ManageCompany struct {
|
||||
*model.ManageCompany
|
||||
}
|
||||
|
||||
func (m *ManageCompany) Companys(page, pageSize int, count *int64, where ...*model.ModelWhere) {
|
||||
|
||||
}
|
||||
|
||||
func NewManageCompany() *ManageCompany {
|
||||
return &ManageCompany{}
|
||||
}
|
||||
|
@ -1,11 +1,50 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ManageExpert struct {
|
||||
*model.ManageExpert
|
||||
}
|
||||
|
||||
type ManageExpertInfo struct {
|
||||
*model.ManageExpert
|
||||
Name string `json:"name"`
|
||||
ResearchName string `json:"research_name"`
|
||||
LaboratoryName string `json:"laboratory_name"`
|
||||
}
|
||||
|
||||
// Experts 专家信息
|
||||
func (m *ManageExpert) Experts(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageExpertInfo, error) {
|
||||
mUserInstance := model.NewUserInstance()
|
||||
mSysTenant := model.NewSysTenant()
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS e").
|
||||
Select("e.*", "u.name", "l.name AS laboratory_name", "r.name AS research_name").
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON e.uid = u.uuid", mUserInstance.TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS l ON e.tenant_id = l.id", mSysTenant.TableName())).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS r ON l.parent_id = r.id", mSysTenant.TableName())).
|
||||
Where("")
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ManageExpertInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("e.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewManageExpert() *ManageExpert {
|
||||
return &ManageExpert{model.NewManageExpert()}
|
||||
}
|
||||
|
Reference in New Issue
Block a user