common.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package request
  2. // IDRequestParam 包含ID字段的请求参数接口
  3. type IDRequestParam interface {
  4. Params
  5. GetID() string
  6. }
  7. // IDJsonBody JsonBody中包含ID字段的定义结构
  8. type IDJsonBody struct {
  9. ID string `json:"id" binding:"required" assign:"toField:ID"`
  10. }
  11. func (id *IDJsonBody) GetID() string {
  12. return id.ID
  13. }
  14. // IDQueryParam 查询参数中包含ID字段的定义结构
  15. type IDQueryParam struct {
  16. ID string `form:"id" binding:"required" assign:"toField:ID"`
  17. }
  18. func (id *IDQueryParam) GetID() string {
  19. return id.ID
  20. }
  21. // IDPathParam 路径参数中包含ID字段的定义结构
  22. type IDPathParam struct {
  23. ID string `uri:"id" binding:"required" assign:"toField:ID"`
  24. }
  25. func (id *IDPathParam) GetID() string {
  26. return id.ID
  27. }
  28. // TenantIDRequestParam 包含租户ID字段的请求参数接口
  29. type TenantIDRequestParam interface {
  30. Params
  31. GetTenantID() string
  32. }
  33. // TenantIDJsonBody JsonBody中包含租户ID字段的定义结构
  34. type TenantIDJsonBody struct {
  35. TenantID string `json:"tenantId" binding:"required" assign:"toField:TenantID"`
  36. }
  37. func (id *IDJsonBody) GetTenantID() string {
  38. return id.ID
  39. }
  40. // TenantIDQueryParam 查询参数中包含租户ID字段的定义结构
  41. type TenantIDQueryParam struct {
  42. TenantID string `form:"tenantId" binding:"required" assign:"toField:TenantID"`
  43. }
  44. func (id *IDQueryParam) GetTenantID() string {
  45. return id.ID
  46. }
  47. // TenantIDPathParam 路径参数中包含租户ID字段的定义结构
  48. type TenantIDPathParam struct {
  49. TenantID string `uri:"tenantId" binding:"required" assign:"toField:TenantID"`
  50. }
  51. func (id *IDPathParam) GetTenantID() string {
  52. return id.ID
  53. }
  54. // QueryRequestParams 包含查询请求需要字段的查询参数接口
  55. type QueryRequestParams interface {
  56. Params
  57. GetPageNo() int
  58. GetPageSize() int
  59. }
  60. // BaseQueryParams 包含查询请求需要字段的查询参数基础实现
  61. type BaseQueryParams struct {
  62. PageNo int `form:"pageNo" assign:"-"`
  63. PageSize int `form:"pageSize" assign:"-"`
  64. }
  65. func (q *BaseQueryParams) GetPageNo() int {
  66. return q.PageNo
  67. }
  68. func (q *BaseQueryParams) GetPageSize() int {
  69. return q.PageSize
  70. }
  71. // QueryWithIDRequestParams 包含查通过ID查询需要字段的查询参数接口
  72. type QueryWithIDRequestParams interface {
  73. IDRequestParam
  74. QueryRequestParams
  75. }
  76. // BaseQueryWithIDParams 包含查通过ID查询需要字段的查询参数基础实现
  77. type BaseQueryWithIDParams struct {
  78. IDQueryParam
  79. BaseQueryParams
  80. }
  81. // CreateUserIDJsonBody JsonBody中包含创建用户ID字段的定义结构
  82. type CreateUserIDJsonBody struct {
  83. CreateUserID string `json:"createUserId" binding:"required" assign:"toField:CreateUserID"`
  84. }
  85. // UpdateUserIDJsonBody JsonBody中包含最近更新用户ID字段的定义结构
  86. type UpdateUserIDJsonBody struct {
  87. UpdateUserID string `json:"updateUserId" binding:"required" assign:"toField:LastUpdateUserID"`
  88. }
  89. // DeleteUserIDQueryParams 查询参数中包含删除用户ID字段的定义结构
  90. type DeleteUserIDQueryParams struct {
  91. DeleteUserID string `form:"deleteUserId" binding:"required" assign:"toField:DeleteUserID"`
  92. }
  93. // OperatorUserNameJsonBody JsonBody中包含操作者用户名的定义结构
  94. type OperatorUserNameJsonBody struct {
  95. OperatorUserName string `json:"operatorUserName" binding:"required" assign:"toField:OperatorUserName"`
  96. }
  97. // OperatorUserNameQueryParams 查询参数中包含操作者用户名的定义结构
  98. type OperatorUserNameQueryParams struct {
  99. OperatorUserName string `form:"operatorUserName" binding:"required" assign:"toField:OperatorUserName"`
  100. }