api.php 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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','apiLogs'], //代表1分钟内接口最高请求次数,超出返回 429: Too Many Attempts
  21. ], function ($api) {
  22. $api->get('test', 'IndexController@index'); //用户配置信息
  23. $api->get('setting/{tags?}', 'SettingsController@get'); //用户配置信息
  24. $api->post('setting', 'SettingsController@set'); //设置用户信息
  25. $api->post('sms/send', 'SmsController@send'); //发送手机验证码
  26. $api->post('email/send', 'EmailController@sendEmailCode'); //发送邮箱验证码
  27. $api->post('attachments', 'AttachmentController@upload'); //上传附件
  28. $api->delete('attachments/{uid}', 'AttachmentController@delete'); //删除附件
  29. $api->get('reset-password', 'AuthController@forgetPassword'); //用户找回密码
  30. $api->get('privacy', 'IndexController@privacyPolice'); //隐私政策
  31. $api->get('agreement', 'IndexController@userAgreement'); //用户协议
  32. $api->get('aboutus', 'IndexController@aboutus'); //关于我们
  33. });
  34. $api->group(['prefix' => 'auth'], function ($api) {
  35. $api->post('register', 'AuthController@register'); //注册
  36. $api->post('login', 'AuthController@login'); //账号密码登录
  37. $api->post('smslogin', 'AuthController@loginBySmsCode'); //短信验证码登录
  38. $api->get('forget_password', 'AuthController@forgetPassword'); //忘记密码
  39. $api->post('oplogin', 'AuthController@authLogin'); //APP第三方授权登录(微信)
  40. $api->post('decrypt_phone', 'AuthController@decryptPhone'); //微信小程序获取手机号
  41. $api->post('mnplogin', 'AuthController@miniProgram'); //微信小程序登录(微信)
  42. $api->post('oalogin', 'AuthController@h5Oauth'); //H5授权登录[未实现]
  43. $api->get('minicode', 'AuthController@miniCode'); //获取微信小程序code[未实现]
  44. });
  45. $api->group(['prefix' => 'index'], function ($api) {
  46. $api->get('all_region', 'RegionController@allRegion'); //全国省市区
  47. $api->get('helps', 'ArticleController@helpList'); //帮助类型
  48. $api->get('answer', 'ArticleController@answer'); //问题答案
  49. });
  50. /*
  51. |--------------------------------------------------------------
  52. | 需要 token 验证的接口 'middleware' => ['api.auth'] 读取的 config/api.php 'auth' => ['jwt' => 'Dingo\Api\Auth\Provider\JWT'], 所以 在 Kernel.php 找不到这个中间件
  53. |--------------------------------------------------------------
  54. */
  55. $api->group([
  56. 'middleware' => ['api.auth', 'throttle:120','checkAuth','apiLogs'],
  57. ], function ($api) {
  58. $api->post('logout', 'AuthController@logout')->name('logout'); //退出登录
  59. $api->post('auth/forget_password', 'AuthController@forgetPassword'); //忘记密码
  60. $api->group(['prefix' => 'users'], function($api){
  61. //restful实例
  62. $api->get('/', 'UserController@index'); //获取用户列表数据
  63. $api->get('/{id}', 'UserController@show'); //根据用户id查询用户数据
  64. $api->post('/', 'UserController@create'); //新增用户
  65. $api->put('/{id}', 'UserController@update'); //修改用户信息
  66. $api->delete('/{id}', 'UserController@destroy'); //删除用户信息
  67. $api->post('/{id}/avatar', 'UserController@avatar'); //上传头像接口
  68. //[未实现:h5绑定、h5解绑;小程序绑定、小程序解绑]
  69. $api->post('bind_mobile', 'UserController@bindMobile'); //手机号绑定
  70. $api->post('rebind_mobile', 'UserController@bindMobile'); //手机号解绑
  71. $api->get('group_by_initial', 'UserController@groupByInitial'); //用户列表按照首字母分组排序,类似手机通讯录 ?
  72. $api->post('feedback', 'UserController@feedback'); //问题反馈 意见反馈
  73. });
  74. });
  75. $api->post('pay/alipay/notify', 'PayController@alipayNotify'); //支付宝支付回调
  76. $api->post('pay/wechatpay/notify', 'PayController@wechatpayNotify'); //微信支付回调
  77. });