| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- // Code scaffolded by goctl. Safe to edit.
- // goctl 1.10.2
- package systemlog
- import (
- "context"
- "udeServer/internal/apierr"
- "udeServer/internal/log"
- udeModel "udeServer/internal/model"
- "udeServer/internal/svc"
- "udeServer/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type LogArchiveListLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- // 归档列表
- func NewLogArchiveListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogArchiveListLogic {
- return &LogArchiveListLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- // LogArchiveList pages the archive records with optional filters.
- func (l *LogArchiveListLogic) LogArchiveList(req *types.LogArchiveListReq) (*types.LogArchiveListResp, error) {
- page, pageSize := normalizePage(req.Page, req.PageSize)
- f := udeModel.LogArchiveFilter{
- ArchiveName: req.ArchiveName,
- ArchivedBy: req.ArchivedBy,
- ArchivedStartTime: req.ArchivedStartTime,
- ArchivedEndTime: req.ArchivedEndTime,
- }
- list, total, err := l.svcCtx.LogArchiveRecordModel.FindPage(l.ctx, page, pageSize, f)
- if err != nil {
- log.RecordError(l.ctx, err)
- return nil, apierr.New(500, "查询归档分页列表失败")
- }
- logArchives := make([]types.LogArchive, len(list))
- for i := range list {
- logArchives[i] = ConvertToLogArchive(&list[i])
- }
- return &types.LogArchiveListResp{
- Total: total,
- LogArchives: logArchives,
- }, nil
- }
|