api.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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', [
  14. 'namespace' => 'App\Http\Controllers\Api',
  15. 'middleware' => ['serializer:array','cors','activity_log','bindings']
  16. ], function ($api) {
  17. $api->group([
  18. 'middleware' => 'api.throttle',
  19. 'limit' => config('api.rate_limits.access.limit'),
  20. 'expires' => config('api.rate_limits.access.expires')
  21. ], function ($api) {
  22. /*
  23. |--------------------------------------------------------------
  24. | 登录相关
  25. |--------------------------------------------------------------
  26. */
  27. $api->group(['prefix' => 'login'], function ($api) {
  28. $api->post('/loginByMobile', 'AuthorizationsController@loginByMobile')->name('login.mobile');
  29. $api->post('/loginByPassword', 'AuthorizationsController@loginByAccountPassword')->name('login.password');
  30. $api->post('/forgetPassword', 'AuthorizationsController@forgetPassword')->name('login.forget');
  31. $api->post('/register', 'AuthorizationsController@register')->name('login.register');
  32. $api->get('/xieyi', 'AuthorizationsController@xieyi')->name('login.xieyi');
  33. });
  34. /*
  35. |--------------------------------------------------------------
  36. | 获取oss上传配置
  37. |--------------------------------------------------------------
  38. */
  39. $api->group(['prefix' => 'upload-config'], function ($api) {
  40. $api->get('/config', 'UploadConfigController@config')->name('upload.config');
  41. });
  42. /*
  43. |--------------------------------------------------------------
  44. | 发送短信验证码
  45. |--------------------------------------------------------------
  46. */
  47. $api->group(['prefix' => 'sms'], function ($api) {
  48. $api->get('/send', 'SmsController@send')->name('sms.send');
  49. });
  50. });
  51. //需要 token 验证的接口
  52. $api->group(['middleware' => 'api.auth'], function ($api) {
  53. /*
  54. |--------------------------------------------------------------
  55. | 用户信息相关
  56. |--------------------------------------------------------------
  57. */
  58. $api->group(['prefix' => 'user'], function ($api) {
  59. //设置性别
  60. $api->post('/checksex', 'UserController@checksex')->name('user.checksex');
  61. //设置资料(初次注册进入时)
  62. $api->post('/setinfo', 'UserController@setinfo')->name('user.setinfo');
  63. $api->get('/getinfo', 'UserController@getinfo')->name('user.getinfo');
  64. $api->get('/getext', 'UserController@getext')->name('user.getext');
  65. });
  66. /*
  67. |--------------------------------------------------------------
  68. | 退出登录
  69. |--------------------------------------------------------------
  70. */
  71. $api->put('/logout', 'AuthorizationsController@logout')->name('logout');
  72. });
  73. });