feat: update template
This commit is contained in:
42
internal/service/admin/access_log.go
Normal file
42
internal/service/admin/access_log.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"server/internal/db"
|
||||
"server/internal/db/sqlc"
|
||||
"server/internal/model/common"
|
||||
)
|
||||
|
||||
type AccessLogService struct {
|
||||
store *db.Store
|
||||
}
|
||||
|
||||
func NewAccessLogService(store *db.Store) *AccessLogService {
|
||||
return &AccessLogService{
|
||||
store: store,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *AccessLogService) List(ctx context.Context, p *common.Pagination) (*common.PageResult[sqlc.ListAccessLogsRow], error) {
|
||||
params := sqlc.ListAccessLogsParams{
|
||||
Limit: p.PageSize,
|
||||
Offset: (p.Page - 1) * p.PageSize,
|
||||
}
|
||||
|
||||
total, err := s.store.CountAccessLogs(ctx)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list, err := s.store.ListAccessLogs(ctx, params)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &common.PageResult[sqlc.ListAccessLogsRow]{
|
||||
Total: total,
|
||||
List: list,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user