serv_api.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package dto
  2. import (
  3. "Medical_OAuth/app/admin/model"
  4. "Medical_OAuth/common/dto"
  5. common "Medical_OAuth/common/model"
  6. )
  7. // ServApiGetPageReq 列表或者搜索使用结构体
  8. type ServApiGetPageReq struct {
  9. dto.Pagination `search:"-"`
  10. ServiceId int `form:"serviceId" search:"type:exact;column:service_id;table:serv_api"` // 服务id
  11. Name string `form:"name" search:"type:orcontains;column:name;table:serv_api"` // 名称
  12. Path string `form:"name" search:"type:orcontains;column:path;table:serv_api" swaggerignore:"true"` // 路径
  13. }
  14. func (m *ServApiGetPageReq) GetNeedSearch() interface{} {
  15. return *m
  16. }
  17. // ServApiInsertReq 功能创建请求参数
  18. type ServApiInsertReq struct {
  19. Id int `json:"id" swaggerignore:"true"` // 编码
  20. ServiceId int `json:"ServiceId"` // 服务id
  21. Name string `json:"name" example:"标题"` // 标题
  22. Path string `json:"path" example:"/api/list"` // 地址
  23. Action string `json:"type" example:"GET"` // 请求类型 GET PUT POST DELETE
  24. common.ControlBy `swaggerignore:"true"`
  25. }
  26. func (s *ServApiInsertReq) Generate(model *model.ServApi) {
  27. model.ServiceId = s.ServiceId
  28. model.Name = s.Name
  29. model.Path = s.Path
  30. model.Action = s.Action
  31. if s.ControlBy.UpdateBy != 0 {
  32. model.UpdateBy = s.UpdateBy
  33. }
  34. if s.ControlBy.CreateBy != 0 {
  35. model.CreateBy = s.CreateBy
  36. }
  37. }
  38. func (s *ServApiInsertReq) GetId() interface{} {
  39. return s.Id
  40. }
  41. // ServApiUpdateReq 功能更新请求参数
  42. type ServApiUpdateReq struct {
  43. Id int `uri:"id" swaggerignore:"true"` // 接口ID
  44. Name string `json:"name" example:"标题"` // 标题
  45. Path string `json:"path" example:"/api/list"` // 地址
  46. Action string `json:"type" example:"GET"` // 请求类型
  47. common.ControlBy `swaggerignore:"true"`
  48. }
  49. func (s *ServApiUpdateReq) Generate(model *model.ServApi) {
  50. model.Name = s.Name
  51. model.Path = s.Path
  52. model.Action = s.Action
  53. if s.ControlBy.UpdateBy != 0 {
  54. model.UpdateBy = s.UpdateBy
  55. }
  56. if s.ControlBy.CreateBy != 0 {
  57. model.CreateBy = s.CreateBy
  58. }
  59. }
  60. func (s *ServApiUpdateReq) GetId() interface{} {
  61. return s.Id
  62. }
  63. // ServApiGetReq 功能获取请求参数
  64. type ServApiGetReq struct {
  65. Id int `uri:"id"`
  66. }
  67. func (s *ServApiGetReq) GetId() interface{} {
  68. return s.Id
  69. }
  70. // ServApiDeleteReq 功能删除请求参数
  71. type ServApiDeleteReq struct {
  72. Ids []int `json:"ids"`
  73. common.ControlBy `swaggerignore:"true"`
  74. }
  75. func (s *ServApiDeleteReq) GetId() interface{} {
  76. return s.Ids
  77. }
  78. // ServApiListByMenuId 获取菜单关联api列表
  79. type ServApiListByMenuId struct {
  80. MenuId int `search:"type:exact;column:menu_id;table:app_api"`
  81. }
  82. func (m *ServApiListByMenuId) GetNeedSearch() interface{} {
  83. return *m
  84. }
  85. // ServApiListByIds 功能获取请求参数
  86. type ServApiListByIds struct {
  87. ServiceId int `search:"type:exact;column:service_id;table:serv_api"` // 服务id
  88. Ids []int `search:"type:in;column:id;table:serv_api"`
  89. }
  90. func (m *ServApiListByIds) GetNeedSearch() interface{} {
  91. return *m
  92. }