api.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <?php
  2. /*
  3. * This file is part of the Jiannei/lumen-api-starter.
  4. *
  5. * (c) Jiannei <longjian.huang@foxmail.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. use Illuminate\Support\Facades\Route;
  11. use Jiannei\Response\Laravel\Support\Facades\Response;
  12. /*
  13. |--------------------------------------------------------------------------
  14. | Application Routes
  15. |--------------------------------------------------------------------------
  16. |
  17. | Here is where you can register all of the routes for an application.
  18. | It is a breeze. Simply tell Lumen the URIs it should respond to
  19. | and give it the Closure to call when that URI is requested.
  20. |
  21. */
  22. /**
  23. * 基础业务模块
  24. */
  25. Route::group(['namespace' => 'Base', 'prefix' => 'base'], function () {
  26. //登录
  27. Route::post('/auth/login', 'AuthController@login');
  28. // Route::post('/auth/login-mobile', 'AuthController@mobileLogin');
  29. // Route::post('/auth/mobile-verification-code', 'AuthController@verificationCode');
  30. // Route::post('/auth/weapp/login', 'AuthController@weappLogin');
  31. // Route::post('/auth/register', 'AuthController@store');
  32. //上传文件
  33. Route::post('/common/upload', 'ResourceController@upload');
  34. //枚举
  35. Route::get('/common/enums', 'CommonController@enums');
  36. Route::post('/settings', 'SettingsController@settings');
  37. Route::get('/setting', 'SettingsController@setting');
  38. Route::group([
  39. 'middleware' => ['auth:api', 'auth.role:user']
  40. ], function () {
  41. Route::get('/auth/me', 'AuthController@me');
  42. Route::put('/auth/me', 'AuthController@update');
  43. Route::put('/auth/password', 'AuthController@changePassword');
  44. Route::get('/auth/logout', 'AuthController@logout');
  45. //微信小程序
  46. Route::post('/auth/weapp/user-info-sync', 'AuthController@weappUserInfoSync');
  47. Route::post('/auth/weapp/bind-mobile', 'AuthController@weappBindMobile');
  48. });
  49. });
  50. //
  51. ////Route::get('/page/home', 'PageController@home');
  52. ////Route::get('/page/navigations', 'PageController@navigations');
  53. ////Route::get('/page/articles', 'PageController@articles');
  54. ////Route::get('/page/article/{id}', 'PageController@article');
  55. ////Route::get('/page/navigation-article/{id}', 'PageController@navigationArticle');
  56. ////Route::post('/page/settings', 'PageController@settings');
  57. //
  58. //Route::group(['namespace' => 'CMS', 'prefix' => 'cms'], function () {
  59. //
  60. // //上传文件
  61. // Route::post('/common/upload', 'ResourceController@upload');
  62. //
  63. // //banner
  64. // Route::get('/banner', 'BannersController@index');
  65. // //导航
  66. // Route::get('/category', 'CategoriesController@index');
  67. // //文章
  68. // Route::get('/articles', 'ArticlesController@index');
  69. // Route::get('/article', 'ArticlesController@article');
  70. // Route::get('/article-lists', 'ArticlesController@lists');
  71. // Route::get('/article/{id}', 'ArticlesController@show');
  72. // //配置
  73. //
  74. // Route::get('/settings', 'SettingController@index');
  75. // Route::get('/setting', 'SettingController@show');
  76. //
  77. //// Route::group([
  78. //// 'middleware' => 'auth:api'
  79. //// ], function () {
  80. //// Route::get('/auth/me', 'AuthController@me');
  81. //// Route::put('/auth/me', 'AuthController@update');
  82. //// Route::get('/auth/logout', 'AuthController@logout');
  83. //// });
  84. //});
  85. ///**
  86. // * 视频接口
  87. // */
  88. Route::group(['namespace' => 'Course', 'prefix' => 'course'], function () {
  89. Route::get('/home', 'HomeController@index');
  90. //分类
  91. Route::get('/category/tree', 'CategoryController@tree');
  92. Route::get('/category/select-options', 'CategoryController@selectOptions');
  93. //视频列表
  94. Route::get('courses', 'CourseController@index');
  95. Route::get('course', 'CourseController@show');
  96. Route::group([
  97. 'middleware' => 'auth:api'
  98. ], function () {
  99. //订阅
  100. Route::post('course/subscribe', 'CourseController@subscribe');
  101. Route::get('/video', 'VideoController@show');
  102. Route::post('/video/look-record', 'VideoController@lookRecord');
  103. //附件
  104. Route::get('/attachs', 'AttachController@index');
  105. Route::get('/attach/download', 'AttachController@download');
  106. //观看记录
  107. Route::get('/course-look', 'CourseController@lookCourses');
  108. //评价
  109. Route::post('/comment', 'CommentController@store');
  110. Route::get('/comments', 'CommentController@index');
  111. Route::delete('/comment', 'CommentController@destroy');
  112. //订阅
  113. Route::get('/subscribes', 'SubscribeController@index');
  114. //收藏
  115. Route::get('/collects', 'CollectController@index');
  116. Route::post('/collect', 'CollectController@store');
  117. Route::delete('/collect', 'CollectController@destroy');
  118. //笔记
  119. Route::post('/node', 'NodeController@store');
  120. Route::get('/nodes', 'NodeController@index');
  121. Route::get('/node', 'NodeController@show');
  122. Route::delete('/node', 'NodeController@destroy');
  123. });
  124. });
  125. /**
  126. * 通知公告
  127. */
  128. Route::group([
  129. 'prefix' => 'info',
  130. 'namespace' => 'Info'
  131. ], function () {
  132. //新闻管理
  133. Route::get('/news', 'NewsController@index');
  134. Route::post('/new', 'NewsController@store');
  135. //通知公告
  136. Route::get('/notices', 'NoticeController@index');
  137. Route::post('/notice', 'NoticeController@store');
  138. //资讯类型
  139. Route::get('/info_types', 'InformationTypeController@index');
  140. //资讯内容
  141. Route::get('/infos', 'InformationController@index');
  142. Route::get('/info', 'InformationController@show');
  143. });
  144. //
  145. ///**
  146. // * 试卷
  147. // */
  148. //Route::group(['namespace' => 'Exam', 'prefix' => 'exam', 'middleware' => 'auth:api'], function () {
  149. // Route::get('/', 'PapersController@index');
  150. // Route::get('/info/{slug}', 'PapersController@show');
  151. // Route::get('/topic-select-options', 'TopicsController@selectOptions');
  152. // //提交考试结果
  153. // Route::post('/examination', 'PapersController@examination');
  154. //// Route::get('/', 'TopicsController@index');
  155. // Route::group([
  156. // 'middleware' => 'auth.role:teacher'
  157. // ], function () {
  158. // Route::post('/', 'PapersController@store');
  159. // Route::put('/{id}', 'PapersController@update');
  160. // Route::delete('/{id}', 'PapersController@destroy');
  161. // //批阅
  162. // Route::post('/examines', 'PapersController@examines');
  163. //
  164. // //试题
  165. // Route::get('/topic', 'TopicsController@index');
  166. // Route::get('/topic/{id}', 'TopicsController@show');
  167. // Route::post('/topic', 'TopicsController@store');
  168. // Route::put('/topic/{id}', 'TopicsController@update');
  169. // Route::delete('/topic/{id}', 'TopicsController@destroy');
  170. //
  171. // //学生考试记录
  172. // Route::delete('/result/{id}', 'PaperResultsController@destroy');
  173. // });
  174. //
  175. // Route::get('/result', 'PaperResultsController@index');
  176. // Route::get('/result/{id}', 'PaperResultsController@show');
  177. //});
  178. //
  179. //
  180. //Route::group(['prefix' => 'inform', 'namespace' => 'Inform'], function () {
  181. // //分类
  182. //// Route::get('category', 'CategoryController@index');
  183. //// Route::post('category', 'CategoryController@store');
  184. //// Route::get('category/{id}', 'CategoryController@show');
  185. //// Route::put('category/{id}', 'CategoryController@update');
  186. //// Route::delete('category/{id}', 'CategoryController@destroy');
  187. //// Route::post('category/delete', 'CategoryController@delete');
  188. //// Route::get('category-tree', 'CategoryController@tree');
  189. //// Route::get('category-user-tree', 'CategoryController@lists');
  190. //
  191. // //信息
  192. // Route::group([
  193. // 'middleware' => 'auth.role:teacher'
  194. // ], function () {
  195. // Route::post('/', 'InformationController@store');
  196. // Route::delete('/{id}', 'InformationController@destroy');
  197. // });
  198. // Route::get('/', 'InformationController@index');
  199. // Route::get('/info/{slug}', 'InformationController@show');
  200. // Route::post('/good', 'InformationController@good');
  201. //
  202. // // Route::put('information/{id}', 'InformationController@update');
  203. //// Route::post('information/delete', 'InformationController@delete');
  204. //// Route::get('information-user-messages', 'InformationController@userMessages');
  205. //// Route::post('information-read-messages', 'InformationController@readMessages');
  206. //});
  207. /**
  208. * 网址导航
  209. */
  210. //Route::group(['prefix' => 'navigation', 'namespace' => 'Navigation'], function () {
  211. // Route::get('/', 'HomeController@index');
  212. // Route::post('/search', 'HomeController@search');
  213. // Route::post('/click', 'HomeController@click');
  214. //
  215. // Route::group([
  216. // 'middleware' => ['auth:api', 'auth.role:user']
  217. // ], function () {
  218. // Route::post('/top', 'HomeController@top');
  219. // Route::delete('/top', 'HomeController@deleteTop');
  220. //
  221. // Route::post('/collection', 'HomeController@collection');
  222. // Route::post('/sort', 'HomeController@sortCategory');
  223. // Route::post('/sort-more', 'HomeController@sortMore');
  224. // Route::post('/sort-management', 'HomeController@sortManagement');
  225. //
  226. // Route::get('/category', 'CategoriesController@index');
  227. // Route::post('/category', 'CategoriesController@store');
  228. // Route::put('/category/{id}', 'CategoriesController@update');
  229. // Route::delete('/category/{id}', 'CategoriesController@destroy');
  230. // Route::get('/category/select-options', 'CategoriesController@selectOptions');
  231. //
  232. // Route::get('/website', 'WebsitesController@index');
  233. // Route::post('/website', 'WebsitesController@store');
  234. // Route::put('/website/{id}', 'WebsitesController@update');
  235. // Route::delete('/website/{id}', 'WebsitesController@destroy');
  236. // Route::get('/website/select-options', 'WebsitesController@selectOptions');
  237. // });
  238. //
  239. // Route::get('/organization', 'OrganizationsController@index');
  240. // Route::get('/organization/select-options', 'OrganizationsController@selectOptions');
  241. //
  242. //});
  243. Route::get('/', function () {
  244. if (config('app.debug')) {
  245. return Response::success([
  246. 'name' => config('app.name'),
  247. 'version' => app()->version(),
  248. 'ip' => getClientIp()
  249. ]);
  250. }
  251. return 'hello word!';
  252. });
  253. //开发环境接口
  254. Route::group(['prefix' => 'develop'], function () {
  255. //响应状态
  256. // Route::get('/http-status', 'DevelopController@httpStatus');
  257. Route::get('/t', 'ExampleController@test');
  258. Route::get('/init', 'ExampleController@init');
  259. });