feat: 系统可暴露的配置信息
This commit is contained in:
@@ -1,16 +1,23 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"ems.agt/src/framework/vo/result"
|
||||||
|
commonService "ems.agt/src/modules/common/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 实例化控制层 CommontController 结构体
|
// 实例化控制层 CommontController 结构体
|
||||||
var NewCommont = &CommontController{}
|
var NewCommont = &CommontController{
|
||||||
|
commontService: commonService.NewCommontImpl,
|
||||||
|
}
|
||||||
|
|
||||||
// 通用请求
|
// 通用请求
|
||||||
//
|
//
|
||||||
// PATH /
|
// PATH /
|
||||||
type CommontController struct{}
|
type CommontController struct {
|
||||||
|
// 通用请求服务
|
||||||
|
commontService commonService.ICommont
|
||||||
|
}
|
||||||
|
|
||||||
// 哈希加密
|
// 哈希加密
|
||||||
//
|
//
|
||||||
@@ -18,3 +25,11 @@ type CommontController struct{}
|
|||||||
func (s *CommontController) Hash(c *gin.Context) {
|
func (s *CommontController) Hash(c *gin.Context) {
|
||||||
c.String(200, "commont Hash")
|
c.String(200, "commont Hash")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 系统可暴露的配置信息
|
||||||
|
//
|
||||||
|
// GET /sysConf
|
||||||
|
func (s *CommontController) SysConfig(c *gin.Context) {
|
||||||
|
data := s.commontService.SystemConfigInfo()
|
||||||
|
c.JSON(200, result.OkData(data))
|
||||||
|
}
|
||||||
|
|||||||
7
src/modules/common/service/commont.go
Normal file
7
src/modules/common/service/commont.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
// 通用请求 服务层接口
|
||||||
|
type ICommont interface {
|
||||||
|
// SystemConfigInfo 系统配置信息
|
||||||
|
SystemConfigInfo() map[string]any
|
||||||
|
}
|
||||||
45
src/modules/common/service/commont.impl.go
Normal file
45
src/modules/common/service/commont.impl.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
systemService "ems.agt/src/modules/system/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 实例化服务层 CommontImpl 结构体
|
||||||
|
var NewCommontImpl = &CommontImpl{
|
||||||
|
sysUserService: systemService.NewSysUserImpl,
|
||||||
|
sysConfigService: systemService.NewSysConfigImpl,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用请求 服务层处理
|
||||||
|
type CommontImpl struct {
|
||||||
|
// 用户信息服务
|
||||||
|
sysUserService systemService.ISysUser
|
||||||
|
// 参数配置服务
|
||||||
|
sysConfigService systemService.ISysConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
// SystemConfigInfo 系统配置信息
|
||||||
|
func (s *CommontImpl) SystemConfigInfo() map[string]any {
|
||||||
|
infoMap := map[string]any{}
|
||||||
|
// 获取LOGO类型
|
||||||
|
logoType := s.sysConfigService.SelectConfigValueByKey("sys.logo.type")
|
||||||
|
infoMap["logoType"] = logoType
|
||||||
|
// 获取LOGO文件
|
||||||
|
filePathIcon := s.sysConfigService.SelectConfigValueByKey("sys.logo.filePathIcon")
|
||||||
|
infoMap["filePathIcon"] = filePathIcon
|
||||||
|
filePathBrand := s.sysConfigService.SelectConfigValueByKey("sys.logo.filePathBrand")
|
||||||
|
infoMap["filePathBrand"] = filePathBrand
|
||||||
|
// 获取系统名称
|
||||||
|
title := s.sysConfigService.SelectConfigValueByKey("sys.title")
|
||||||
|
infoMap["title"] = title
|
||||||
|
// 获取版权声明
|
||||||
|
copyright := s.sysConfigService.SelectConfigValueByKey("sys.copyright")
|
||||||
|
infoMap["copyright"] = copyright
|
||||||
|
// 获取是否开启用户注册功能
|
||||||
|
registerUser := s.sysConfigService.SelectConfigValueByKey("sys.account.registerUser")
|
||||||
|
infoMap["registerUser"] = registerUser
|
||||||
|
// 获取登录界面背景
|
||||||
|
loginBackground := s.sysConfigService.SelectConfigValueByKey("sys.loginBackground")
|
||||||
|
infoMap["loginBackground"] = loginBackground
|
||||||
|
return infoMap
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user