feat: 监控模块多语言

This commit is contained in:
TsMask
2023-11-20 18:54:59 +08:00
parent 99e247506a
commit d52945c946
4 changed files with 28 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
package controller
import (
"ems.agt/src/framework/i18n"
"ems.agt/src/framework/utils/ctx"
"ems.agt/src/framework/vo/result"
"ems.agt/src/modules/monitor/service"
@@ -24,6 +26,7 @@ type MonitorController struct {
//
// GET /load
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"`
@@ -40,7 +43,7 @@ func (s *MonitorController) Load(c *gin.Context) {
}
err := c.ShouldBindQuery(&querys)
if err != nil {
c.JSON(400, result.CodeMsg(400, "parameter error"))
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}

View File

@@ -2,7 +2,9 @@ package controller
import (
"ems.agt/src/framework/constants/cachekey"
"ems.agt/src/framework/i18n"
"ems.agt/src/framework/redis"
"ems.agt/src/framework/utils/ctx"
"ems.agt/src/framework/vo/result"
"ems.agt/src/modules/monitor/model"
@@ -48,9 +50,10 @@ func (s *SysCacheController) Names(c *gin.Context) {
//
// GET /getKeys/:cacheName
func (s *SysCacheController) Keys(c *gin.Context) {
language := ctx.AcceptLanguage(c)
cacheName := c.Param("cacheName")
if cacheName == "" {
c.JSON(400, result.CodeMsg(400, "parameter error"))
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
caches := []model.SysCache{}
@@ -68,10 +71,11 @@ func (s *SysCacheController) Keys(c *gin.Context) {
//
// GET /getValue/:cacheName/:cacheKey
func (s *SysCacheController) Value(c *gin.Context) {
language := ctx.AcceptLanguage(c)
cacheName := c.Param("cacheName")
cacheKey := c.Param("cacheKey")
if cacheName == "" || cacheKey == "" {
c.JSON(400, result.CodeMsg(400, "parameter error"))
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
@@ -88,9 +92,10 @@ func (s *SysCacheController) Value(c *gin.Context) {
//
// DELETE /clearCacheName/:cacheName
func (s *SysCacheController) ClearCacheName(c *gin.Context) {
language := ctx.AcceptLanguage(c)
cacheName := c.Param("cacheName")
if cacheName == "" {
c.JSON(400, result.CodeMsg(400, "parameter error"))
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}
@@ -111,10 +116,11 @@ func (s *SysCacheController) ClearCacheName(c *gin.Context) {
//
// DELETE /clearCacheKey/:cacheName/:cacheKey
func (s *SysCacheController) ClearCacheKey(c *gin.Context) {
language := ctx.AcceptLanguage(c)
cacheName := c.Param("cacheName")
cacheKey := c.Param("cacheKey")
if cacheName == "" || cacheKey == "" {
c.JSON(400, result.CodeMsg(400, "parameter error"))
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}

View File

@@ -6,7 +6,9 @@ import (
"strings"
"ems.agt/src/framework/constants/cachekey"
"ems.agt/src/framework/i18n"
"ems.agt/src/framework/redis"
"ems.agt/src/framework/utils/ctx"
"ems.agt/src/framework/vo"
"ems.agt/src/framework/vo/result"
"ems.agt/src/modules/monitor/model"
@@ -110,9 +112,10 @@ func (s *SysUserOnlineController) List(c *gin.Context) {
//
// DELETE /:tokenId
func (s *SysUserOnlineController) ForceLogout(c *gin.Context) {
language := ctx.AcceptLanguage(c)
tokenId := c.Param("tokenId")
if tokenId == "" || tokenId == "*" {
c.JSON(400, result.CodeMsg(400, "parameter error"))
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
return
}

View File

@@ -80,18 +80,18 @@ func Setup(router *gin.Engine) {
)
sysJobLogGroup.DELETE("/:jobLogIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task Log", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJobLog", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysJobLog.Remove,
)
sysJobLogGroup.DELETE("/clean",
repeat.RepeatSubmit(5),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task Log", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJobLog", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysJobLog.Clean,
)
sysJobLogGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task Log", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJobLog", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysJobLog.Export,
)
}
@@ -109,39 +109,39 @@ func Setup(router *gin.Engine) {
)
sysJobGroup.POST("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:add"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_INSERT)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJob", collectlogs.BUSINESS_TYPE_INSERT)),
controller.NewSysJob.Add,
)
sysJobGroup.PUT("",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:edit"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJob", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysJob.Edit,
)
sysJobGroup.DELETE("/:jobIds",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:remove"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_DELETE)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJob", collectlogs.BUSINESS_TYPE_DELETE)),
controller.NewSysJob.Remove,
)
sysJobGroup.PUT("/changeStatus",
repeat.RepeatSubmit(5),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJob", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysJob.Status,
)
sysJobGroup.PUT("/run/:jobId",
repeat.RepeatSubmit(10),
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_UPDATE)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJob", collectlogs.BUSINESS_TYPE_UPDATE)),
controller.NewSysJob.Run,
)
sysJobGroup.PUT("/resetQueueJob",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:changeStatus"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_CLEAN)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJob", collectlogs.BUSINESS_TYPE_CLEAN)),
controller.NewSysJob.ResetQueueJob,
)
sysJobGroup.POST("/export",
middleware.PreAuthorize(map[string][]string{"hasPerms": {"monitor:job:export"}}),
collectlogs.OperateLog(collectlogs.OptionNew("Scheduling Task", collectlogs.BUSINESS_TYPE_EXPORT)),
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.sysJob", collectlogs.BUSINESS_TYPE_EXPORT)),
controller.NewSysJob.Export,
)
}