2021-12-16 13:22:14 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"SciencesServer/app/common/model"
|
|
|
|
"SciencesServer/serve/orm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SysNavigation struct {
|
|
|
|
*model.SysNavigation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Navigation 导航信息
|
2022-01-14 09:56:55 +08:00
|
|
|
func (m *SysNavigation) Navigation(where ...*model.ModelWhere) ([]*model.SysNavigation, error) {
|
2021-12-16 13:22:14 +08:00
|
|
|
out := make([]*model.SysNavigation, 0)
|
|
|
|
|
2022-01-14 09:56:55 +08:00
|
|
|
db := orm.GetDB().Table(m.TableName()).
|
2021-12-16 13:22:14 +08:00
|
|
|
Select("id", "parent_id", "title", "link").
|
|
|
|
Where("status = ?", model.SysNavigationStatusForShow).
|
2022-01-14 09:56:55 +08:00
|
|
|
Where("is_deleted = ?", model.DeleteStatusForNot)
|
|
|
|
|
|
|
|
if len(where) > 0 {
|
|
|
|
for _, v := range where {
|
|
|
|
db = db.Where(v.Condition, v.Value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err := db.Order("sort " + model.OrderModeToDesc).Scan(&out).Error
|
2021-12-16 13:22:14 +08:00
|
|
|
|
|
|
|
return out, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSysNavigation() *SysNavigation {
|
|
|
|
return &SysNavigation{model.NewSysNavigation()}
|
|
|
|
}
|