order.go 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package model
  2. import (
  3. "time"
  4. "go-common/library/ecode"
  5. )
  6. // Order perf order model
  7. type Order struct {
  8. ID int64 `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
  9. Name string `json:"name" form:"name"`
  10. Broker string `json:"broker" form:"broker"`
  11. TestBackGround string `json:"test_background" form:"test_background" gorm:"column:test_background"`
  12. Type int32 `json:"type" form:"type" gorm:"type"`
  13. TestType int32 `json:"test_type" form:"test_type" gorm:"test_type"`
  14. TestTarget string `json:"test_target" gorm:"test_target"`
  15. APIList string `json:"api_list" gorm:"api_list"`
  16. APIDoc string `json:"api_doc" gorm:"api_doc"`
  17. LimitUser string `json:"limit_user" gorm:"limit_user"`
  18. LimitIP string `json:"limit_ip" gorm:"limit_ip"`
  19. LimitVisit string `json:"limit_visit" gorm:"limit_visit"`
  20. ServerConf string `json:"server_conf" gorm:"server_conf"`
  21. DependentComponent string `json:"dependent_component" gorm:"dependent_component"`
  22. DependentBusiness string `json:"dependent_business" gorm:"dependent_business"`
  23. TestDataFrom string `json:"test_data_from" gorm:"test_data_from"`
  24. TestHost string `json:"test_host" gorm:"test_host"`
  25. MoniRedis string `json:"moni_redis" gorm:"moni_redis"`
  26. MoniMemcache string `json:"moni_memcache" gorm:"moni_memcache"`
  27. MoniDocker string `json:"moni_docker" gorm:"moni_docker"`
  28. MoniAPI string `json:"moni_api" gorm:"moni_api"`
  29. MoniMysql string `json:"moni_mysql" gorm:"moni_mysql"`
  30. MoniElasticsearch string `json:"moni_elasticsearch" gorm:"moni_elasticsearch"`
  31. MoniOther string `json:"moni_other" gorm:"moni_other"`
  32. TestCycles string `json:"test_cycles" gorm:"moni_cycles"`
  33. ScriptID string `json:"script_id" gorm:"script_id"`
  34. MachineID string `json:"machine_id" gorm:"machine_id"`
  35. Department string `json:"department" form:"department" gorm:"department"`
  36. Project string `json:"project" form:"project" gorm:"project"`
  37. App string `json:"app" form:"app" gorm:"app"`
  38. Status int32 `json:"status" form:"status" gorm:"status"`
  39. UpdateBy string `json:"update_by" form:"update_by" gorm:"update_by"`
  40. Handler string `json:"handler" form:"handler" gorm:"handler"`
  41. ApplyDate time.Time `json:"apply_date" gorm:"apply_date"`
  42. Active int32 `json:"active" gorm:"active"`
  43. }
  44. // QueryOrderRequest queryOrderRequest
  45. type QueryOrderRequest struct {
  46. Order
  47. Pagination
  48. }
  49. // QueryOrderResponse queryOrderResponse
  50. type QueryOrderResponse struct {
  51. Orders []*Order `json:"orders"`
  52. Pagination
  53. }
  54. // Verify verify the value of pageNum and pageSize.
  55. func (p *Pagination) Verify() error {
  56. if p.PageNum < 0 {
  57. return ecode.MeilloiIllegalPageNumErr
  58. } else if p.PageNum == 0 {
  59. p.PageNum = 1
  60. }
  61. if p.PageSize < 0 {
  62. return ecode.MeilloillegalPageSizeErr
  63. } else if p.PageSize == 0 {
  64. p.PageSize = 10
  65. }
  66. return nil
  67. }
  68. // Pagination page num
  69. type Pagination struct {
  70. PageNum int32 `form:"page_num" json:"page_num"`
  71. PageSize int32 `form:"page_size" json:"page_size"`
  72. TotalSize int32 `form:"total_size" json:"total_size"`
  73. }
  74. // TableName get table name model
  75. func (w Order) TableName() string {
  76. return "order"
  77. }