notification.go 681 B

1234567891011121314151617181920212223242526272829303132
  1. package notification
  2. import (
  3. "github.com/0xJacky/Nginx-UI/model"
  4. "github.com/0xJacky/Nginx-UI/query"
  5. )
  6. func Info(title string, details string) {
  7. push(model.NotificationInfo, title, details)
  8. }
  9. func Error(title string, details string) {
  10. push(model.NotificationError, title, details)
  11. }
  12. func Warning(title string, details string) {
  13. push(model.NotificationWarning, title, details)
  14. }
  15. func Success(title string, details string) {
  16. push(model.NotificationSuccess, title, details)
  17. }
  18. func push(nType model.NotificationType, title string, details string) {
  19. n := query.Notification
  20. _ = n.Create(&model.Notification{
  21. Type: nType,
  22. Title: title,
  23. Details: details,
  24. })
  25. }