spec.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package sdk
  2. import "github.com/fatih/structs"
  3. type DataSourceDatabaseSpec struct {
  4. Type string `structs:"type"`
  5. UserName string `structs:"user_name"`
  6. Password string `structs:"password"`
  7. Address string `structs:"address"`
  8. Port string `structs:"port"`
  9. Database string `structs:"database"`
  10. MaxConnections int `structs:"max_connections"`
  11. MaxIdleConnections int `structs:"max_idle_connections"`
  12. }
  13. func (spec *DataSourceDatabaseSpec) ToMap() map[string]any {
  14. return structs.Map(spec)
  15. }
  16. type DataContainerDatabaseSpec struct {
  17. TableName string `structs:"table_name"`
  18. Columns []DataContainerDatabaseColumnSpec `structs:"columns"`
  19. }
  20. type DataContainerDatabaseColumnSpec struct {
  21. Name string `structs:"name"`
  22. Type string `structs:"type"`
  23. Comment string `structs:"comment"`
  24. PrimaryKey bool `structs:"primary_key"`
  25. Size int `structs:"size"`
  26. Unique bool `structs:"unique"`
  27. NotNull bool `structs:"not_null"`
  28. Index bool `structs:"index"`
  29. UniqueIndex string `structs:"unique_index"`
  30. Default any `structs:"default"`
  31. }
  32. func (spec *DataContainerDatabaseSpec) ToMap() map[string]any {
  33. return structs.Map(spec)
  34. }