From 0d0ad90e1f861e663099741d02c85dd8cb9cb48a Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 25 Oct 2023 17:05:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B3=BB=E7=BB=9F=E5=8F=AF=E6=9A=B4?= =?UTF-8?q?=E9=9C=B2=E7=9A=84=E9=85=8D=E7=BD=AE=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/common/controller/common.go | 19 ++++++++- src/modules/common/service/commont.go | 7 ++++ src/modules/common/service/commont.impl.go | 45 ++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/modules/common/service/commont.go create mode 100644 src/modules/common/service/commont.impl.go diff --git a/src/modules/common/controller/common.go b/src/modules/common/controller/common.go index b3c2708b..0e677f83 100644 --- a/src/modules/common/controller/common.go +++ b/src/modules/common/controller/common.go @@ -1,16 +1,23 @@ package controller import ( + "ems.agt/src/framework/vo/result" + commonService "ems.agt/src/modules/common/service" "github.com/gin-gonic/gin" ) // 实例化控制层 CommontController 结构体 -var NewCommont = &CommontController{} +var NewCommont = &CommontController{ + commontService: commonService.NewCommontImpl, +} // 通用请求 // // PATH / -type CommontController struct{} +type CommontController struct { + // 通用请求服务 + commontService commonService.ICommont +} // 哈希加密 // @@ -18,3 +25,11 @@ type CommontController struct{} func (s *CommontController) Hash(c *gin.Context) { c.String(200, "commont Hash") } + +// 系统可暴露的配置信息 +// +// GET /sysConf +func (s *CommontController) SysConfig(c *gin.Context) { + data := s.commontService.SystemConfigInfo() + c.JSON(200, result.OkData(data)) +} diff --git a/src/modules/common/service/commont.go b/src/modules/common/service/commont.go new file mode 100644 index 00000000..5dc1e658 --- /dev/null +++ b/src/modules/common/service/commont.go @@ -0,0 +1,7 @@ +package service + +// 通用请求 服务层接口 +type ICommont interface { + // SystemConfigInfo 系统配置信息 + SystemConfigInfo() map[string]any +} diff --git a/src/modules/common/service/commont.impl.go b/src/modules/common/service/commont.impl.go new file mode 100644 index 00000000..41972980 --- /dev/null +++ b/src/modules/common/service/commont.impl.go @@ -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 +}