47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package system
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"management/internal/erpserver/model/dto"
|
|
"management/internal/erpserver/model/system"
|
|
"management/internal/erpserver/service/v1"
|
|
)
|
|
|
|
type loginLogService struct {
|
|
*v1.Service
|
|
repo system.LoginLogRepository
|
|
}
|
|
|
|
func NewLoginLogService(service *v1.Service, repo system.LoginLogRepository) v1.LoginLogService {
|
|
return &loginLogService{
|
|
Service: service,
|
|
repo: repo,
|
|
}
|
|
}
|
|
|
|
func (s *loginLogService) Create(ctx context.Context, req *system.LoginLog) error {
|
|
return s.repo.Create(ctx, req)
|
|
}
|
|
|
|
func (s *loginLogService) List(ctx context.Context, q dto.SearchDto) ([]*system.LoginLog, int64, error) {
|
|
return s.repo.List(ctx, q)
|
|
}
|
|
|
|
func (s *loginLogService) LoginLatestTime(ctx context.Context, email string) time.Time {
|
|
log, err := s.repo.GetLatest(ctx, email)
|
|
if err != nil {
|
|
return time.Time{}
|
|
}
|
|
return log.CreatedAt
|
|
}
|
|
|
|
func (s *loginLogService) LoginCount(ctx context.Context, email string) int64 {
|
|
count, err := s.repo.Count(ctx, email)
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
return count
|
|
}
|