41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"github.com/kataras/iris/v12"
|
|
"github.com/kataras/iris/v12/context"
|
|
"gorm.io/gorm/clause"
|
|
"pet-house.com/business/models"
|
|
"pet-house.com/core/server/database"
|
|
"pet-house.com/core/server/web/web_iris"
|
|
)
|
|
|
|
type SystemInfoResponse struct {
|
|
SystemInfos []models.SystemConfig `json:"systemInfos"`
|
|
}
|
|
|
|
// 获取系统配置
|
|
func (p DefParty) systemConfigInfo() web_iris.Party {
|
|
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
|
index.Post(System+"/systemConfigInfo", func(ctx *context.Context) {
|
|
var systemConfig []models.SystemConfig
|
|
database.Instance().Model(&models.SystemConfig{}).Where("config_type > 0").Find(&systemConfig)
|
|
Success(ctx, nil, SystemInfoResponse{systemConfig})
|
|
})
|
|
}}
|
|
}
|
|
|
|
type SystemBannersResponse struct {
|
|
Banners []models.SystemConfig `json:"banners"`
|
|
}
|
|
|
|
// 获取系统banner
|
|
func (p DefParty) systemBanners() web_iris.Party {
|
|
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
|
|
index.Post(System+"/systemBanners", func(ctx *context.Context) {
|
|
var systemConfig []models.SystemConfig
|
|
database.Instance().Model(&models.SystemConfig{}).Where("config_type = 0").Order(clause.OrderByColumn{Column: clause.Column{Name: "sort"}, Desc: true}).Find(&systemConfig)
|
|
Success(ctx, nil, SystemBannersResponse{systemConfig})
|
|
})
|
|
}}
|
|
}
|