Some checks failed
Build and Deploy (service.xpcool.com) / build-and-deploy (push) Failing after 5m7s
- 新增 9 张房屋相关数据表(社区/楼宇/房源/价格快照/交易/设施/社区设施/学区/偏好) - 添加菜单权限种子数据并绑定超级管理员角色 - 生成 DAO 层代码和实体对象 - 实现房屋模块 API 接口(社区/房源/看板)和控制器服务层 - 支持多平台软关联匹配、笋盘标记和低可信度标记功能 - 更新超级管理员账号为 xxcool/xxCool@2026 - 调整 RBAC 菜单结构,移除管理员管理功能,新增日志管理菜单 - 修复 RBAC 安全漏洞,确保禁用角色权限失效 - 重构认证模块,将登录相关接口迁移到统一包结构下 - 移除废弃的管理模块和工具类接口定义 - 为通用工具包添加中文注释和文档说明
51 lines
1.9 KiB
Go
51 lines
1.9 KiB
Go
package admin
|
|
|
|
import (
|
|
"context"
|
|
|
|
logv1 "service.xpcool.com/api/admin/base/log"
|
|
systemlogv1 "service.xpcool.com/api/admin/system/log"
|
|
"service.xpcool.com/internal/model/dto"
|
|
log "service.xpcool.com/internal/service/admin/base/log"
|
|
adminlog "service.xpcool.com/internal/service/admin/system/log"
|
|
)
|
|
|
|
// LogFiles 列出服务器日志文件。
|
|
func (c *Controller) LogFiles(ctx context.Context, req *logv1.LogFilesReq) (res *logv1.LogFilesRes, err error) {
|
|
dir, files, err := log.LogManage().Files(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
list := make([]*logv1.LogFile, 0, len(files))
|
|
for _, f := range files {
|
|
list = append(list, &logv1.LogFile{Name: f.Name, Path: f.Path, Size: f.Size, ModTime: f.ModTime})
|
|
}
|
|
return &logv1.LogFilesRes{Dir: dir, Files: list}, nil
|
|
}
|
|
|
|
// LogTail 读取日志文件尾部,支持关键字过滤。
|
|
func (c *Controller) LogTail(ctx context.Context, req *logv1.LogTailReq) (res *logv1.LogTailRes, err error) {
|
|
lines, err := log.LogManage().Tail(ctx, req.File, req.Lines, req.Keyword)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &logv1.LogTailRes{Lines: lines}, nil
|
|
}
|
|
|
|
// LogList 分页查询 admin 系统日志(操作审计记录)。
|
|
func (c *Controller) LogList(ctx context.Context, req *systemlogv1.LogListReq) (res *systemlogv1.LogListRes, err error) {
|
|
items, total, err := adminlog.AdminAudit().List(ctx, dto.LogQuery{Page: req.Page, Size: req.Size, AdminID: req.AdminID, Permission: req.Keyword})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
list := make([]*systemlogv1.LogItem, 0, len(items))
|
|
for _, it := range items {
|
|
list = append(list, &systemlogv1.LogItem{
|
|
Id: it.Id, AdminID: it.AdminID, Permission: it.Permission, Method: it.Method,
|
|
Path: it.Path, IP: it.IP, Param: it.Param, DurationMS: it.DurationMS,
|
|
StatusCode: it.StatusCode, CreatedAt: it.CreatedAt,
|
|
})
|
|
}
|
|
return &systemlogv1.LogListRes{List: list, Total: total}, nil
|
|
}
|