Controller.tpl 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace App\{module}\Controllers;
  3. use App\{module}\Services\{action}Service;
  4. use App\Base\Controllers\Controller;
  5. use Illuminate\Http\Request;
  6. class {action}Controller extends Controller
  7. {
  8. private $service;
  9. /**
  10. * {action}Controller constructor.
  11. * @param {action}Service $service
  12. */
  13. public function __construct({action}Service $service)
  14. {
  15. $this->service = $service;
  16. }
  17. /**
  18. * @param string name 主页名称
  19. * @param int page_size 每页显示数量
  20. * @param int page 当前页
  21. * @return array
  22. * @throws \App\Base\Exceptions\ApiException
  23. * @throws
  24. * @api get (接口路径) (接口名称)
  25. * @group (接口分组)
  26. * @successExample
  27. */
  28. public function lists(Request $request)
  29. {
  30. return $this->service->lists($request);
  31. }
  32. /**
  33. * @param (参数类型) (参数字段) (描述)
  34. * @return mixed
  35. * @throws \App\Base\Exceptions\ApiException
  36. * @api post (接口路径) (接口名称)
  37. * @group (接口分组)
  38. * @successExample
  39. * {"ret":0,"msg":"success","data":1}
  40. */
  41. public function saveInfo(Request $request){
  42. return $this->service->saveInfo($request);
  43. }
  44. /**
  45. * @param (参数类型) (参数字段) (描述)
  46. * @return bool
  47. * @throws \App\Base\Exceptions\ApiException
  48. * @api post (接口路径) (接口名称)
  49. * @group (接口分组)
  50. * @successExample
  51. * {"ret":0,"msg":"success","data":1}
  52. */
  53. public function changeStatus(Request $request){
  54. return $this->service->changeStatus($request);
  55. }
  56. /**
  57. * @param int id required
  58. * @return \App\Base\Models\BaseModel|array|void
  59. * @api post (接口路径) (接口名称)
  60. * @group (接口分组)
  61. * @successExample
  62. */
  63. public function detail(Request $request){
  64. parent::detail($request);
  65. return $this->service->detail($request);
  66. }
  67. /**
  68. * @param array ids ids required
  69. * @return int
  70. * @api delete (接口路径) (接口名称)
  71. * @group (接口分组)
  72. * @successExample
  73. * {"ret":0,"msg":"success.","data":1}
  74. */
  75. public function deleteInfo(Request $request){
  76. parent::deleteInfo($request);
  77. return $this->service->deleteInfo($request);
  78. }
  79. }