mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
fix: i18n & other optimizations
This commit is contained in:
@@ -16,8 +16,8 @@ type Dashbord struct {
|
||||
func (m *Dashbord) Dashbord(rc *req.Ctx) {
|
||||
accountId := rc.GetLoginAccount().Id
|
||||
|
||||
tagCodePaths := m.TagTreeApp.GetAccountTagCodePaths(accountId, tagentity.TagTypeMachineAuthCert, "")
|
||||
machineCodes := tagentity.GetCodeByPath(tagentity.TagTypeMachine, tagCodePaths...)
|
||||
tagCodePaths := m.TagTreeApp.GetAccountTags(accountId, &tagentity.TagTreeQuery{Types: collx.AsArray(tagentity.TagTypeMachineAuthCert)}).GetCodePaths()
|
||||
machineCodes := tagentity.GetCodesByCodePaths(tagentity.TagTypeMachine, tagCodePaths...)
|
||||
|
||||
rc.ResData = collx.M{
|
||||
"machineNum": len(machineCodes),
|
||||
|
||||
@@ -43,14 +43,18 @@ type Machine struct {
|
||||
func (m *Machine) Machines(rc *req.Ctx) {
|
||||
condition, pageParam := req.BindQueryAndPage(rc, new(entity.MachineQuery))
|
||||
|
||||
tagCodePaths := m.TagApp.GetAccountTagCodePaths(rc.GetLoginAccount().Id, tagentity.TagTypeMachineAuthCert, condition.TagPath)
|
||||
tags := m.TagApp.GetAccountTags(rc.GetLoginAccount().Id, &tagentity.TagTreeQuery{
|
||||
Types: collx.AsArray(tagentity.TagTypeMachineAuthCert),
|
||||
CodePathLikes: collx.AsArray(condition.TagPath),
|
||||
})
|
||||
// 不存在可操作的机器-授权凭证标签,即没有可操作数据
|
||||
if len(tagCodePaths) == 0 {
|
||||
if len(tags) == 0 {
|
||||
rc.ResData = model.EmptyPageResult[any]()
|
||||
return
|
||||
}
|
||||
|
||||
machineCodes := tagentity.GetCodeByPath(tagentity.TagTypeMachine, tagCodePaths...)
|
||||
tagCodePaths := tags.GetCodePaths()
|
||||
machineCodes := tagentity.GetCodesByCodePaths(tagentity.TagTypeMachine, tagCodePaths...)
|
||||
condition.Codes = collx.ArrayDeduplicate(machineCodes)
|
||||
|
||||
var machinevos []*vo.MachineVO
|
||||
@@ -67,7 +71,7 @@ func (m *Machine) Machines(rc *req.Ctx) {
|
||||
})...)
|
||||
|
||||
// 填充授权凭证信息
|
||||
m.ResourceAuthCertApp.FillAuthCertByAcNames(tagentity.GetCodeByPath(tagentity.TagTypeMachineAuthCert, tagCodePaths...), collx.ArrayMap(machinevos, func(mvo *vo.MachineVO) tagentity.IAuthCert {
|
||||
m.ResourceAuthCertApp.FillAuthCertByAcNames(tagentity.GetCodesByCodePaths(tagentity.TagTypeMachineAuthCert, tagCodePaths...), collx.ArrayMap(machinevos, func(mvo *vo.MachineVO) tagentity.IAuthCert {
|
||||
return mvo
|
||||
})...)
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ func (m *machineCronJobAppImpl) RunCronJob(key string) {
|
||||
|
||||
relateCodePaths := m.tagTreeRelateApp.GetTagPathsByRelate(tagentity.TagRelateTypeMachineCronJob, cronJob.Id)
|
||||
var machineTags []tagentity.TagTree
|
||||
m.tagTreeApp.ListByQuery(&tagentity.TagTreeQuery{CodePathLikes: relateCodePaths, Type: tagentity.TagTypeMachine}, &machineTags)
|
||||
m.tagTreeApp.ListByQuery(&tagentity.TagTreeQuery{CodePathLikes: relateCodePaths, Types: []tagentity.TagType{tagentity.TagTypeMachine}}, &machineTags)
|
||||
machines, _ := m.machineApp.ListByCond(model.NewCond().In("code", collx.ArrayMap(machineTags, func(tag tagentity.TagTree) string {
|
||||
return tag.Code
|
||||
})), "id")
|
||||
|
||||
@@ -31,5 +31,7 @@ var En = map[i18n.MsgId]string{
|
||||
ErrFileUploadFail: "File upload failure",
|
||||
MsgUploadFileSuccess: "File uploaded successfully",
|
||||
|
||||
TerminalCmdDisable: "This command has been disabled...",
|
||||
LogMachineSecurityCmdSave: "Machine - Security - Save command configuration",
|
||||
LogMachineSecurityCmdDelete: "Machine - Security - Delete command configuration",
|
||||
TerminalCmdDisable: "This command has been disabled...",
|
||||
}
|
||||
|
||||
@@ -39,5 +39,9 @@ const (
|
||||
ErrFileUploadFail
|
||||
MsgUploadFileSuccess
|
||||
|
||||
// security
|
||||
LogMachineSecurityCmdSave
|
||||
LogMachineSecurityCmdDelete
|
||||
|
||||
TerminalCmdDisable
|
||||
)
|
||||
|
||||
@@ -31,5 +31,7 @@ var Zh_CN = map[i18n.MsgId]string{
|
||||
ErrFileUploadFail: "文件上传失败",
|
||||
MsgUploadFileSuccess: "文件上传成功",
|
||||
|
||||
TerminalCmdDisable: "该命令已被禁用...",
|
||||
LogMachineSecurityCmdSave: "机器-安全-保存命令配置",
|
||||
LogMachineSecurityCmdDelete: "机器-安全-删除命令配置",
|
||||
TerminalCmdDisable: "该命令已被禁用...",
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package router
|
||||
|
||||
import (
|
||||
"mayfly-go/internal/machine/api"
|
||||
"mayfly-go/internal/machine/imsg"
|
||||
"mayfly-go/pkg/biz"
|
||||
"mayfly-go/pkg/ioc"
|
||||
"mayfly-go/pkg/req"
|
||||
@@ -18,9 +19,9 @@ func InitMachineCmdConfRouter(router *gin.RouterGroup) {
|
||||
reqs := [...]*req.Conf{
|
||||
req.NewGet("", mcc.MachineCmdConfs),
|
||||
|
||||
req.NewPost("", mcc.Save).Log(req.NewLogSave("机器命令配置-保存")).RequiredPermissionCode("cmdconf:save"),
|
||||
req.NewPost("", mcc.Save).Log(req.NewLogSaveI(imsg.LogMachineSecurityCmdSave)).RequiredPermissionCode("cmdconf:save"),
|
||||
|
||||
req.NewDelete(":id", mcc.Delete).Log(req.NewLogSave("机器命令配置-删除")).RequiredPermissionCode("cmdconf:del"),
|
||||
req.NewDelete(":id", mcc.Delete).Log(req.NewLogSaveI(imsg.LogMachineSecurityCmdDelete)).RequiredPermissionCode("cmdconf:del"),
|
||||
}
|
||||
|
||||
req.BatchSetGroup(mccs, reqs[:])
|
||||
|
||||
Reference in New Issue
Block a user