api.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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('register', 'AuthController@register'); //注册
  32. $api->post('auth_login', 'AuthController@authLogin'); //APP第三方授权登录(微信)
  33. $api->post('decrypt_phone', 'AuthController@decryptPhone'); //微信小程序获取手机号
  34. $api->post('h5_oauth', 'AuthController@h5Oauth'); //H5授权登录
  35. $api->post('mini_program', 'AuthController@miniProgram'); //微信小程序登录(微信)
  36. $api->get('mini_code', 'AuthController@miniCode'); //获取微信小程序 code
  37. });
  38. $api->group(['prefix' => 'index'], function ($api) {
  39. $api->get('all_region', 'IndexController@allRegion'); //全国省市区
  40. $api->get('helps', 'IndexController@helpList'); //帮助类型
  41. $api->get('answer', 'IndexController@answer'); //问题答案
  42. });
  43. /*
  44. |--------------------------------------------------------------
  45. | 需要 token 验证的接口 'middleware' => ['api.auth'] 读取的 config/api.php 'auth' => ['jwt' => 'Dingo\Api\Auth\Provider\JWT'], 所以 在 Kernel.php 找不到这个中间件
  46. |--------------------------------------------------------------
  47. */
  48. $api->group([
  49. 'middleware' => ['api.auth', 'throttle:120'],
  50. ], function ($api) {
  51. /* @var Dingo\Api\Routing\Router $api*/
  52. $api->post('auth/logout', 'AuthController@logout'); //退出登录
  53. $api->post('auth/forget_password', 'AuthController@forgetPassword'); //忘记密码
  54. $api->group(['prefix' => 'user'], function($api){
  55. /* @var Dingo\Api\Routing\Router $api*/
  56. $api->post('h5_bind', 'UserController@h5Bind'); //H5绑定
  57. $api->post('h5_rebind', 'UserController@h5Rebind'); //H5解绑
  58. $api->post('mini_program_bind', 'UserController@miniProgramBind'); //微信小程序绑定
  59. $api->post('mini_program_rebind', 'UserController@miniProgramReBind'); //微信小程序解绑
  60. $api->post('sms_bind', 'UserController@smsBind'); //手机号绑定
  61. $api->post('sms_rebind', 'UserController@smsReBind'); //手机号解绑
  62. $api->get('group_by_initial', 'UserController@groupByInitial'); //用户列表按照首字母分组排序,类似手机通讯录
  63. $api->post('feedback', 'UserController@feedback'); //问题反馈
  64. $api->get('info', 'UserController@info'); //用户信息
  65. $api->post('update', 'UserController@update'); //更新用户信息
  66. });
  67. });
  68. });