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}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user