2
This commit is contained in:
46
internal/erpserver/service/v1/system/login_log.go
Normal file
46
internal/erpserver/service/v1/system/login_log.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"management/internal/db/model/dto"
|
||||
"management/internal/erpserver/model/system"
|
||||
v1 "management/internal/erpserver/service/v1"
|
||||
)
|
||||
|
||||
type loginLogService struct {
|
||||
repo system.LoginLogRepository
|
||||
}
|
||||
|
||||
var _ v1.LoginLogService = (*loginLogService)(nil)
|
||||
|
||||
func NewLoginLogService(repo system.LoginLogRepository) *loginLogService {
|
||||
return &loginLogService{
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user