update
This commit is contained in:
@@ -2,7 +2,6 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"management/internal/erpserver/model/dto"
|
||||
"management/internal/erpserver/model/form"
|
||||
@@ -67,7 +66,7 @@ type LoginLogService interface {
|
||||
Create(ctx context.Context, req *system.LoginLog) error
|
||||
List(ctx context.Context, q dto.SearchDto) ([]*system.LoginLog, int64, error)
|
||||
|
||||
LoginLatestTime(ctx context.Context, email string) time.Time
|
||||
LoginTime(ctx context.Context, email string) (dto.LoginTimeDto, error)
|
||||
LoginCount(ctx context.Context, email string) int64
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,17 @@ func (s *configService) Pear(ctx context.Context) (*dto.PearConfig, error) {
|
||||
var res *dto.PearConfig
|
||||
key := know.GetManageKey(ctx, know.PearAdmin)
|
||||
err := util.GetOrSetCache(ctx, s.Redis, key, util.GetCacheExpire(), func() (any, error) {
|
||||
return s.repo.GetByKey(ctx, pearadmin.PearKey)
|
||||
conf, err := s.repo.GetByKey(ctx, pearadmin.PearKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var pc dto.PearConfig
|
||||
err = json.Unmarshal(conf.Value, &pc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pc, nil
|
||||
}, &res)
|
||||
return res, err
|
||||
}
|
||||
@@ -72,7 +82,7 @@ func (s *configService) ResetPear(ctx context.Context) error {
|
||||
// create
|
||||
conf = &system.Config{
|
||||
Key: pearadmin.PearKey,
|
||||
Value: string(b),
|
||||
Value: b,
|
||||
}
|
||||
err = s.Create(ctx, conf)
|
||||
if err != nil {
|
||||
@@ -80,7 +90,7 @@ func (s *configService) ResetPear(ctx context.Context) error {
|
||||
}
|
||||
} else {
|
||||
// update
|
||||
conf.Value = string(b)
|
||||
conf.Value = b
|
||||
conf.UpdatedAt = time.Now()
|
||||
err = s.Update(ctx, conf)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,7 +2,6 @@ package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"management/internal/erpserver/model/dto"
|
||||
"management/internal/erpserver/model/system"
|
||||
@@ -29,12 +28,20 @@ func (s *loginLogService) List(ctx context.Context, q dto.SearchDto) ([]*system.
|
||||
return s.repo.List(ctx, q)
|
||||
}
|
||||
|
||||
func (s *loginLogService) LoginLatestTime(ctx context.Context, email string) time.Time {
|
||||
log, err := s.repo.GetLatest(ctx, email)
|
||||
func (s *loginLogService) LoginTime(ctx context.Context, email string) (dto.LoginTimeDto, error) {
|
||||
var res dto.LoginTimeDto
|
||||
logs, err := s.repo.GetLatest(ctx, email)
|
||||
if err != nil {
|
||||
return time.Time{}
|
||||
return res, err
|
||||
}
|
||||
return log.CreatedAt
|
||||
if len(logs) == 2 {
|
||||
res.ThisLoginTime = logs[0].CreatedAt
|
||||
res.LastLoginTime = logs[1].CreatedAt
|
||||
} else if len(logs) == 1 {
|
||||
res.ThisLoginTime = logs[0].CreatedAt
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (s *loginLogService) LoginCount(ctx context.Context, email string) int64 {
|
||||
|
||||
@@ -36,7 +36,8 @@ func NewMenuService(
|
||||
}
|
||||
|
||||
func (s *menuService) Create(ctx context.Context, req *system.Menu) error {
|
||||
return s.repo.Create(ctx, req)
|
||||
_, err := s.repo.Create(ctx, req)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *menuService) Update(ctx context.Context, req *system.Menu) error {
|
||||
|
||||
Reference in New Issue
Block a user