model.go 823 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package rest
  2. import (
  3. "git.nspix.com/golang/micro/gateway/http"
  4. "gorm.io/gorm"
  5. )
  6. type (
  7. Model interface {
  8. ModuleName() string
  9. TableName() string
  10. Scenario() []string
  11. }
  12. ModelViewer interface {
  13. TableLabel() string
  14. }
  15. Migrating interface {
  16. Defaults() []MigrateValue
  17. }
  18. MigrateValue struct {
  19. Value interface{}
  20. Conditions interface{}
  21. }
  22. KvMapping interface {
  23. LabelField() string
  24. ValueField() string
  25. }
  26. mappingValue struct {
  27. Label string `json:"label"`
  28. Value string `json:"value"`
  29. }
  30. // FilterColumnInterface 过滤回调函数
  31. FilterColumnInterface interface {
  32. OnSearchColumn(ctx *http.Context, query *Query, schema *Schema) (err error)
  33. }
  34. // RequestHandleFunc 处理HTTP请求回调函数
  35. RequestHandleFunc func(ctx *http.Context, tx *gorm.DB, model interface{}) (err error)
  36. )