feat:完善项目管理
This commit is contained in:
@ -1,11 +1,17 @@
|
||||
package controller
|
||||
|
||||
import "SciencesServer/app/service"
|
||||
import (
|
||||
"SciencesServer/app/service"
|
||||
)
|
||||
|
||||
type Config struct{ *service.Session }
|
||||
|
||||
type ConfigHandle func(session *service.Session) *Config
|
||||
|
||||
func (c *Config) Platform() {
|
||||
|
||||
}
|
||||
|
||||
func NewConfig() ConfigHandle {
|
||||
return func(session *service.Session) *Config {
|
||||
return &Config{Session: session}
|
||||
|
49
app/api/website/controller/navigation.go
Normal file
49
app/api/website/controller/navigation.go
Normal file
@ -0,0 +1,49 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
)
|
||||
|
||||
type Navigation struct{}
|
||||
|
||||
type NavigationHandle func() *Navigation
|
||||
|
||||
type NavigationInfo struct {
|
||||
Title string `json:"title"`
|
||||
Link string `json:"link"`
|
||||
Children []*NavigationInfo `json:"children"`
|
||||
}
|
||||
|
||||
// tree 树状
|
||||
func (c *Navigation) tree(src []*model2.SysNavigation, parentID uint64) []*NavigationInfo {
|
||||
out := make([]*NavigationInfo, 0)
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
out = append(out, &NavigationInfo{
|
||||
Title: v.Title,
|
||||
Link: v.Link,
|
||||
Children: c.tree(src, v.ID),
|
||||
})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Instance 导航栏信息
|
||||
func (c *Navigation) Instance() ([]*NavigationInfo, error) {
|
||||
mSysNavigation := model.NewSysNavigation()
|
||||
out, err := mSysNavigation.Navigation()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.tree(out, 0), nil
|
||||
}
|
||||
|
||||
func NewNavigation() NavigationHandle {
|
||||
return func() *Navigation {
|
||||
return &Navigation{}
|
||||
}
|
||||
}
|
49
app/api/website/controller/platform.go
Normal file
49
app/api/website/controller/platform.go
Normal file
@ -0,0 +1,49 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
)
|
||||
|
||||
type Platform struct{}
|
||||
|
||||
type PlatformHandle func() *Platform
|
||||
|
||||
type PlatformInfo struct {
|
||||
Title string `json:"title"`
|
||||
Link string `json:"link"`
|
||||
Children []*PlatformInfo `json:"children"`
|
||||
}
|
||||
|
||||
// tree 树状
|
||||
func (c *Platform) tree(src []*model2.SysPlatform, parentID uint64) []*PlatformInfo {
|
||||
out := make([]*PlatformInfo, 0)
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
out = append(out, &PlatformInfo{
|
||||
Title: v.Title,
|
||||
Link: v.Link,
|
||||
Children: c.tree(src, v.ID),
|
||||
})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Instance 平台信息
|
||||
func (c *Platform) Instance() ([]*PlatformInfo, error) {
|
||||
mSysPlatform := model.NewSysPlatform()
|
||||
out, err := mSysPlatform.Platform()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.tree(out, 0), nil
|
||||
}
|
||||
|
||||
func NewPlatform() PlatformHandle {
|
||||
return func() *Platform {
|
||||
return &Platform{}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user