fix: common去除Impi层

This commit is contained in:
TsMask
2024-12-20 16:35:32 +08:00
parent 4c57fe2c85
commit 6bfdef3ea5
4 changed files with 88 additions and 101 deletions

View File

@@ -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,
})

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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
}