system_config.go 648 B

1234567891011121314151617181920212223242526
  1. package mysql
  2. import (
  3. "context"
  4. "gorm.io/gen"
  5. "pji_desktop_http/biz/dal/query"
  6. "pji_desktop_http/biz/model"
  7. )
  8. func QuerySystemConfig(ctx context.Context) (*model.SystemConfig, error) {
  9. r := query.SystemConfig
  10. config, err := r.WithContext(ctx).First()
  11. if err != nil {
  12. return &model.SystemConfig{}, err
  13. }
  14. return config, nil
  15. }
  16. func UpdateSystemConfig(ctx context.Context, config *model.SystemConfig) (gen.ResultInfo, error) {
  17. r := query.SystemConfig
  18. info, err := r.WithContext(ctx).Where(r.DeletedAt.Eq(nil)).Update(r.RescanReminderThreshold, config.RescanReminderThreshold)
  19. if err != nil {
  20. return info, err
  21. }
  22. return info, nil
  23. }