update
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user