api.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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('email/send', 'EmailController@sendEmailCode'); //发送邮箱验证码
  23. $api->post('email/email_verify', 'EmailController@emailVerify'); //验证码验证
  24. $api->post('attachments/upload', 'AttachmentController@upload'); //上传附件
  25. $api->delete('attachments/{uid}', 'AttachmentController@delete'); //删除附件
  26. $api->post('reset_password', 'AuthController@forgetPassword'); //用户找回密码
  27. $api->post('find_id', 'AuthController@findId'); //用户找回ID
  28. $api->get('captcha', 'AuthController@captcha'); // 图形二维码
  29. $api->get('privacy', 'IndexController@privacyPolice'); //隐私政策
  30. $api->get('agreement', 'IndexController@userAgreement'); //用户协议
  31. $api->get('aboutus', 'IndexController@aboutus'); //关于我们
  32. $api->get('filter_type_list', 'ProductController@filterTypeList'); //产品类型(分类)
  33. $api->get('upload_type_list', 'ProductController@uploadTypeList'); //产品类型(上传)
  34. });
  35. $api->group(['prefix' => 'auth'], function ($api) {
  36. $api->post('register', 'AuthController@register'); //注册
  37. $api->post('login', 'AuthController@login'); //账号密码登录
  38. $api->post('smslogin', 'AuthController@loginBySmsCode'); //短信验证码登录
  39. $api->get('forget_password', 'AuthController@forgetPassword'); //忘记密码
  40. });
  41. $api->group(['prefix' => 'index'], function ($api) {
  42. $api->get('product_list', 'ProductController@productList'); //首页产品列表
  43. });
  44. // 系统设置
  45. $api->group(['prefix' => 'settings'], function ($api) {
  46. $api->get('notice_policy', 'SettingsController@noticePolicy'); //公告|政策
  47. $api->get('record', 'SettingsController@record'); //备案信息
  48. $api->get('clause', 'SettingsController@clause'); //条款
  49. $api->get('law', 'SettingsController@law'); //法律声明
  50. $api->get('copyright', 'SettingsController@copyright'); //版权
  51. });
  52. /*
  53. |--------------------------------------------------------------
  54. | 需要 token 验证的接口 'middleware' => ['api.auth'] 读取的 config/api.php 'auth' => ['jwt' => 'Dingo\Api\Auth\Provider\JWT'], 所以 在 Kernel.php 找不到这个中间件
  55. |--------------------------------------------------------------
  56. */
  57. $api->group([
  58. 'middleware' => ['api.auth', 'throttle:120'],
  59. ], function ($api) {
  60. $api->get('logout', 'AuthController@logout')->name('logout'); //退出登录
  61. $api->post('auth/forget_password', 'AuthController@forgetPassword'); //忘记密码
  62. // 用户
  63. $api->group(['prefix' => 'users'], function($api){
  64. $api->get('show', 'UserController@show'); //根据用户id查询用户数据
  65. $api->post('up_user_info', 'UserController@upUserInfo'); //修改用户信息
  66. $api->delete('destroy', 'UserController@destroy'); //删除用户信息
  67. $api->post('avatar', 'UserController@avatar'); //上传头像接口
  68. $api->get('add_follow', 'UserController@addFollow'); //添加关注
  69. $api->get('cancelFollow', 'UserController@cancelFollow'); //添加关注
  70. $api->get('group_by_initial', 'UserController@groupByInitial'); //用户列表按照首字母分组排序
  71. $api->post('accountStop', 'UserController@accountStop'); //账号停用
  72. $api->post('accountOpen', 'UserController@accountOpen'); //账号启用
  73. });
  74. // 产品
  75. $api->group(['prefix' => 'product'], function($api){
  76. $api->post('add_product', 'ProductController@addProduct'); //添加产品
  77. $api->delete('del_product', 'ProductController@delProduct'); //删除产品
  78. $api->get('user_product_list', 'ProductController@userProductList'); //我的产品列表
  79. $api->get('product_detail', 'ProductController@productDetail'); //产品详情
  80. $api->get('add_collect', 'ProductController@addCollect'); //添加收藏
  81. $api->get('cancel_collect', 'ProductController@cancelCollect'); //取消收藏
  82. $api->get('add_like', 'ProductController@addLike'); //喜欢产品
  83. $api->get('collect_list', 'ProductController@collectList'); //收藏列表
  84. $api->get('report_list', 'ProductController@reportList'); //举报列表
  85. $api->post('report', 'ProductController@report'); //举报图片
  86. $api->get('getProductRecommend', 'ProductController@getProductRecommend'); //获取推荐数据
  87. });
  88. // 消息
  89. $api->group(['prefix' => 'msg'], function($api){
  90. $api->get('msg_list', 'MsgController@msgList'); //消息列表
  91. $api->get('msg_detail', 'MsgController@msgDetail'); //消息详情
  92. $api->get('getNewMsgState', 'MsgController@getNewMsgState'); //消息详情
  93. });
  94. // 会员
  95. $api->group(['prefix' => 'member'], function($api){
  96. $api->get('member_list', 'MemberController@memberList'); //会员价格
  97. $api->post('join_member', 'MemberController@joinMember'); //加入会员
  98. });
  99. // 文件夹
  100. $api->group(['prefix' => 'folder'], function($api){
  101. $api->post('add_folder', 'UserFolderController@addFolder'); //新建文件夹
  102. $api->get('folder_list', 'UserFolderController@folderList'); //文件夹列表
  103. $api->get('folder_detail', 'UserFolderController@folderDetail'); //文件夹详情
  104. $api->post('edit_folder', 'UserFolderController@editFolder'); //编辑文件夹
  105. $api->post('move_file', 'UserFolderController@moveFile'); //移动文件
  106. $api->get('image_list', 'UserFolderController@imageList'); //图片列表
  107. });
  108. // 支付
  109. $api->group(['prefix' => 'pay'], function($api){
  110. $api->get('payment', 'PayController@payment'); //构建支付
  111. });
  112. });
  113. });