api.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | API Routes
  5. |--------------------------------------------------------------------------
  6. |
  7. | Here is where you can register API routes for your application. These
  8. | routes are loaded by the RouteServiceProvider within a group which
  9. | is assigned the "api" middleware group. Enjoy building your API!
  10. |
  11. */
  12. $api = app('Dingo\Api\Routing\Router');
  13. $api->version('v1', ['namespace' => 'App\Http\Controllers\V1'], function ($api) {
  14. /*
  15. |--------------------------------------------------------------
  16. | 不需要token验证的接口
  17. |--------------------------------------------------------------
  18. */
  19. $api->group([
  20. 'middleware' => ['throttle:120'], //代表1分钟内接口最高请求次数,超出返回 429: Too Many Attempts
  21. ], function ($api) {
  22. $api->post('sms/send', 'SmsController@send'); //发送手机验证码
  23. $api->post('email/send', 'SmsController@sendEmailCode'); //发送邮箱验证码
  24. $api->post('attachment/upload', 'AttachmentController@upload'); //上传附件
  25. $api->post('attachment/delete', 'AttachmentController@delete'); //删除附件
  26. $api->get('privacy', 'IndexController@privacyPolice'); //隐私政策
  27. $api->get('agreement', 'IndexController@userAgreement'); //用户协议
  28. });
  29. $api->group(['prefix' => 'auth'], function ($api) {
  30. $api->post('login', 'AuthController@login'); //账号密码登录
  31. $api->post('wechat/minni/code', 'AuthController@wechatMiniCode'); //获取微信小程序 code
  32. $api->post('wechat/minni/phone', 'AuthController@wechatMiniPhone'); //获取微信小程序 code
  33. });
  34. $api->group(['prefix' => 'index'], function ($api) {
  35. $api->get('all_region', 'IndexController@allRegion'); //全国省市区
  36. $api->get('helps', 'IndexController@helpList'); //帮助类型
  37. $api->get('answer', 'IndexController@answer'); //问题答案
  38. });
  39. // 相关设置
  40. $api->group(['prefix' => 'setting'],function ($api){
  41. /* @var Dingo\Api\Routing\Router $api*/
  42. $api->get('login/banner', 'SettingController@loginBanner'); // banner
  43. $api->get('login/contact', 'SettingController@contact'); // contact
  44. });
  45. /*
  46. |--------------------------------------------------------------
  47. | 需要 token 验证的接口 'middleware' => ['api.auth'] 读取的 config/api.php 'auth' => ['jwt' => 'Dingo\Api\Auth\Provider\JWT'], 所以 在 Kernel.php 找不到这个中间件
  48. |--------------------------------------------------------------
  49. */
  50. $api->group([
  51. 'middleware' => ['api.auth', 'throttle:120'],
  52. ], function ($api) {
  53. /* @var Dingo\Api\Routing\Router $api*/
  54. $api->post('auth/logout', 'AuthController@logout'); //退出登录
  55. $api->post('auth/forget_password', 'AuthController@forgetPassword'); //忘记密码
  56. $api->group(['prefix' => 'user'], function($api){
  57. /* @var Dingo\Api\Routing\Router $api*/
  58. $api->post('h5_bind', 'UserController@h5Bind'); //H5绑定
  59. $api->post('h5_rebind', 'UserController@h5Rebind'); //H5解绑
  60. $api->post('mini_program_bind', 'UserController@miniProgramBind'); //微信小程序绑定
  61. $api->post('mini_program_rebind', 'UserController@miniProgramReBind'); //微信小程序解绑
  62. $api->post('sms_bind', 'UserController@smsBind'); //手机号绑定
  63. $api->post('sms_rebind', 'UserController@smsReBind'); //手机号解绑
  64. $api->get('group_by_initial', 'UserController@groupByInitial'); //用户列表按照首字母分组排序,类似手机通讯录
  65. $api->post('feedback', 'UserController@feedback'); //问题反馈
  66. $api->get('info', 'UserController@info'); //用户信息
  67. $api->post('update', 'UserController@update'); //更新用户信息
  68. });
  69. // 相关设置
  70. $api->group(['prefix' => 'setting'],function ($api){
  71. /* @var Dingo\Api\Routing\Router $api*/
  72. $api->get('index/banner', 'SettingController@indexBanner'); // banner
  73. });
  74. // 产品
  75. $api->group(['prefix' => 'product'],function ($api){
  76. /* @var Dingo\Api\Routing\Router $api*/
  77. $api->get('cate', 'ProductController@cate');
  78. $api->get('search', 'ProductController@search');
  79. $api->get('{id}/detail', 'ProductController@detail');
  80. $api->post('{id}/viewer', 'ProductController@viewer');
  81. $api->post('{id}/download', 'ProductController@download');
  82. });
  83. // 展厅案例
  84. $api->group(['prefix' => 'cases'],function ($api){
  85. /* @var Dingo\Api\Routing\Router $api*/
  86. $api->get('search', 'CasesController@search');
  87. $api->get('{id}/detail', 'CasesController@detail');
  88. $api->post('{id}/viewer', 'CasesController@viewer');
  89. });
  90. });
  91. });