mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-09-28 04:42:12 +08:00
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package api
|
|
|
|
import (
|
|
"errors"
|
|
"slices"
|
|
|
|
"github.com/lzh-1625/go_process_manager/internal/app/eum"
|
|
"github.com/lzh-1625/go_process_manager/internal/app/logic"
|
|
"github.com/lzh-1625/go_process_manager/internal/app/model"
|
|
"github.com/lzh-1625/go_process_manager/internal/app/repository"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type logApi struct{}
|
|
|
|
var LogApi = new(logApi)
|
|
|
|
func (a *logApi) GetLog(ctx *gin.Context, req model.GetLogReq) any {
|
|
if isAdmin(ctx) {
|
|
return logic.LogLogicImpl.Search(req, req.FilterName...)
|
|
} else {
|
|
processNameList := repository.PermissionRepository.GetProcessNameByPermission(getUserName(ctx), eum.OperationLog)
|
|
filterName := slices.DeleteFunc(req.FilterName, func(s string) bool {
|
|
return !slices.Contains(processNameList, s)
|
|
})
|
|
if len(filterName) == 0 {
|
|
filterName = processNameList
|
|
}
|
|
if len(filterName) == 0 {
|
|
return errors.New("no information found")
|
|
}
|
|
return logic.LogLogicImpl.Search(req, filterName...)
|
|
}
|
|
}
|
|
|
|
func (a *logApi) GetRunningLog(ctx *gin.Context, _ any) int {
|
|
return logic.Loghandler.GetRunning()
|
|
}
|