feat:完善项目
This commit is contained in:
40
app/api/website/controller/sys/banner.go
Normal file
40
app/api/website/controller/sys/banner.go
Normal file
@ -0,0 +1,40 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
"SciencesServer/config"
|
||||
)
|
||||
|
||||
type Banner struct {
|
||||
tenantID uint64
|
||||
}
|
||||
|
||||
type BannerHandle func(tenantID uint64) *Banner
|
||||
|
||||
type BannerInfo struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
IsMultiple int `json:"is_multiple"`
|
||||
Images string `json:"images"`
|
||||
}
|
||||
|
||||
func (c *Banner) Instance(key string) (*BannerInfo, error) {
|
||||
mSysBanner := model.NewSysBanner()
|
||||
if err := mSysBanner.Get(c.tenantID, map[string]interface{}{
|
||||
"key": key, "local": key,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &BannerInfo{
|
||||
ID: mSysBanner.GetEncodeID(),
|
||||
Title: mSysBanner.Title,
|
||||
IsMultiple: mSysBanner.IsMultiple,
|
||||
Images: mSysBanner.Images.AnalysisSlice(config.SettingInfo.Domain),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewBanner() BannerHandle {
|
||||
return func(tenantID uint64) *Banner {
|
||||
return &Banner{tenantID: tenantID}
|
||||
}
|
||||
}
|
58
app/api/website/controller/sys/platform.go
Normal file
58
app/api/website/controller/sys/platform.go
Normal file
@ -0,0 +1,58 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/website/model"
|
||||
"SciencesServer/app/basic/config"
|
||||
config2 "SciencesServer/config"
|
||||
)
|
||||
|
||||
type Platform struct{}
|
||||
|
||||
type PlatformHandle func() *Platform
|
||||
|
||||
type PlatformInfo struct {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Domain string `json:"domain"`
|
||||
Children []*PlatformInfo `json:"children"`
|
||||
}
|
||||
|
||||
// Instance 平台信息
|
||||
func (c *Platform) Instance() (map[string]*PlatformInfo, error) {
|
||||
mSysPlatform := model.NewSysTenant()
|
||||
out, err := mSysPlatform.Tenant()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := make(map[string]*PlatformInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
if _, has := ret[v.Province]; !has {
|
||||
ret[v.Province] = &PlatformInfo{
|
||||
Name: config.MemoryForAreaInfo[config2.DefaultChinaAreaCode][v.Province],
|
||||
Code: v.Province,
|
||||
Domain: "",
|
||||
Children: []*PlatformInfo{&PlatformInfo{
|
||||
Name: config.MemoryForAreaInfo[v.Province][v.City],
|
||||
Code: v.City,
|
||||
Domain: v.Domain,
|
||||
Children: nil,
|
||||
}},
|
||||
}
|
||||
continue
|
||||
}
|
||||
ret[v.Province].Children = append(ret[v.Province].Children, &PlatformInfo{
|
||||
Name: config.MemoryForAreaInfo[v.Province][v.City],
|
||||
Domain: v.Domain,
|
||||
Children: nil,
|
||||
})
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func NewPlatform() PlatformHandle {
|
||||
return func() *Platform {
|
||||
return &Platform{}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user