api.php
18.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<?php
/**
* @var $api \Dingo\Api\Routing\Router
*/
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', ['namespace' => 'App\Http\Api\V1\Controllers', 'middleware' => ['cors','access-record']], function ($api) {
/*
|-------------------------------------------------------------------------------------------------------------------
| 调试类
|-------------------------------------------------------------------------------------------------------------------
*/
$api->any('test1', 'ToolsController@test1');
$api->any('express', 'ToolsController@express');
/*
|-------------------------------------------------------------------------------------------------------------------
| 工具类
|-------------------------------------------------------------------------------------------------------------------
*/
$api->any('language', 'LanguageController@setLocale');
/*
|-------------------------------------------------------------------------------------------------------------------
| 短信消息通知回调
|-------------------------------------------------------------------------------------------------------------------
*/
$api->any('sms-notify', 'SmsController@notify')->name('sms.notify'); //
/*
|-------------------------------------------------------------------------------------------------------------------
| 订单支付回调:在三方平台支付成功后,回调处理
|-------------------------------------------------------------------------------------------------------------------
*/
$api->any('pay/notify/{type}', 'RechargeOrdersController@notifyPay')->name('pay.notify');
/*
|-------------------------------------------------------------------------------------------------------------------
| 微信授权相关:包含小程序和公众号
|-------------------------------------------------------------------------------------------------------------------
*/
// $api->group(['prefix' => 'wechat'], function ($api) {
// $controller = 'WechatController';
// $prefix = 'wechat';
// $api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid
// $api->any('mini-authorized-login', $controller .'@authorizeLoginMini')->name($prefix .'.authorize.Login');// 小程序 授权登录
// $api->any('mini-phone', $controller .'@getMiniPhone')->name($prefix .'.phone');// 获取小程序用户手机号
//
//
// $api->post('auth/token', $controller .'@authLogin')->name($prefix .'.login');// 微信授权登录:根据 method 判断登录方式
// $api->post('auth/token/nickname', $controller .'@authLoginByNickname')->name($prefix .'.auth.nickname');// 小程序昵称授权
// $api->post('auth/token/mobile', $controller .'@authLoginByMobile')->name($prefix .'.auth.mobile');// 小程序手机号授权
//
// $api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid
// $api->any('login-with-nickname', $controller .'@authorizeLoginByNickname')->name($prefix .'.authorize.Login');// 小程序 授权登录
// $api->any('login-with-mobile', $controller .'@authorizeLoginByMobile')->name($prefix .'.phone');// 获取小程序用户手机号
//
// $api->any('mini-user', $controller .'@getMiniUserInfo')->name($prefix .'.user.info'); // 获取微信用户信息
// $api->any('mini-decrypt', $controller .'@decrypt')->name($prefix .'decrypt'); // 解密
// $api->any('token', $controller .'@token')->name($prefix .'.token');// 验证 token
// $api->any('jssdk', $controller .'@jssdk')->name($prefix .'.jssdk');// 验证 token
// $api->any('auth', $controller.'@auth')->name($prefix.'.authorize'); // 授权
// $api->get('openid', $controller .'@initOpenid')->name($prefix .'.openid')->middleware('check.xcx.user');// 验证 token
// $api->post('authorized-login', $controller .'@authorizeLogin')->name($prefix .'.authorize.Login')->middleware('check.xcx.user');// 授权登录
// $api->post('openid', $controller .'@getOpenid')->name($prefix .'.user.openid')->middleware('check.xcx.user'); // 列表
// $api->post('user', $controller .'@getWxUserInfo')->name($prefix .'.user.info'); // 列表
// $api->post('server', $controller .'@server')->name($prefix .'.server');
// $api->get('server', $controller .'@server')->name($prefix .'.server');
// });
/*
|-------------------------------------------------------------------------------------------------------------------
| 用户信息
|-------------------------------------------------------------------------------------------------------------------
*/
$api->group(['namespace' => 'User'], function ($api) {
/*
|---------------------------------------------------------------------------------------------------------------
| 用户模块
|---------------------------------------------------------------------------------------------------------------
*/
# 定义前缀
$api->group(['prefix' => 'users',], function ($api) {
// 用户信息
$api->get('{id}', 'UsersController@show')->where('id', '[0-9]+');
$api->get('detail', 'UsersController@detail');
});
});
/*
|-------------------------------------------------------------------------------------------------------------------
| 首页
|-------------------------------------------------------------------------------------------------------------------
*/
$api->any('home', 'HomesController@home')->name('home');
/*
|-------------------------------------------------------------------------------------------------------------------
| 工具类
|-------------------------------------------------------------------------------------------------------------------
*/
$api->group(['prefix' => 'utils'], function ($api) {
$api->any('address', 'UtilsController@address');//
});
/*
|-------------------------------------------------------------------------------------------------------------------
| 登录、注册、忘记密码 模块:微信授权相关,包含小程序和公众号
|-------------------------------------------------------------------------------------------------------------------
*/
$api->group(['prefix' => 'auth'], function ($api) {
$api->post('token', 'AuthController@login');// 登录:根据 method 判断登录方式
$api->post('user', 'AuthController@register');// 注册
$api->post('login/quick', 'AuthController@loginQuick');// 快捷登录
$api->post('password/reset', 'AuthController@resetPassword');// 重置密码
$api->post('password/retrieve', 'AuthController@retrievePassword');// 找回密码
});
$api->post('sms-code', 'SmsController@store');// 发送验证码,用户注册:type1
// $api->group(['middleware' => ['web','wechat.oauth']], function ($api) {
// $api->post('auth', 'AuthController@wechatAuth')->name('user.authorize'); // 授权
// $api->post('official-account', 'AuthController@wechatAuth')->name('user.authorize'); // 授权
// $api->any('register', 'AuthController@register');// 注册
// });
//
$api->group(['middleware' => ['web']], function ($api) {
$api->any('auth', 'AuthController@wechatAuth')->name('user.authorize'); // 授权
$api->post('official-account', 'AuthController@wechatAuth')->name('user.authorize'); // 授权
$api->any('register', 'AuthController@register');// 注册
});
/*
|-------------------------------------------------------------------------------------------------------------------
| 需要用户登录后才能操作
|-------------------------------------------------------------------------------------------------------------------
*/
$api->group(['middleware' => 'jwt.api.auth'], function ($api) {
/*
|---------------------------------------------------------------------------------------------------------------
| 登出
|---------------------------------------------------------------------------------------------------------------
*/
$api->post('logout', 'AuthController@logout');
$api->delete('auth/token', 'AuthController@logout');
/*
|---------------------------------------------------------------------------------------------------------------
| 用户模块
|---------------------------------------------------------------------------------------------------------------
*/
$api->group(['namespace' => 'User'], function ($api) {
/*
|-----------------------------------------------------------------------------------------------------------
| 用户模块
|-----------------------------------------------------------------------------------------------------------
*/
# 定义前缀
$api->group(['prefix' => 'users',], function ($api) {
// 用户信息
$api->get('me', 'UsersController@me'); // 我的信息
$api->put('me', 'UsersController@updateMe'); // 更新我的信息
$api->post('me', 'UsersController@submitMe'); // 游客-提交我的信息
$api->any('account', 'UsersController@changeAccount'); // 更新我的账号
// 我的钱包
$api->get('wallet', 'UsersController@myWallet');
// 我的团队
$api->get('team-count', 'UsersController@myTeamCount');
$api->get('team', 'UsersController@myTeam');
$api->get('commissions', 'UsersController@myCommissions');
$api->get('withdrawals', 'UsersController@myWithdrawals');
$api->post('withdrawals', 'UsersController@withdrawal');
// 收藏
$api->get('favorites', 'UsersController@favorites');
// 反馈
$api->get('feedbacks', 'UsersController@myFeedbacks');
// 消息
$api->get('notifications', 'UsersController@myNotifications');
$api->get('notifications-unread-count', 'UsersController@myUnreadNotificationsCount');
// 次数记录
$api->get('times-records', 'UsersController@myTimesRecords');
// 聊天记录
$api->get('chat-records', 'UsersController@myChatRecords');
// 聊天记录
$api->put('chat-records/cleared', 'UsersController@clearMyChatRecords');
});
/*
|-----------------------------------------------------------------------------------------------------------
| 用户地址模块
|-----------------------------------------------------------------------------------------------------------
*/
# 定义前缀
$api->group(['prefix' => 'user-addresses'], function ($api) {
$api->put('{id}/default', 'UserAddressesController@setDefault'); // 设置默认
});
$api->resource('user-addresses', 'UserAddressesController');
});
/*
|---------------------------------------------------------------------------------------------------------------
| 系统相关
|---------------------------------------------------------------------------------------------------------------
*/
$api->group(['namespace' => 'System'], function ($api) {
/*
|-----------------------------------------------------------------------------------------------------------
| 系统参数相关
|-----------------------------------------------------------------------------------------------------------
*/
$api->group(['prefix' => 'system-configs'], function ($api) {
$api->get('options', 'ConfigsController@options'); // options
});
/*
|-----------------------------------------------------------------------------------------------------------
| 系统参数相关
|-----------------------------------------------------------------------------------------------------------
*/
$api->get('system-setting', 'SettingsController@setting');
$api->group(['prefix' => 'system-setting'], function ($api) {
$api->get('options', 'SettingsController@options'); // options
});
/*
|-----------------------------------------------------------------------------------------------------------
| 系统轮播图
|-----------------------------------------------------------------------------------------------------------
*/
$api->group(['prefix' => 'system-banners'], function ($api) {
$api->get('', 'SystemBannersController@all');
});
$api->get('system-banks', 'SystemsController@banks');
});
// /*
// |---------------------------------------------------------------------------------------------------------------
// | 分类 模块
// |---------------------------------------------------------------------------------------------------------------
// */
// # 定义前缀
// $api->group(['prefix' => 'categories'], function ($api) {
// //
// $api->get('{id}/examples', 'CategoriesController@examples');
//
// });
// $api->resource('categories', 'CategoriesController');
/*
|-----------------------------------------------------------------------------------------------------------
| 意见反馈
|-----------------------------------------------------------------------------------------------------------
*/
$api->resource('feedbacks', 'FeedbacksController');
// /*
// |---------------------------------------------------------------------------------------------------------------
// | 广告 模块
// |---------------------------------------------------------------------------------------------------------------
// */
// # 定义前缀
// $api->group(['prefix' => 'advertisements'], function ($api) {
// //
// $api->get('latest', 'AdvertisementsController@latest');
// });
//// $api->resource('advertisements', 'AdvertisementsController');
//
// /*
// |---------------------------------------------------------------------------------------------------------------
// | 帮助中心 模块
// |---------------------------------------------------------------------------------------------------------------
// */
//// $api->resource('help-centers', 'HelpCentersController');
// $api->group(['prefix' => 'help-centers'], function ($api) {
// $api->get('latest', 'HelpCentersController@latest');
// });
/*
|---------------------------------------------------------------------------------------------------------------
| 充值包 模块
|---------------------------------------------------------------------------------------------------------------
*/
$api->group(['prefix' => 'recharge-packages'], function ($api) {
$api->post('{id}/orders', 'RechargePackagesController@recharge');
});
/*
|---------------------------------------------------------------------------------------------------------------
| 聊天 模块
|---------------------------------------------------------------------------------------------------------------
*/
$api->group(['prefix' => 'chat-records'], function ($api) {
$api->post('{id}/items', 'ChatRecordsController@chat');
$api->post('{id}/items/stream', 'ChatRecordsController@chatStream');
$api->get('{id}/items', 'ChatRecordsController@items');
$api->post('stream', 'ChatRecordsController@stream');
$api->get('latest/timeout', 'ChatRecordsController@latestTimeout');
$api->get('latest', 'ChatRecordsController@latest');
});
$api->resource('chat-records', 'ChatRecordsController');
});
/*
|-------------------------------------------------------------------------------------------------------------------
| 系统相关
|-------------------------------------------------------------------------------------------------------------------
*/
$api->group(['namespace' => 'System'], function ($api) {
$api->get('system-configs/options', 'ConfigsController@options'); // options
$api->group(['prefix' => 'system-configs'], function ($api) {
$api->get('express-companies', 'ConfigsController@expressCompanies');
});
});
/*
|-------------------------------------------------------------------------------------------------------------------
| 分类 模块
|-------------------------------------------------------------------------------------------------------------------
*/
# 定义前缀
$api->group(['prefix' => 'categories'], function ($api) {
//
$api->get('{id}/examples', 'CategoriesController@examples');
$api->get('{id}/labels', 'CategoriesController@labels');
});
$api->resource('categories', 'CategoriesController');
/*
|---------------------------------------------------------------------------------------------------------------
| 广告 模块
|---------------------------------------------------------------------------------------------------------------
*/
# 定义前缀
$api->group(['prefix' => 'advertisements'], function ($api) {
//
$api->get('latest', 'AdvertisementsController@latest');
});
$api->resource('advertisements', 'AdvertisementsController');
/*
|---------------------------------------------------------------------------------------------------------------
| 帮助中心 模块
|---------------------------------------------------------------------------------------------------------------
*/
// $api->resource('help-centers', 'HelpCentersController');
$api->group(['prefix' => 'help-centers'], function ($api) {
$api->get('latest', 'HelpCentersController@latest');
});
/*
|---------------------------------------------------------------------------------------------------------------
| 充值包 模块
|---------------------------------------------------------------------------------------------------------------
*/
$api->resource('recharge-packages', 'RechargePackagesController');
$api->group(['prefix' => 'recharge-packages'], function ($api) {
$api->get('latest', 'RechargePackagesController@latest');
});
});