marge: 合并11.2版本
This commit is contained in:
1 parent
1bdb13a2ab
commit
7bcb439d57
248 files changed
+18255
-10974
No files matched your search
@@ -11,15 +11,14 @@ import (
|
||||
|
||||
// 实例化控制层 MonitorInfoController 结构体
|
||||
var NewMonitor = &MonitorController{
|
||||
monitorService: service.NewMonitorImpl,
|
||||
monitorService: service.NewMonitor,
|
||||
}
|
||||
|
||||
// 服务器资源监控信息
|
||||
//
|
||||
// PATH /monitor
|
||||
type MonitorController struct {
|
||||
// 服务器系统相关信息服务
|
||||
monitorService service.IMonitor
|
||||
monitorService *service.Monitor // 服务器系统相关信息服务
|
||||
}
|
||||
|
||||
// 资源监控信息加载
|
||||
@@ -28,21 +27,14 @@ type MonitorController struct {
|
||||
func (s *MonitorController) Load(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var querys struct {
|
||||
// 数据类型all/load/cpu/memory/io/network
|
||||
Type string `form:"type" binding:"required,oneof=all load cpu memory io network"`
|
||||
// 开始时间
|
||||
StartTime int64 `form:"startTime" binding:"required"`
|
||||
// 结束时间
|
||||
EndTime int64 `form:"endTime" binding:"required"`
|
||||
// 网元类型
|
||||
NeType string `form:"neType"`
|
||||
// 网元ID
|
||||
NeID string `form:"neId"`
|
||||
// 名称,networ和iok时有效
|
||||
Name string `form:"name"`
|
||||
Type string `form:"type" binding:"required,oneof=all load cpu memory io network"` // 数据类型all/load/cpu/memory/io/network
|
||||
StartTime int64 `form:"startTime" binding:"required"` // 开始时间
|
||||
EndTime int64 `form:"endTime" binding:"required"` // 结束时间
|
||||
NeType string `form:"neType"` // 网元类型
|
||||
NeID string `form:"neId"` // 网元ID
|
||||
Name string `form:"name"` // 名称,networ和io时有效
|
||||
}
|
||||
err := c.ShouldBindQuery(&querys)
|
||||
if err != nil {
|
||||
if err := c.ShouldBindQuery(&querys); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -141,10 +141,8 @@ func (s *SysCacheController) ClearCacheKey(c *gin.Context) {
|
||||
func (s *SysCacheController) ClearCacheSafe(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
caches := []model.SysCache{
|
||||
model.NewSysCacheNames(i18n.TKey(language, "cache.name.user"), cachekey.LOGIN_TOKEN_KEY),
|
||||
model.NewSysCacheNames(i18n.TKey(language, "cache.name.sys_config"), cachekey.SYS_CONFIG_KEY),
|
||||
model.NewSysCacheNames(i18n.TKey(language, "cache.name.sys_dict"), cachekey.SYS_DICT_KEY),
|
||||
model.NewSysCacheNames(i18n.TKey(language, "cache.name.captcha_codes"), cachekey.CAPTCHA_CODE_KEY),
|
||||
model.NewSysCacheNames(i18n.TKey(language, "cache.name.repeat_submit"), cachekey.REPEAT_SUBMIT_KEY),
|
||||
model.NewSysCacheNames(i18n.TKey(language, "cache.name.rate_limit"), cachekey.RATE_LIMIT_KEY),
|
||||
model.NewSysCacheNames(i18n.TKey(language, "cache.name.pwd_err_cnt"), cachekey.PWD_ERR_CNT_KEY),
|
||||
|
||||
@@ -22,18 +22,16 @@ import (
|
||||
|
||||
// 实例化控制层 SysJobLogController 结构体
|
||||
var NewSysJob = &SysJobController{
|
||||
sysJobService: service.NewSysJobImpl,
|
||||
sysDictDataService: systemService.NewSysDictDataImpl,
|
||||
sysJobService: service.NewSysJob,
|
||||
sysDictDataService: systemService.NewSysDictData,
|
||||
}
|
||||
|
||||
// 调度任务信息
|
||||
//
|
||||
// PATH /monitor/job
|
||||
type SysJobController struct {
|
||||
// 调度任务服务
|
||||
sysJobService service.ISysJob
|
||||
// 字典数据服务
|
||||
sysDictDataService systemService.ISysDictData
|
||||
sysJobService *service.SysJob // 调度任务服务
|
||||
sysDictDataService *systemService.SysDictData // 字典数据服务
|
||||
}
|
||||
|
||||
// 调度任务列表
|
||||
|
||||
@@ -21,18 +21,16 @@ import (
|
||||
|
||||
// 实例化控制层 SysJobLogController 结构体
|
||||
var NewSysJobLog = &SysJobLogController{
|
||||
sysJobLogService: service.NewSysJobLogImpl,
|
||||
sysDictDataService: systemService.NewSysDictDataImpl,
|
||||
sysJobLogService: service.NewSysJobLog,
|
||||
sysDictDataService: systemService.NewSysDictData,
|
||||
}
|
||||
|
||||
// 调度任务日志信息
|
||||
//
|
||||
// PATH /monitor/jobLog
|
||||
type SysJobLogController struct {
|
||||
// 调度任务日志服务
|
||||
sysJobLogService service.ISysJobLog
|
||||
// 字典数据服务
|
||||
sysDictDataService systemService.ISysDictData
|
||||
sysJobLogService *service.SysJobLog // 调度任务日志服务
|
||||
sysDictDataService *systemService.SysDictData // 字典数据服务
|
||||
}
|
||||
|
||||
// 调度任务日志列表
|
||||
@@ -44,7 +42,7 @@ func (s *SysJobLogController) List(c *gin.Context) {
|
||||
querys := ctx.QueryMap(c)
|
||||
// 任务ID优先级更高
|
||||
if v, ok := querys["jobId"]; ok && v != nil {
|
||||
jobInfo := service.NewSysJobImpl.SelectJobById(v.(string))
|
||||
jobInfo := service.NewSysJob.SelectJobById(v.(string))
|
||||
querys["jobName"] = jobInfo.JobName
|
||||
querys["jobGroup"] = jobInfo.JobGroup
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"be.ems/src/framework/constants/cachekey"
|
||||
"be.ems/src/framework/constants/roledatascope"
|
||||
"be.ems/src/framework/i18n"
|
||||
"be.ems/src/framework/redis"
|
||||
"be.ems/src/framework/utils/ctx"
|
||||
@@ -20,15 +19,14 @@ import (
|
||||
|
||||
// 实例化控制层 SysUserOnlineController 结构体
|
||||
var NewSysUserOnline = &SysUserOnlineController{
|
||||
sysUserOnlineService: service.NewSysUserOnlineImpl,
|
||||
sysUserOnlineService: service.NewSysUserOnline,
|
||||
}
|
||||
|
||||
// 在线用户监控
|
||||
//
|
||||
// PATH /monitor/online
|
||||
type SysUserOnlineController struct {
|
||||
// 在线用户服务
|
||||
sysUserOnlineService service.ISysUserOnline
|
||||
sysUserOnlineService *service.SysUserOnline // 在线用户服务
|
||||
}
|
||||
|
||||
// 在线用户列表
|
||||
@@ -38,43 +36,6 @@ func (s *SysUserOnlineController) List(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
ipaddr := c.Query("ipaddr")
|
||||
userName := c.Query("userName")
|
||||
data := map[string]any{
|
||||
"total": 0,
|
||||
"rows": []model.SysUserOnline{},
|
||||
}
|
||||
|
||||
// 当前登录用户
|
||||
currentUser, _ := ctx.LoginUser(c)
|
||||
currentRoleKey := ""
|
||||
currentRoleDataScope := ""
|
||||
if len(currentUser.User.Roles) > 0 {
|
||||
role := currentUser.User.Roles[0]
|
||||
currentRoleKey = role.RoleKey
|
||||
currentRoleDataScope = role.DataScope
|
||||
}
|
||||
|
||||
if currentRoleKey == "" {
|
||||
c.JSON(200, result.Ok(data))
|
||||
return
|
||||
}
|
||||
hasRoleDataScope := func(loginUser vo.LoginUser) bool {
|
||||
if currentRoleDataScope == roledatascope.ALL {
|
||||
return true
|
||||
}
|
||||
if currentRoleDataScope == roledatascope.CUSTOM {
|
||||
return false
|
||||
}
|
||||
if currentRoleDataScope == roledatascope.DEPT && loginUser.DeptID == currentUser.DeptID {
|
||||
return true
|
||||
}
|
||||
if currentRoleDataScope == roledatascope.DEPT_AND_CHILD && (strings.Contains(loginUser.User.Dept.Ancestors, currentUser.DeptID) || currentUser.DeptID == loginUser.DeptID) {
|
||||
return true
|
||||
}
|
||||
if currentRoleDataScope == roledatascope.SELF && loginUser.UserID == currentUser.UserID {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 获取所有在线用户key
|
||||
keys, _ := redis.GetKeys("", cachekey.LOGIN_TOKEN_KEY+"*")
|
||||
@@ -106,10 +67,6 @@ func (s *SysUserOnlineController) List(c *gin.Context) {
|
||||
continue
|
||||
}
|
||||
|
||||
if !hasRoleDataScope(loginUser) {
|
||||
continue
|
||||
}
|
||||
|
||||
onlineUser := s.sysUserOnlineService.LoginUserToUserOnline(loginUser)
|
||||
if onlineUser.TokenID != "" {
|
||||
onlineUser.LoginLocation = i18n.TKey(language, onlineUser.LoginLocation)
|
||||
@@ -146,9 +103,10 @@ func (s *SysUserOnlineController) List(c *gin.Context) {
|
||||
return filteredUserOnlines[j].LoginTime > filteredUserOnlines[i].LoginTime
|
||||
})
|
||||
|
||||
data["total"] = len(filteredUserOnlines)
|
||||
data["rows"] = filteredUserOnlines
|
||||
c.JSON(200, result.Ok(data))
|
||||
c.JSON(200, result.Ok(map[string]any{
|
||||
"total": len(filteredUserOnlines),
|
||||
"rows": filteredUserOnlines,
|
||||
}))
|
||||
}
|
||||
|
||||
// 在线用户强制退出
|
||||
|
||||
@@ -9,27 +9,27 @@ import (
|
||||
|
||||
// 实例化控制层 SystemInfoController 结构体
|
||||
var NewSystemInfo = &SystemInfoController{
|
||||
systemInfogService: service.NewSystemInfoImpl,
|
||||
systemInfogService: service.NewSystemInfo,
|
||||
}
|
||||
|
||||
// 服务器监控信息
|
||||
//
|
||||
// PATH /monitor/system-info
|
||||
type SystemInfoController struct {
|
||||
// 服务器系统相关信息服务
|
||||
systemInfogService service.ISystemInfo
|
||||
systemInfogService *service.SystemInfo // 服务器系统相关信息服务
|
||||
}
|
||||
|
||||
// 服务器信息
|
||||
//
|
||||
// GET /
|
||||
func (s *SystemInfoController) Info(c *gin.Context) {
|
||||
c.JSON(200, result.OkData(map[string]any{
|
||||
data := map[string]any{
|
||||
"cpu": s.systemInfogService.CPUInfo(),
|
||||
"memory": s.systemInfogService.MemoryInfo(),
|
||||
"network": s.systemInfogService.NetworkInfo(),
|
||||
"time": s.systemInfogService.TimeInfo(),
|
||||
"system": s.systemInfogService.SystemInfo(),
|
||||
"disk": s.systemInfogService.DiskInfo(),
|
||||
}))
|
||||
}
|
||||
c.JSON(200, result.OkData(data))
|
||||
}
|
||||
Reference in new issue
Block a user