You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

admin_operate_log.go 967 B

2 years ago
2 years ago
2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package models
  2. import (
  3. "code.gitea.io/gitea/modules/log"
  4. "code.gitea.io/gitea/modules/timeutil"
  5. "encoding/json"
  6. )
  7. type AdminOperateLog struct {
  8. ID int64 `xorm:"pk autoincr"`
  9. BizType string
  10. OperateType string
  11. OldValue string `xorm:"TEXT"`
  12. NewValue string `xorm:"TEXT"`
  13. RelatedId string `xorm:"INDEX"`
  14. Comment string
  15. CreatedTime timeutil.TimeStamp `xorm:"created"`
  16. CreatedBy int64
  17. }
  18. type LogValues struct {
  19. Params []LogValue
  20. }
  21. type LogValue struct {
  22. Key string
  23. Val interface{}
  24. }
  25. func (l *LogValues) Add(key string, val interface{}) *LogValues {
  26. l.Params = append(l.Params, LogValue{Key: key, Val: val})
  27. return l
  28. }
  29. func (l *LogValues) JsonString() string {
  30. if len(l.Params) == 0 {
  31. return ""
  32. }
  33. b, err := json.Marshal(l)
  34. if err != nil {
  35. log.Error("LogValues JsonString error . %v", err)
  36. return ""
  37. }
  38. return string(b)
  39. }
  40. func InsertAdminOperateLog(log AdminOperateLog) (int64, error) {
  41. return x.Insert(&log)
  42. }