| xqd
@@ -12,10 +12,12 @@ use Illuminate\Http\Request;
|
|
|
use App\Services\Base\ErrorCode;
|
|
|
class IndexController extends Controller
|
|
|
{
|
|
|
+
|
|
|
/**
|
|
|
- * @api {get} /api/index/hot 热门(hot)
|
|
|
- * @apiDescription 热门(hot)
|
|
|
+ * @api {get} /api/index/index 首页
|
|
|
+ * @apiDescription 首页
|
|
|
* @apiGroup Index
|
|
|
+ * @apiParam {string} type (热门)hot/(潮流)trend/(最新)news
|
|
|
* @apiPermission none
|
|
|
* @apiVersion 0.1.0
|
|
|
* @apiParam {int} [page=1] 页码(分页参数)
|
| xqd
@@ -30,18 +32,42 @@ class IndexController extends Controller
|
|
|
* "users": [ 动态用户
|
|
|
* 'news_num':2 新消息数目
|
|
|
* ],
|
|
|
- * "dreams": [
|
|
|
- * "care_num": 0, 关注人数
|
|
|
- * "time": 1222222, 梦想倒计时
|
|
|
- * "dream_imgs_first": {
|
|
|
- * "pic": "", 梦想封面图片
|
|
|
- * }
|
|
|
- * "dream_find_user": [
|
|
|
- * {
|
|
|
- * ... 发布梦想的用户信息
|
|
|
- * }
|
|
|
- * ],
|
|
|
- * ]
|
|
|
+ * "dreams": {
|
|
|
+ * "current_page": 1,
|
|
|
+ * "data": [
|
|
|
+ * {
|
|
|
+ * "dream": "signture",
|
|
|
+ * "about": "123568",
|
|
|
+ * "video": "",
|
|
|
+ * "money": 162,
|
|
|
+ * "time": 2666,
|
|
|
+ * "get_money": 0,
|
|
|
+ * "status": 0,
|
|
|
+ * "updated_at": "2017-06-21 10:51:20",
|
|
|
+ * "dream_find_user": [
|
|
|
+ * {
|
|
|
+ * "pic": "",
|
|
|
+ * }
|
|
|
+ * ],
|
|
|
+ * "care_num": 1,
|
|
|
+ * "dream_first_pic": null,
|
|
|
+ * "dream_imgs_first": null 封面图片
|
|
|
+ * "care_num": 2,
|
|
|
+ * "dream_first_pic": null,
|
|
|
+ * "dream_imgs_first": null
|
|
|
+ * },
|
|
|
+ * }
|
|
|
+ * ],
|
|
|
+ * "from": 1,
|
|
|
+ * "last_page": 1,
|
|
|
+ * "next_page_url": null,
|
|
|
+ * "path": "http://www.miao.com/api/index/index",
|
|
|
+ * "per_page": 20,
|
|
|
+ * "prev_page_url": null,
|
|
|
+ * "to": 3,
|
|
|
+ * "total": 3
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
* }
|
|
|
* }
|
|
|
* @apiErrorExample {json} Error-Response:
|
| xqd
@@ -53,12 +79,10 @@ class IndexController extends Controller
|
|
|
* "data": null or []
|
|
|
* }
|
|
|
*/
|
|
|
- public function hot(Request $request)
|
|
|
+ public function index(Request $request)
|
|
|
{
|
|
|
$user = $this->getUser();
|
|
|
-//获取轮播图
|
|
|
- $banner = $this->getBanner();
|
|
|
-// 关注的用户
|
|
|
+ // 关注的用户
|
|
|
$arr = $user->UserCareUser;
|
|
|
$users = [] ;
|
|
|
foreach ($arr as $k => $v){
|
| xqd
@@ -67,126 +91,24 @@ class IndexController extends Controller
|
|
|
$users[] = $v;
|
|
|
}
|
|
|
}
|
|
|
-// 获取其他用户信息 及梦想
|
|
|
- $dreams = DreamInfoModel::orderBy('score','desc')->limit(20)->paginate(20);
|
|
|
- $this->dreams($dreams);
|
|
|
- return $this->api(compact('banner','users','dreams'));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @api {get} /api/index/trend 潮流(trend)
|
|
|
- * @apiDescription 潮流(trend)
|
|
|
- * @apiGroup Index
|
|
|
- * @apiPermission none
|
|
|
- * @apiVersion 0.1.0
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
- * HTTP/1.1 200 OK
|
|
|
- *{
|
|
|
- *"status": true,
|
|
|
- *"status_code": 0,
|
|
|
- *"message": "",
|
|
|
- *"data": {
|
|
|
- * "users": [ 动态用户
|
|
|
- * 'news_num':2 新消息数目
|
|
|
- * ],
|
|
|
- * "dreams": [
|
|
|
- * "care_num": 0, 关注人数
|
|
|
- * "time": 1222222, 梦想倒计时
|
|
|
- * "dream_imgs_first": {
|
|
|
- * "pic": "", 梦想封面图片
|
|
|
- * }
|
|
|
- * "dream_find_user": [
|
|
|
- * {
|
|
|
- * ... 发布梦想的用户信息
|
|
|
- * }
|
|
|
- * ],
|
|
|
- * ]
|
|
|
- * }
|
|
|
- * }
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
- * {
|
|
|
- * "state": false,
|
|
|
- * "code": 1000,
|
|
|
- * "message": "传入参数不正确",
|
|
|
- * "data": null or []
|
|
|
- * }
|
|
|
- */
|
|
|
- public function trend(Request $request)
|
|
|
- {
|
|
|
- $user = $this->getUser();
|
|
|
-// 关注的用户
|
|
|
- $arr = $user->UserCareUser;
|
|
|
- $users = [] ;
|
|
|
-
|
|
|
- foreach ($arr as $k => $v){
|
|
|
- if ($v->pivot->dream_num > 0) {
|
|
|
- $v->news_num = $v->pivot->dream_num;
|
|
|
- $users[] = $v;
|
|
|
- }
|
|
|
+ $type = $request->type;
|
|
|
+ if ($type == 'trend') {
|
|
|
+ $dreams = DreamInfoModel::orderBy('score','desc')->offset(20)->limit(100)->paginate(20);
|
|
|
+ $this->dreams($dreams);
|
|
|
+ return $this->api(compact('users','dreams'));
|
|
|
+ } elseif ($type == 'news') {
|
|
|
+ $dreams = DreamInfoModel::orderBy('score','desc')->offset(100)->limit(500)->paginate(20);
|
|
|
+ $this->dreams($dreams);
|
|
|
+ return $this->api(compact('users','dreams'));
|
|
|
+ } else{
|
|
|
+ $banner = $this->getBanner();
|
|
|
+ // 获取其他用户信息 及梦想
|
|
|
+ $dreams = DreamInfoModel::orderBy('score','desc')->limit(20)->paginate(20);
|
|
|
+ $this->dreams($dreams);
|
|
|
+ return $this->api(compact('banner','users','dreams'));
|
|
|
}
|
|
|
-// 获取其他用户信息 及梦想
|
|
|
- $dreams = DreamInfoModel::orderBy('score','desc')->offset(20)->limit(100)->paginate(20);
|
|
|
- $this->dreams($dreams);
|
|
|
- return $this->api(compact('users','dreams'));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @api {get} /api/index/new 最新(news)
|
|
|
- * @apiDescription 最新(news)
|
|
|
- * @apiGroup Index
|
|
|
- * @apiPermission none
|
|
|
- * @apiVersion 0.1.0
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
- * HTTP/1.1 200 OK
|
|
|
- *{
|
|
|
- *"status": true,
|
|
|
- *"status_code": 0,
|
|
|
- *"message": "",
|
|
|
- *"data": {
|
|
|
- * "users": [
|
|
|
- * 'news_num':2 新消息数目
|
|
|
- * ], 动态用户
|
|
|
- * "dreams": [
|
|
|
- * "care_num": 0, 关注人数
|
|
|
- * "time": 1222222, 梦想倒计时
|
|
|
- * "dream_imgs_first": {
|
|
|
- * "pic": "", 梦想封面图片
|
|
|
- * }
|
|
|
- * "dream_find_user": [
|
|
|
- * {
|
|
|
- * ... 发布梦想的用户信息
|
|
|
- * }
|
|
|
- * ],
|
|
|
- * ]
|
|
|
- * }
|
|
|
- * }
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
- * {
|
|
|
- * "state": false,
|
|
|
- * "code": 1000,
|
|
|
- * "message": "传入参数不正确",
|
|
|
- * "data": null or []
|
|
|
- * }
|
|
|
- */
|
|
|
- public function news(Request $request)
|
|
|
- {
|
|
|
- $user = $this->getUser();
|
|
|
-// 关注的用户
|
|
|
- $arr = $user->UserCareUser;
|
|
|
- $users = [] ;
|
|
|
- foreach ($arr as $k => $v){
|
|
|
- if ($v->pivot->dream_num > 0) {
|
|
|
- $v->news_num = $v->pivot->dream_num;
|
|
|
- $users[] = $v;
|
|
|
- }
|
|
|
- }
|
|
|
-// 获取其他用户信息 及梦想
|
|
|
- $dreams = DreamInfoModel::orderBy('score','desc')->offset(100)->limit(500)->paginate(20);
|
|
|
- $this->dreams($dreams);
|
|
|
- return $this->api(compact('$users','dreams'));
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* @api {get} /api/index/search 搜索(search)
|