Files
be.ems/src/modules/common/controller/sys_conf.go

101 lines
3.3 KiB
Go

package controller
import (
"fmt"
"be.ems/src/framework/config"
"be.ems/src/framework/constants"
"be.ems/src/framework/i18n"
"be.ems/src/framework/reqctx"
"be.ems/src/framework/resp"
"be.ems/src/framework/utils/machine"
systemService "be.ems/src/modules/system/service"
"github.com/gin-gonic/gin"
)
// 实例化控制层 SysConfController 结构体
var NewSysConf = &SysConfController{
sysUserService: systemService.NewSysUser,
sysConfigService: systemService.NewSysConfig,
}
// 系统的配置信息
//
// PATH /sys-conf
type SysConfController struct {
sysUserService *systemService.SysUser // 用户信息服务
sysConfigService *systemService.SysConfig // 参数配置服务
}
// 系统的配置信息
//
// GET /
//
// @Tags common
// @Accept json
// @Produce json
// @Success 200 {object} object "Response Results"
// @Summary Configuration information for the system
// @Description Configuration information for the system
// @Router /sys-conf [get]
func (s SysConfController) Handler(c *gin.Context) {
language := reqctx.AcceptLanguage(c)
infoMap := map[string]string{}
// 获取打包注入的全局变量信息
infoMap["version"] = config.Version
// 系统首次使用标记
launchInfo := machine.LaunchInfo
if launchInfo != nil {
if v, ok := launchInfo[constants.LAUNCH_BOOTLOADER]; ok {
infoMap[constants.LAUNCH_BOOTLOADER] = fmt.Sprint(v)
} else {
infoMap[constants.LAUNCH_BOOTLOADER] = "true"
}
} else {
infoMap[constants.LAUNCH_BOOTLOADER] = "true"
}
// 服务类型
infoMap["serverType"] = fmt.Sprint(config.Get("serverType"))
// 用户登录认证
infoMap["loginAuth"] = fmt.Sprint(config.Get("serverLoginAuth"))
// 用户接口加密
infoMap["cryptoApi"] = fmt.Sprint(config.Get("serverCryptoApi"))
// 序列号
infoMap["serialNum"] = fmt.Sprint(config.Get("omc.sn"))
// 获取LOGO类型
logoType := s.sysConfigService.FindValueByKey("sys.logo.type")
infoMap["logoType"] = logoType
// 获取LOGO文件
filePathIcon := s.sysConfigService.FindValueByKey("sys.logo.filePathIcon")
infoMap["filePathIcon"] = filePathIcon
filePathBrand := s.sysConfigService.FindValueByKey("sys.logo.filePathBrand")
infoMap["filePathBrand"] = filePathBrand
// 获取系统名称
title := s.sysConfigService.FindValueByKey("sys.title")
infoMap["title"] = i18n.TKey(language, title)
// 获取版权声明
copyright := s.sysConfigService.FindValueByKey("sys.copyright")
infoMap["copyright"] = i18n.TKey(language, copyright)
// 获取是否开启用户注册功能
registerUser := s.sysConfigService.FindValueByKey("sys.account.registerUser")
infoMap["registerUser"] = registerUser
// 获取登录界面背景
loginBackground := s.sysConfigService.FindValueByKey("sys.loginBackground")
infoMap["loginBackground"] = loginBackground
// 系统设置-官网网址
officialUrl := s.sysConfigService.FindValueByKey("sys.officialUrl")
infoMap["officialUrl"] = officialUrl
// 系统设置-系统使用文档
helpDoc := s.sysConfigService.FindValueByKey("sys.helpDoc")
infoMap["helpDoc"] = helpDoc
// 国际化切换
i18nOpen := s.sysConfigService.FindValueByKey("sys.i18n.open")
infoMap["i18nOpen"] = i18nOpen
// 国际化默认语言
i18nDefault := s.sysConfigService.FindValueByKey("sys.i18n.default")
infoMap["i18nDefault"] = i18nDefault
c.JSON(200, resp.OkData(infoMap))
}