api.js.tpl 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import service from '@/utils/request'
  2. {{- if not .OnlyTemplate}}
  3. // @Tags {{.StructName}}
  4. // @Summary 创建{{.Description}}
  5. // @Security ApiKeyAuth
  6. // @Accept application/json
  7. // @Produce application/json
  8. // @Param data body model.{{.StructName}} true "创建{{.Description}}"
  9. // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
  10. // @Router /{{.Abbreviation}}/create{{.StructName}} [post]
  11. export const create{{.StructName}} = (data) => {
  12. return service({
  13. url: '/{{.Abbreviation}}/create{{.StructName}}',
  14. method: 'post',
  15. data
  16. })
  17. }
  18. // @Tags {{.StructName}}
  19. // @Summary 删除{{.Description}}
  20. // @Security ApiKeyAuth
  21. // @Accept application/json
  22. // @Produce application/json
  23. // @Param data body model.{{.StructName}} true "删除{{.Description}}"
  24. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  25. // @Router /{{.Abbreviation}}/delete{{.StructName}} [delete]
  26. export const delete{{.StructName}} = (params) => {
  27. return service({
  28. url: '/{{.Abbreviation}}/delete{{.StructName}}',
  29. method: 'delete',
  30. params
  31. })
  32. }
  33. // @Tags {{.StructName}}
  34. // @Summary 批量删除{{.Description}}
  35. // @Security ApiKeyAuth
  36. // @Accept application/json
  37. // @Produce application/json
  38. // @Param data body request.IdsReq true "批量删除{{.Description}}"
  39. // @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
  40. // @Router /{{.Abbreviation}}/delete{{.StructName}} [delete]
  41. export const delete{{.StructName}}ByIds = (params) => {
  42. return service({
  43. url: '/{{.Abbreviation}}/delete{{.StructName}}ByIds',
  44. method: 'delete',
  45. params
  46. })
  47. }
  48. // @Tags {{.StructName}}
  49. // @Summary 更新{{.Description}}
  50. // @Security ApiKeyAuth
  51. // @Accept application/json
  52. // @Produce application/json
  53. // @Param data body model.{{.StructName}} true "更新{{.Description}}"
  54. // @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
  55. // @Router /{{.Abbreviation}}/update{{.StructName}} [put]
  56. export const update{{.StructName}} = (data) => {
  57. return service({
  58. url: '/{{.Abbreviation}}/update{{.StructName}}',
  59. method: 'put',
  60. data
  61. })
  62. }
  63. // @Tags {{.StructName}}
  64. // @Summary 用id查询{{.Description}}
  65. // @Security ApiKeyAuth
  66. // @Accept application/json
  67. // @Produce application/json
  68. // @Param data query model.{{.StructName}} true "用id查询{{.Description}}"
  69. // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
  70. // @Router /{{.Abbreviation}}/find{{.StructName}} [get]
  71. export const find{{.StructName}} = (params) => {
  72. return service({
  73. url: '/{{.Abbreviation}}/find{{.StructName}}',
  74. method: 'get',
  75. params
  76. })
  77. }
  78. // @Tags {{.StructName}}
  79. // @Summary 分页获取{{.Description}}列表
  80. // @Security ApiKeyAuth
  81. // @Accept application/json
  82. // @Produce application/json
  83. // @Param data query request.PageInfo true "分页获取{{.Description}}列表"
  84. // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
  85. // @Router /{{.Abbreviation}}/get{{.StructName}}List [get]
  86. export const get{{.StructName}}List = (params) => {
  87. return service({
  88. url: '/{{.Abbreviation}}/get{{.StructName}}List',
  89. method: 'get',
  90. params
  91. })
  92. }
  93. {{- if .HasDataSource}}
  94. // @Tags {{.StructName}}
  95. // @Summary 获取数据源
  96. // @Security ApiKeyAuth
  97. // @Accept application/json
  98. // @Produce application/json
  99. // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
  100. // @Router /{{.Abbreviation}}/find{{.StructName}}DataSource [get]
  101. export const get{{.StructName}}DataSource = () => {
  102. return service({
  103. url: '/{{.Abbreviation}}/get{{.StructName}}DataSource',
  104. method: 'get',
  105. })
  106. }
  107. {{- end}}
  108. {{- end}}
  109. // @Tags {{.StructName}}
  110. // @Summary 不需要鉴权的{{.Description}}接口
  111. // @Accept application/json
  112. // @Produce application/json
  113. // @Param data query {{.Package}}Req.{{.StructName}}Search true "分页获取{{.Description}}列表"
  114. // @Success 200 {object} response.Response{data=object,msg=string} "获取成功"
  115. // @Router /{{.Abbreviation}}/get{{.StructName}}Public [get]
  116. export const get{{.StructName}}Public = () => {
  117. return service({
  118. url: '/{{.Abbreviation}}/get{{.StructName}}Public',
  119. method: 'get',
  120. })
  121. }