report_profiles_controller.rb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. class ReportProfilesController < ApplicationController
  2. prepend_before_action { authentication_check(permission: 'admin.report_profile') }
  3. =begin
  4. Format:
  5. JSON
  6. Example:
  7. {
  8. "id":1,
  9. "name":"some report_profile",
  10. "condition":{"c_a":1,"c_b":2},
  11. "updated_at":"2012-09-14T17:51:53Z",
  12. "created_at":"2012-09-14T17:51:53Z",
  13. "updated_by_id":2.
  14. "created_by_id":2,
  15. }
  16. =end
  17. =begin
  18. Resource:
  19. GET /api/report_profiles.json
  20. Response:
  21. [
  22. {
  23. "id": 1,
  24. "name": "some_name1",
  25. ...
  26. },
  27. {
  28. "id": 2,
  29. "name": "some_name2",
  30. ...
  31. }
  32. ]
  33. Test:
  34. curl http://localhost/api/report_profiles.json -v -u #{login}:#{password}
  35. =end
  36. def index
  37. model_index_render(Report::Profile, params)
  38. end
  39. =begin
  40. Resource:
  41. GET /api/report_profiles/#{id}.json
  42. Response:
  43. {
  44. "id": 1,
  45. "name": "name_1",
  46. ...
  47. }
  48. Test:
  49. curl http://localhost/api/report_profiles/#{id}.json -v -u #{login}:#{password}
  50. =end
  51. def show
  52. model_show_render(Report::Profile, params)
  53. end
  54. =begin
  55. Resource:
  56. POST /api/report_profiles.json
  57. Payload:
  58. {
  59. "name":"some report_profile",
  60. "condition":{"c_a":1,"c_b":2},
  61. }
  62. Response:
  63. {
  64. "id": 1,
  65. "name": "some_name",
  66. ...
  67. }
  68. Test:
  69. curl http://localhost/api/report_profiles.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X POST -d '{"name": "some_name","active": true, "note": "some note"}'
  70. =end
  71. def create
  72. model_create_render(Report::Profile, params)
  73. end
  74. =begin
  75. Resource:
  76. PUT /api/report_profiles/{id}.json
  77. Payload:
  78. {
  79. "name":"some report_profile",
  80. "condition":{"c_a":1,"c_b":2},
  81. }
  82. Response:
  83. {
  84. "id": 1,
  85. "name": "some_name",
  86. ...
  87. }
  88. Test:
  89. curl http://localhost/api/report_profiles.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X PUT -d '{"name": "some_name","active": true, "note": "some note"}'
  90. =end
  91. def update
  92. model_update_render(Report::Profile, params)
  93. end
  94. =begin
  95. Resource:
  96. DELETE /api/report_profiles/{id}.json
  97. Response:
  98. {}
  99. Test:
  100. curl http://localhost/api/report_profiles.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X DELETE
  101. =end
  102. def destroy
  103. model_destroy_render(Report::Profile, params)
  104. end
  105. end