common.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package request
  2. type IDRequestParam interface {
  3. Params
  4. GetID() string
  5. }
  6. type IDJsonBody struct {
  7. ID string `json:"id" binding:"required" assign:"toField:ID"`
  8. }
  9. func (id *IDJsonBody) GetID() string {
  10. return id.ID
  11. }
  12. type IDPathParam struct {
  13. ID string `uri:"id" binding:"required" assign:"toField:ID"`
  14. }
  15. func (id *IDPathParam) GetID() string {
  16. return id.ID
  17. }
  18. type IDQueryParam struct {
  19. ID string `form:"id" binding:"required" assign:"toField:ID"`
  20. }
  21. func (id *IDQueryParam) GetID() string {
  22. return id.ID
  23. }
  24. type TenantIDRequestParam interface {
  25. Params
  26. GetTenantID() string
  27. }
  28. type TenantIDJsonBody struct {
  29. TenantID string `json:"tenantId" binding:"required" assign:"toField:TenantID"`
  30. }
  31. func (id *IDJsonBody) GetTenantID() string {
  32. return id.ID
  33. }
  34. type TenantIDPathParam struct {
  35. TenantID string `uri:"tenantId" binding:"required" assign:"toField:TenantID"`
  36. }
  37. func (id *IDPathParam) GetTenantID() string {
  38. return id.ID
  39. }
  40. type TenantIDQueryParam struct {
  41. TenantID string `form:"tenantId" binding:"required" assign:"toField:TenantID"`
  42. }
  43. func (id *IDQueryParam) GetTenantID() string {
  44. return id.ID
  45. }
  46. type QueryRequestParams interface {
  47. Params
  48. GetPageNo() int
  49. GetPageSize() int
  50. }
  51. type BaseQueryParams struct {
  52. PageNo int `form:"pageNo" assign:"-"`
  53. PageSize int `form:"pageSize" assign:"-"`
  54. }
  55. func (q *BaseQueryParams) GetPageNo() int {
  56. return q.PageNo
  57. }
  58. func (q *BaseQueryParams) GetPageSize() int {
  59. return q.PageSize
  60. }
  61. type QueryWithIDRequestParams interface {
  62. IDRequestParam
  63. QueryRequestParams
  64. }
  65. type BaseQueryWithIDParams struct {
  66. IDQueryParam
  67. BaseQueryParams
  68. }
  69. type CreateUserIDJsonBody struct {
  70. CreateUserID string `json:"createUserId" binding:"required" assign:"toField:CreateUserID"`
  71. }
  72. type UpdateUserIDJsonBody struct {
  73. UpdateUserID string `json:"updateUserId" binding:"required" assign:"toField:LastUpdateUserID"`
  74. }
  75. type DeleteUserIDQueryParams struct {
  76. DeleteUserID string `form:"deleteUserId" binding:"required" assign:"toField:LastUpdateUserID"`
  77. }