From 6bfdef3ea56c4bef0482b6da0469d3d646fb4efb Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 20 Dec 2024 16:35:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20common=E5=8E=BB=E9=99=A4Impi=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/common/controller/common.go | 14 ++-- src/modules/common/service/commont.go | 82 ++++++++++++++++++++-- src/modules/common/service/commont.impl.go | 81 --------------------- src/modules/ws/processor/cdr_connect.go | 12 ++-- 4 files changed, 88 insertions(+), 101 deletions(-) delete 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 5e2ec70b..7a871dfa 100644 --- a/src/modules/common/controller/common.go +++ b/src/modules/common/controller/common.go @@ -10,15 +10,14 @@ import ( // 实例化控制层 CommontController 结构体 var NewCommont = &CommontController{ - commontService: commonService.NewCommontImpl, + commontService: commonService.NewCommont, } // 通用请求 // // PATH / type CommontController struct { - // 通用请求服务 - commontService commonService.ICommont + commontService *commonService.Commont // 通用请求服务 } // 哈希加密 @@ -36,17 +35,12 @@ func (s *CommontController) I18n(c *gin.Context) { i18nLang := i18n.TKey(language, "i18n") hello := i18n.TKey(language, "hello") - ivs := i18n.TTemplate(language, "errorFields", nil) - errorFields := i18n.TTemplate(language, "errorFields", map[string]any{ - "num": 1000, - "hello": "你好", - "h2o2": false, - "fileName": " ====", + errorFields := i18n.TTemplate(language, "dictData.errLabelExists", map[string]any{ + "name": " ====", }) c.JSON(200, map[string]any{ "lang": language, "i18nLang": i18nLang, - "ivs": ivs, "hello": hello, "errorFields": errorFields, }) diff --git a/src/modules/common/service/commont.go b/src/modules/common/service/commont.go index e8be8db3..23789077 100644 --- a/src/modules/common/service/commont.go +++ b/src/modules/common/service/commont.go @@ -1,7 +1,81 @@ package service -// 通用请求 服务层接口 -type ICommont interface { - // SystemConfigInfo 系统配置信息 - SystemConfigInfo() map[string]string +import ( + "fmt" + + "be.ems/lib/global" + "be.ems/src/framework/config" + "be.ems/src/framework/constants/common" + "be.ems/src/framework/utils/machine" + systemService "be.ems/src/modules/system/service" +) + +// 实例化服务层 Commont 结构体 +var NewCommont = &Commont{ + sysUserService: systemService.NewSysUserImpl, + sysConfigService: systemService.NewSysConfigImpl, +} + +// 通用请求 服务层处理 +type Commont struct { + // 用户信息服务 + sysUserService systemService.ISysUser + // 参数配置服务 + sysConfigService systemService.ISysConfig +} + +// SystemConfigInfo 系统配置信息 +func (s *Commont) SystemConfigInfo() map[string]string { + infoMap := map[string]string{} + // 获取打包注入的全局变量信息 + infoMap["version"] = global.Version + infoMap["buildTime"] = global.BuildTime + // 系统首次使用标记 + launchInfo := machine.LaunchInfo + if launchInfo != nil { + if v, ok := launchInfo[common.LAUNCH_BOOTLOADER]; ok { + infoMap[common.LAUNCH_BOOTLOADER] = fmt.Sprint(v) + } else { + infoMap[common.LAUNCH_BOOTLOADER] = "true" + } + } else { + infoMap[common.LAUNCH_BOOTLOADER] = "true" + } + // 用户登录认证 + infoMap["loginAuth"] = fmt.Sprint(config.Get("user.loginAuth")) + // 序列号 + infoMap["serialNum"] = fmt.Sprint(config.Get("omc.sn")) + // 获取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 + // 系统设置-官网网址 + officialUrl := s.sysConfigService.SelectConfigValueByKey("sys.officialUrl") + infoMap["officialUrl"] = officialUrl + // 系统设置-系统使用文档 + helpDoc := s.sysConfigService.SelectConfigValueByKey("sys.helpDoc") + infoMap["helpDoc"] = helpDoc + // 国际化切换 + i18nOpen := s.sysConfigService.SelectConfigValueByKey("sys.i18n.open") + infoMap["i18nOpen"] = i18nOpen + // 国际化默认语言 + i18nDefault := s.sysConfigService.SelectConfigValueByKey("sys.i18n.default") + infoMap["i18nDefault"] = i18nDefault + return infoMap } diff --git a/src/modules/common/service/commont.impl.go b/src/modules/common/service/commont.impl.go deleted file mode 100644 index b84b4d49..00000000 --- a/src/modules/common/service/commont.impl.go +++ /dev/null @@ -1,81 +0,0 @@ -package service - -import ( - "fmt" - - "be.ems/lib/global" - "be.ems/src/framework/config" - "be.ems/src/framework/constants/common" - "be.ems/src/framework/utils/machine" - systemService "be.ems/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]string { - infoMap := map[string]string{} - // 获取打包注入的全局变量信息 - infoMap["version"] = global.Version - infoMap["buildTime"] = global.BuildTime - // 系统首次使用标记 - launchInfo := machine.LaunchInfo - if launchInfo != nil { - if v, ok := launchInfo[common.LAUNCH_BOOTLOADER]; ok { - infoMap[common.LAUNCH_BOOTLOADER] = fmt.Sprint(v) - } else { - infoMap[common.LAUNCH_BOOTLOADER] = "true" - } - } else { - infoMap[common.LAUNCH_BOOTLOADER] = "true" - } - // 用户登录认证 - infoMap["loginAuth"] = fmt.Sprint(config.Get("user.loginAuth")) - // 序列号 - infoMap["serialNum"] = fmt.Sprint(config.Get("omc.sn")) - // 获取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 - // 系统设置-官网网址 - officialUrl := s.sysConfigService.SelectConfigValueByKey("sys.officialUrl") - infoMap["officialUrl"] = officialUrl - // 系统设置-系统使用文档 - helpDoc := s.sysConfigService.SelectConfigValueByKey("sys.helpDoc") - infoMap["helpDoc"] = helpDoc - // 国际化切换 - i18nOpen := s.sysConfigService.SelectConfigValueByKey("sys.i18n.open") - infoMap["i18nOpen"] = i18nOpen - // 国际化默认语言 - i18nDefault := s.sysConfigService.SelectConfigValueByKey("sys.i18n.default") - infoMap["i18nDefault"] = i18nDefault - return infoMap -} diff --git a/src/modules/ws/processor/cdr_connect.go b/src/modules/ws/processor/cdr_connect.go index 5cfc7776..35d7846a 100644 --- a/src/modules/ws/processor/cdr_connect.go +++ b/src/modules/ws/processor/cdr_connect.go @@ -28,10 +28,10 @@ func GetCDRConnectByIMS(requestID string, data any) ([]byte, error) { } query.RmUID = neInfo.RmUID - dataMap := neDataService.NewCDREventIMS.SelectPage(query) + rows, total := neDataService.NewCDREventIMS.SelectPage(query) resultByte, err := json.Marshal(result.Ok(map[string]any{ "requestId": requestID, - "data": dataMap, + "data": map[string]any{"rows": rows, "total": total}, })) return resultByte, err } @@ -53,10 +53,10 @@ func GetCDRConnectBySMF(requestID string, data any) ([]byte, error) { } query.RmUID = neInfo.RmUID - dataMap := neDataService.NewCDREventSMF.SelectPage(query) + rows, total := neDataService.NewCDREventSMF.SelectPage(query) resultByte, err := json.Marshal(result.Ok(map[string]any{ "requestId": requestID, - "data": dataMap, + "data": map[string]any{"rows": rows, "total": total}, })) return resultByte, err } @@ -78,10 +78,10 @@ func GetCDRConnectBySMSC(requestID string, data any) ([]byte, error) { } query.RmUID = neInfo.RmUID - dataMap := neDataService.NewCDREventSMSC.SelectPage(query) + rows, total := neDataService.NewCDREventSMSC.SelectPage(query) resultByte, err := json.Marshal(result.Ok(map[string]any{ "requestId": requestID, - "data": dataMap, + "data": map[string]any{"rows": rows, "total": total}, })) return resultByte, err }