api.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. use Illuminate\Http\Request;
  3. use Illuminate\Support\Facades\Route;
  4. use App\Http\Controllers\LoginController;
  5. use App\Http\Controllers\CateController;
  6. use App\Http\Controllers\CourseController;
  7. use App\Http\Controllers\CollectionController;
  8. /*
  9. |--------------------------------------------------------------------------
  10. | API Routes
  11. |--------------------------------------------------------------------------
  12. |
  13. | Here is where you can register API routes for your application. These
  14. | routes are loaded by the RouteServiceProvider within a group which
  15. | is assigned the "api" middleware group. Enjoy building your API!
  16. |
  17. */
  18. //
  19. //Route::middleware('auth:api')->get('/user', function (Request $request) {
  20. // return $request->user();
  21. //});
  22. $api = app('Dingo\Api\Routing\Router');
  23. //这里的version是版本,里面的v1是在env里面定义好的。
  24. $api->version('v1', function($api) {
  25. $api->get('gzh', function(){
  26. return view('gzh');
  27. });
  28. $api->get('dist', function(){
  29. return view('dist');
  30. });
  31. $api->group(['prefix'=>'login'], function ($api) {
  32. $api->post('login', [LoginController::class,'login'])->name('login');
  33. $api->post('register', [LoginController::class,'register']);
  34. $api->group(['middleware' => 'auth:users'],function($api){
  35. $api->get('logout', [LoginController::class,'logout']);
  36. $api->get('user', [LoginController::class,'getAuthUser']);
  37. });
  38. });
  39. $api->group(['prefix'=>'collection'], function ($api) {
  40. $api->group(['middleware' => 'auth:users'],function($api){
  41. $api->get('getCollection', [CollectionController::class,'getCollection']);
  42. $api->post('addCollection', [CollectionController::class,'addCollection']);
  43. });
  44. });
  45. $api->group(['prefix'=>'course'], function ($api) {
  46. $api->group(['middleware' => 'auth:users'],function($api){
  47. $api->get('list', [CourseController::class,'list']);
  48. $api->get('current', [CourseController::class,'current']);
  49. });
  50. });
  51. $api->group(['prefix'=>'cate'], function ($api) {
  52. $api->group(['middleware' => 'auth:users'],function($api){
  53. $api->get('getCate', [CateController::class,'getCate']);
  54. });
  55. });
  56. // $api->group(['prefix'=>'article'], function ($api) {
  57. // $api->get('list', [ArticleController::class,'list']);
  58. // $api->get('detail', [ArticleController::class,'detail']);
  59. // $api->group(['middleware' => 'auth:users'],function($api){
  60. //// $api->group(['middleware' => 'check_token'],function($api){
  61. // $api->get('getDataInfo', [ArticleController::class,'getDataInfo']);
  62. // $api->post('like', [ArticleController::class,'like']);
  63. // $api->post('share', [ArticleController::class,'share']);
  64. // $api->post('read', [ArticleController::class,'read']);
  65. // $api->post('addComment', [ArticleController::class,'addComment']);
  66. // $api->get('getSignPackage', [ArticleController::class,'getSignPackage']);
  67. // $api->get('getArticleLike', [ArticleController::class,'getArticleLike']);
  68. // $api->get('getWetalkData', [ArticleController::class,'getWetalkData']);
  69. // $api->get('getAllWetalkComment', [ArticleController::class,'getAllWetalkComment']);
  70. // });
  71. // });
  72. $api->group(['prefix'=>'admin','namespace'=>'App\Http\Controllers\Admin'], function($api){
  73. $api->post('login','LoginController@login')->name('login');
  74. $api->post('register','LoginController@register');
  75. $api->post('refresh', 'LoginController@refresh')->name('refresh');
  76. $api->group(['middleware' => ['check_token','auth:admins']],function($api) {
  77. $api->get('getAuthUser', 'LoginController@getAuthUser');
  78. });
  79. $api->group(['middleware' => ['check_token','auth:admins']],function($api) {
  80. $api->get('getAuthUser', 'LoginController@getAuthUser');
  81. $api->get('list', 'LoginController@list');
  82. $api->post('delete', 'LoginController@delete');
  83. $api->post('edit', 'LoginController@edit');
  84. $api->post('logout', 'LoginController@logout');
  85. });
  86. $api->group(['prefix'=>'course'], function ($api) {
  87. $api->group(['middleware' => ['check_token','auth:admins']],function($api){//'check_token'
  88. $api->post('uploadAudio', 'CourseController@uploadAudio');
  89. $api->post('uploadImg', 'CourseController@uploadImg');
  90. $api->post('uploadVideo', 'CourseController@uploadVideo');
  91. $api->post('addCourse', 'CourseController@addCourse');
  92. $api->post('editCourse', 'CourseController@editCourse');
  93. $api->post('deleteCourse', 'CourseController@deleteCourse');
  94. $api->post('onlineCourse', 'CourseController@onlineCourse');
  95. $api->post('manyOnlineCourse', 'CourseController@manyOnlineCourse');
  96. $api->post('shareCourse', 'CourseController@shareCourse');
  97. $api->post('setTop', 'CourseController@setTop');
  98. $api->post('cancelTop', 'CourseController@cancelTop');
  99. $api->get('list', 'CourseController@list');
  100. $api->get('getCourseDetail', 'CourseController@getCourseDetail');
  101. });
  102. });
  103. $api->group(['prefix'=>'cate'], function ($api) {
  104. $api->group(['middleware' => ['check_token','auth:admins']],function($api){
  105. $api->post('addCate', 'CateController@addCate');
  106. $api->post('editCate', 'CateController@editCate');
  107. $api->post('deleteCate', 'CateController@deleteCate');
  108. $api->get('getOneCate', 'CateController@getOneCate');
  109. $api->get('getTwoCate', 'CateController@getTwoCate');
  110. $api->get('getCate', 'CateController@getCate');
  111. $api->post('uploadImg', 'CateController@uploadImg');
  112. });
  113. });
  114. $api->group(['prefix'=>'comment'], function ($api) {
  115. $api->group(['middleware' => ['check_token','auth:admins']],function($api){
  116. $api->get('list', 'CommentController@list');
  117. $api->post('auditComment', 'CommentController@auditComment');
  118. $api->post('deleteComment', 'CommentController@deleteComment');
  119. });
  120. });
  121. $api->group(['prefix'=>'data'], function ($api) {
  122. $api->group(['middleware' => ['check_token','auth:admins']],function($api){
  123. $api->get('index', 'DataController@index');
  124. $api->get('getCourseRead', 'DataController@getCourseRead');
  125. });
  126. });
  127. $api->group(['prefix'=>'author'], function ($api) {
  128. $api->group(['middleware' => ['check_token','auth:admins']],function($api){
  129. $api->get('getUserAvatar', 'AuthorController@getUserAvatar');
  130. $api->post('uploadAvatar', 'AuthorController@uploadAvatar');
  131. });
  132. });
  133. });
  134. });