|
@@ -8,44 +8,53 @@ use App\Models\DreamImages;
|
|
use App\Models\DreamInfoModel;
|
|
use App\Models\DreamInfoModel;
|
|
use App\Models\ReplyCommentsInfo;
|
|
use App\Models\ReplyCommentsInfo;
|
|
use App\Models\SystemInfoModel;
|
|
use App\Models\SystemInfoModel;
|
|
-use App\Models\UserCareUser;
|
|
|
|
-use App\Models\UserDream;
|
|
|
|
|
|
+use App\Models\UserCareDream;
|
|
use App\Models\UserInfoModel;
|
|
use App\Models\UserInfoModel;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use App\Services\Base\ErrorCode;
|
|
use App\Services\Base\ErrorCode;
|
|
class MyController extends Controller
|
|
class MyController extends Controller
|
|
{
|
|
{
|
|
/**
|
|
/**
|
|
- * @api {get} /api/my/show 个人首页(index)
|
|
|
|
- * @apiDescription 个人首页(index)
|
|
|
|
|
|
+ * @api {get} /api/my/show 个人首页
|
|
|
|
+ * @apiDescription 个人首页
|
|
* @apiGroup My
|
|
* @apiGroup My
|
|
* @apiPermission Passport
|
|
* @apiPermission Passport
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 O* "status": true,
|
|
* HTTP/1.1 200 O* "status": true,
|
|
- * "status_code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": {
|
|
|
|
- * "id": 1,
|
|
|
|
- * "tel": "13880642880",
|
|
|
|
- * "password": "",
|
|
|
|
- * "nickname": "",
|
|
|
|
- * "pic": "",
|
|
|
|
- * "sign": 0,
|
|
|
|
- * "money": 0,余额
|
|
|
|
- * "sex": 1,
|
|
|
|
- * "signture": "",个性签名
|
|
|
|
- * "tall": "",
|
|
|
|
- * "job": "",
|
|
|
|
- * "emotion": 1,
|
|
|
|
- * "address": "",
|
|
|
|
- * "detail_address": "",
|
|
|
|
- * "status": 1,
|
|
|
|
- * "remember_token": "",
|
|
|
|
- * "care_num": 4,关注
|
|
|
|
- * "fens_num": 3,粉丝
|
|
|
|
- * "collection_num": 2,收藏
|
|
|
|
- * "dream_num": 1,发帖
|
|
|
|
- * }
|
|
|
|
|
|
+ *{
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "id": 1,
|
|
|
|
+ * "phone": "13880642880",
|
|
|
|
+ * "nickname": "name1",
|
|
|
|
+ * "avatar": "https://tims%2Fitem%225_kzrcM.thumb.224_0.jpeg",
|
|
|
|
+ * "birthday": "2000-06-21",
|
|
|
|
+ * "sign": 0,
|
|
|
|
+ * "money": 0,
|
|
|
|
+ * "coin": 1300,
|
|
|
|
+ * "sex": 1,
|
|
|
|
+ * "signture": "",
|
|
|
|
+ * "height": 170,
|
|
|
|
+ * "work": "",
|
|
|
|
+ * "emotion": 1,
|
|
|
|
+ * "address": "",
|
|
|
|
+ * "city": "",
|
|
|
|
+ * "detail_address": "",
|
|
|
|
+ * "status": 1,
|
|
|
|
+ * "wechat": "",
|
|
|
|
+ * "weibo": "",
|
|
|
|
+ * "remember_token": "",
|
|
|
|
+ * "created_at": "2017-06-25 10:27:08",
|
|
|
|
+ * "updated_at": "2017-06-25 15:20:11",
|
|
|
|
+ * "deleted_at": null,
|
|
|
|
+ * "care_dreams_number": 2,
|
|
|
|
+ * "fans_number": 0,
|
|
|
|
+ * "collection_number": 0,
|
|
|
|
+ * "interaction_number": 0,
|
|
|
|
+ * }
|
|
|
|
+ *}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
* HTTP/1.1 400 Bad Request
|
|
* HTTP/1.1 400 Bad Request
|
|
*{
|
|
*{
|
|
@@ -64,20 +73,20 @@ class MyController extends Controller
|
|
* 我的关注人数,我的粉丝,收藏
|
|
* 我的关注人数,我的粉丝,收藏
|
|
* 点赞?徽章?
|
|
* 点赞?徽章?
|
|
* */
|
|
* */
|
|
- $data1 = $user->myCareNum;
|
|
|
|
- $user->care_num = count($data1);
|
|
|
|
- $data2 = $user->myFans;
|
|
|
|
- $user->fans_num = count($data2);
|
|
|
|
- $data3 = $user->myCollection;
|
|
|
|
- $user->collection_num = count($data3);
|
|
|
|
- $data4 = $user->UserDream;
|
|
|
|
- $user->dream_num = count($data4);
|
|
|
|
|
|
+ $care_num = $user->careDreams;
|
|
|
|
+ $user->care_dreams_number = count($care_num);
|
|
|
|
+ $fens = UserCareDream::where('dream_user_id',$user->id)->get();
|
|
|
|
+ $user->fans_number = count($fens);
|
|
|
|
+ $collection = $user->myCollection;
|
|
|
|
+ $user->collection_number = count($collection);
|
|
|
|
+ $interaction_infos = $user->allInteraction;
|
|
|
|
+ $user->interaction_number = count($interaction_infos);
|
|
return $this->api($user);
|
|
return $this->api($user);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @api {get} /api/my/edit_user_info 修改个人信息
|
|
|
|
|
|
+ * @api {get} /api/my/edit 修改个人信息
|
|
* @apiDescription 修改个人信息
|
|
* @apiDescription 修改个人信息
|
|
* @apiGroup My
|
|
* @apiGroup My
|
|
* @apiPermission Passport
|
|
* @apiPermission Passport
|
|
@@ -124,26 +133,26 @@ class MyController extends Controller
|
|
* "data": null
|
|
* "data": null
|
|
* }
|
|
* }
|
|
*/
|
|
*/
|
|
- public function editUserInfo (Request $request)
|
|
|
|
|
|
+ public function edit()
|
|
{
|
|
{
|
|
$sex = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
|
|
$sex = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
|
|
- where('dictionary_code','sex')->paginate(20);
|
|
|
|
|
|
+ where('dictionary_code','sex')->get();
|
|
$emotion = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
|
|
$emotion = BaseDictionaryOptionModel::where('dictionary_table_code','user_info')->
|
|
- where('dictionary_code','emotion')->paginate(20);
|
|
|
|
|
|
+ where('dictionary_code','emotion')->get();
|
|
|
|
|
|
return $this->api(compact('emotion','sex'));
|
|
return $this->api(compact('emotion','sex'));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @api {post} /api/my/update_user_info 保存个人信息
|
|
|
|
|
|
+ * @api {post} /api/my/update 保存个人信息
|
|
* @apiDescription 保存个人信息
|
|
* @apiDescription 保存个人信息
|
|
* @apiParam {string} pic 头像
|
|
* @apiParam {string} pic 头像
|
|
* @apiParam {int} sex 性别
|
|
* @apiParam {int} sex 性别
|
|
* @apiParam {string} signture 个性签名
|
|
* @apiParam {string} signture 个性签名
|
|
* @apiParam {int} emotion 情感状态
|
|
* @apiParam {int} emotion 情感状态
|
|
- * @apiParam {string} job 职业
|
|
|
|
- * @apiParam {int} tall 身高
|
|
|
|
|
|
+ * @apiParam {string} work 职业
|
|
|
|
+ * @apiParam {int} height 身高
|
|
* @apiGroup My
|
|
* @apiGroup My
|
|
* @apiPermission Passport
|
|
* @apiPermission Passport
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
@@ -164,7 +173,7 @@ class MyController extends Controller
|
|
* "data": null
|
|
* "data": null
|
|
* }
|
|
* }
|
|
*/
|
|
*/
|
|
- public function updateUserInfo(Request $request)
|
|
|
|
|
|
+ public function update(Request $request)
|
|
{
|
|
{
|
|
$user = $this->getUser();
|
|
$user = $this->getUser();
|
|
$data = $request->except('_token');
|
|
$data = $request->except('_token');
|
|
@@ -177,9 +186,10 @@ class MyController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @api {get} /api/my/recharge 充值(recharge)
|
|
|
|
|
|
+ * @api {post} /api/my/recharge 充值(recharge)
|
|
* @apiDescription 充值(recharge)
|
|
* @apiDescription 充值(recharge)
|
|
* @apiGroup My
|
|
* @apiGroup My
|
|
|
|
+ * @apiParam {int} coin 充值金额
|
|
* @apiPermission Passport
|
|
* @apiPermission Passport
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
@@ -191,20 +201,20 @@ class MyController extends Controller
|
|
{
|
|
{
|
|
$validator = \Validator::make($request->all(),
|
|
$validator = \Validator::make($request->all(),
|
|
[
|
|
[
|
|
- 'money' => 'required|integer',
|
|
|
|
|
|
+ 'coin' => 'required|integer',
|
|
],
|
|
],
|
|
[
|
|
[
|
|
- 'money.required' => '请输入金额',
|
|
|
|
- 'money.integer' => '请输入整数',
|
|
|
|
|
|
+ 'coin.required' => '请填写金额',
|
|
|
|
+ 'coin.integer' => '请输入整数',
|
|
|
|
|
|
]
|
|
]
|
|
);
|
|
);
|
|
if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
|
|
|
|
$user = $this->getUser();
|
|
$user = $this->getUser();
|
|
- $user->coin += $request->money;
|
|
|
|
|
|
+ $user->coin += $request->coin;
|
|
$user->save();
|
|
$user->save();
|
|
- return $this->api(compact('user'));
|
|
|
|
|
|
+ return $this->api('');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -226,14 +236,6 @@ class MyController extends Controller
|
|
*}
|
|
*}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
* HTTP/1.1 400 Bad Request
|
|
* HTTP/1.1 400 Bad Request
|
|
- * {
|
|
|
|
- * "status": true,
|
|
|
|
- * "status_code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": {
|
|
|
|
- * "data": []
|
|
|
|
- * }
|
|
|
|
- *}
|
|
|
|
*/
|
|
*/
|
|
public function systemInfo()
|
|
public function systemInfo()
|
|
{
|
|
{
|
|
@@ -242,124 +244,40 @@ class MyController extends Controller
|
|
return $this->api(compact('data'));
|
|
return $this->api(compact('data'));
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * @api {get} /api/my/reply_my 回复我的(replyMy)
|
|
|
|
- * @apiDescription 回复我的(replyMy)
|
|
|
|
- * @apiGroup My
|
|
|
|
- * @apiPermission Passport
|
|
|
|
- * @apiVersion 0.1.0
|
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
|
- * HTTP/1.1 200 OK
|
|
|
|
- *
|
|
|
|
- * {
|
|
|
|
- * "status": true,
|
|
|
|
- * "status_code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": {
|
|
|
|
- * "comments_infos": [
|
|
|
|
- * {
|
|
|
|
- * "id": 1,
|
|
|
|
- * "dream_id": 2,
|
|
|
|
- * "user_id": 2,
|
|
|
|
- * "level": 2,
|
|
|
|
- * "content": "啊哈", 评论内容
|
|
|
|
- * "created_at": null, 评论时间
|
|
|
|
- * "updated_at": null,
|
|
|
|
- * "deleted_at": null,
|
|
|
|
- * "dream_name": "去旅游去旅游2", 梦想介绍
|
|
|
|
- * "dream_pic": "aaaaa", 梦想图片
|
|
|
|
- * "progress": 0, 进度
|
|
|
|
- * "reviewer": "22222", 评论者
|
|
|
|
- * "reviewer_pic": "22222pic", 评论者头像
|
|
|
|
- * }
|
|
|
|
- * ]
|
|
|
|
- * }
|
|
|
|
- * }
|
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
|
- */
|
|
|
|
- public function replyMy()
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- $user = $this->getUser();
|
|
|
|
-// 梦想
|
|
|
|
- $dreams = $user->UserDream;
|
|
|
|
-
|
|
|
|
- $data = $user->allInteraction;
|
|
|
|
- foreach ($data as $item) {
|
|
|
|
- $item->get_money = $item->dream->get_money;
|
|
|
|
- $item->money = $item->dream->money;
|
|
|
|
- }
|
|
|
|
- dd($data) ;
|
|
|
|
- if (count($dreams) == 0)
|
|
|
|
- return $this->error(ErrorCode::DREAM_NOT_EXIST);
|
|
|
|
- $comments_infos = [];
|
|
|
|
- foreach ($dreams as $dream){
|
|
|
|
- $comments_info = $dream->DreamInfo;
|
|
|
|
- if (count($comments_info) > 0) {
|
|
|
|
- foreach ($comments_info as $k => $value) {
|
|
|
|
- $value->dream_name = $dream->dream;
|
|
|
|
- $value->dream_about = $dream->about;
|
|
|
|
- $value->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
|
|
|
|
- $value->progress = $dream->money == 0 ? 0 : floor($dream->get_money/$dream->money);
|
|
|
|
- $value->reviewer = $value->CommentUser->nickname;
|
|
|
|
- $value->reviewer_pic = $value->CommentUser->pic;
|
|
|
|
- }
|
|
|
|
- $comments_infos[] = $comments_info;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $this->api(compact('comments_infos'));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @api {post} /api/my/my_reply 我的回复(myReply)
|
|
|
|
- * @apiDescription 我的回复(recharge)
|
|
|
|
- * @apiGroup My
|
|
|
|
- * @apiParam {text} content 回复内容
|
|
|
|
- * @apiParam {int} comment_id 评论ID
|
|
|
|
- * @apiPermission Passport
|
|
|
|
- * @apiVersion 0.1.0
|
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
|
- * {
|
|
|
|
- * "status": true,
|
|
|
|
- * "status_code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": ""
|
|
|
|
- *}
|
|
|
|
- * HTTP/1.1 200 OK
|
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
|
- * {
|
|
|
|
- * "status": false,
|
|
|
|
- * "status_code": 1000,
|
|
|
|
- * "message": "输入不正确",
|
|
|
|
- * "data": null
|
|
|
|
- *}
|
|
|
|
- *{
|
|
|
|
- * "status": false,
|
|
|
|
- * "status_code": 600,
|
|
|
|
- * "message": "保存用户数据失败",
|
|
|
|
- * "data": null
|
|
|
|
- *}
|
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
|
- */
|
|
|
|
- public function myReply(Request $request)
|
|
|
|
- {
|
|
|
|
- $user = $this->getUser();
|
|
|
|
- $data = $request->except('_token');
|
|
|
|
- $data['user_id'] = $user->id;
|
|
|
|
-
|
|
|
|
- if (!$request->content)
|
|
|
|
- return $this->error(ErrorCode::CLIENT_WRONG_PARAMS);
|
|
|
|
-
|
|
|
|
- $ok = ReplyCommentsInfo::create($data);
|
|
|
|
-
|
|
|
|
- if ($ok) {
|
|
|
|
- return $this->api('');
|
|
|
|
- }else{
|
|
|
|
- return $this->error(ErrorCode::SAVE_USER_FAILED);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// 回复我的
|
|
|
|
+// public function replyMy()
|
|
|
|
+// {
|
|
|
|
+//
|
|
|
|
+// $user = $this->getUser();
|
|
|
|
+//// 梦想
|
|
|
|
+// $dreams = $user->UserDream;
|
|
|
|
+//
|
|
|
|
+// $data = $user->allInteraction;
|
|
|
|
+// foreach ($data as $item) {
|
|
|
|
+// $item->get_money = $item->dream->get_money;
|
|
|
|
+// $item->money = $item->dream->money;
|
|
|
|
+// }
|
|
|
|
+// dd($data) ;
|
|
|
|
+// if (count($dreams) == 0)
|
|
|
|
+// return $this->error(ErrorCode::DREAM_NOT_EXIST);
|
|
|
|
+// $comments_infos = [];
|
|
|
|
+// foreach ($dreams as $dream){
|
|
|
|
+// $comments_info = $dream->DreamInfo;
|
|
|
|
+// if (count($comments_info) > 0) {
|
|
|
|
+// foreach ($comments_info as $k => $value) {
|
|
|
|
+// $value->dream_name = $dream->dream;
|
|
|
|
+// $value->dream_about = $dream->about;
|
|
|
|
+// $value->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
|
|
|
|
+// $value->progress = $dream->money == 0 ? 0 : floor($dream->get_money/$dream->money);
|
|
|
|
+// $value->reviewer = $value->CommentUser->nickname;
|
|
|
|
+// $value->reviewer_pic = $value->CommentUser->pic;
|
|
|
|
+// }
|
|
|
|
+// $comments_infos[] = $comments_info;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// return $this->api(compact('comments_infos'));
|
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @api {get} /api/my/dream 我的梦想(dream)
|
|
* @api {get} /api/my/dream 我的梦想(dream)
|
|
@@ -368,38 +286,42 @@ class MyController extends Controller
|
|
* @apiPermission Passport
|
|
* @apiPermission Passport
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
- * {
|
|
|
|
- * "status": true,
|
|
|
|
- * "status_code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": {
|
|
|
|
- * "dreams": [
|
|
|
|
- * {
|
|
|
|
- * "id": 2,
|
|
|
|
- * "dream": "去旅游去旅游2",
|
|
|
|
- * "about": "欧冠胡234",
|
|
|
|
- * "dream_pic": "aaaaa", 封面图片
|
|
|
|
- * "progress": 0, 进度
|
|
|
|
- * ]
|
|
|
|
- * }
|
|
|
|
- * }
|
|
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
|
|
+ *{
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": [
|
|
|
|
+ * {
|
|
|
|
+ * "id": 5,
|
|
|
|
+ * "user_id": 1,
|
|
|
|
+ * "name": "梦想标题1",
|
|
|
|
+ * "about": "梦想介绍",
|
|
|
|
+ * "coin": 2500,
|
|
|
|
+ * "time": 21,
|
|
|
|
+ * "get_coin": 0,
|
|
|
|
+ * "status": 0,
|
|
|
|
+ * "video": null,
|
|
|
|
+ * "sign": "",
|
|
|
|
+ * "created_at": "2017-06-25 12:45:22",
|
|
|
|
+ * "updated_at": "2017-06-25 12:45:22",
|
|
|
|
+ * "pic": "https://timgsa.baidu.com/timg?image7b14f12f.jpg",
|
|
|
|
+ * },
|
|
|
|
+ * ]
|
|
|
|
+ *}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
* HTTP/1.1 400 Bad Request
|
|
* HTTP/1.1 400 Bad Request
|
|
*/
|
|
*/
|
|
public function dream()
|
|
public function dream()
|
|
{
|
|
{
|
|
$user = $this->getUser();
|
|
$user = $this->getUser();
|
|
-// 梦想
|
|
|
|
- $dreams = $user->UserDream;
|
|
|
|
|
|
+ $dreams = $user->dreams;
|
|
|
|
|
|
if (count($dreams) == 0)
|
|
if (count($dreams) == 0)
|
|
return $this->error(ErrorCode::DREAM_NOT_EXIST);
|
|
return $this->error(ErrorCode::DREAM_NOT_EXIST);
|
|
|
|
|
|
foreach ($dreams as $dream){
|
|
foreach ($dreams as $dream){
|
|
- $dream->dream_pic = count($dream->dreamImgsFirst) > 0 ? $dream->dreamImgsFirst->pic : '';
|
|
|
|
-
|
|
|
|
- $dream->progress = $dream->money == 0 ? 0 : floor($dream->get_money/$dream->money);
|
|
|
|
|
|
+ $dream->pic = count($dream->img) > 0 ? $dream->img->pic : '';
|
|
}
|
|
}
|
|
|
|
|
|
return $this->api($dreams);
|
|
return $this->api($dreams);
|
|
@@ -413,14 +335,53 @@ class MyController extends Controller
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
|
|
+ *{
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "data": [
|
|
|
|
+ * { 梦想详情
|
|
|
|
+ * "id": 12,
|
|
|
|
+ * "user_id": 2,
|
|
|
|
+ * "name": "用户2梦想标题166",
|
|
|
|
+ * "about": "用户2梦想介绍666",
|
|
|
|
+ * "coin": 2500,
|
|
|
|
+ * "time": 21,
|
|
|
|
+ * "get_coin": 0,
|
|
|
|
+ * "status": 0,
|
|
|
|
+ * "video": null,
|
|
|
|
+ * "sign": "",
|
|
|
|
+ * },
|
|
|
|
+ * "img": {
|
|
|
|
+ * "title": "",
|
|
|
|
+ * "pic": "https://f12f.jpg" 梦想封面图片
|
|
|
|
+ * }
|
|
|
|
+ * ],
|
|
|
|
+ * "users": {
|
|
|
|
+ * "2": "https://xxx.jpeg" ID号和头像
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ *}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
* HTTP/1.1 400 Bad Request
|
|
* HTTP/1.1 400 Bad Request
|
|
*/
|
|
*/
|
|
public function collection()
|
|
public function collection()
|
|
{
|
|
{
|
|
$user = $this->getUser();
|
|
$user = $this->getUser();
|
|
- $data = $user->myCollection;
|
|
|
|
- return $this->api(compact('data'));
|
|
|
|
|
|
+ $data = $user->collection;
|
|
|
|
+ $users = [];
|
|
|
|
+ foreach ($data as $item) {
|
|
|
|
+ if ($item->pivot->interaction_number > 0) {
|
|
|
|
+ $user_info = UserInfoModel::find($item->pivot->dream_user_id);
|
|
|
|
+ $avatar = $user_info ? $user_info->avatar : '';
|
|
|
|
+ if (!array_key_exists($item->pivot->dream_user_id,$users)) {
|
|
|
|
+ $users[$item->pivot->dream_user_id] = $avatar;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $item->img;
|
|
|
|
+ }
|
|
|
|
+ return $this->api(compact('data','users'));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -433,13 +394,11 @@ class MyController extends Controller
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
*{
|
|
*{
|
|
* "status": true,
|
|
* "status": true,
|
|
- ** "status_code": 0,
|
|
|
|
|
|
+ * "status_code": 0,
|
|
* "message": "",
|
|
* "message": "",
|
|
* "data": {
|
|
* "data": {
|
|
- * "data": {
|
|
|
|
- * "key": "2511789", 电话
|
|
|
|
- * "value": "关于喵喵介绍" 介绍
|
|
|
|
- * }
|
|
|
|
|
|
+ * "key": "2511789", 电话
|
|
|
|
+ * "value": "关于喵喵介绍" 关于喵喵
|
|
* }
|
|
* }
|
|
*}
|
|
*}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
@@ -448,106 +407,7 @@ class MyController extends Controller
|
|
public function setting()
|
|
public function setting()
|
|
{
|
|
{
|
|
$data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
|
|
$data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
|
|
- return $this->api(compact('data'));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @api {post} /api/my/store_dream 发布梦想
|
|
|
|
- * @apiDescription 发布梦想
|
|
|
|
- * @apiParam {string} pics 梦想图片 数组
|
|
|
|
- * @apiParam {string} video 梦想视频
|
|
|
|
- * @apiParam {string} name 梦想标题
|
|
|
|
- * @apiParam {string} about 梦想介绍
|
|
|
|
- * @apiParam {int} coin 梦想币
|
|
|
|
- * @apiParam {int} time 实现时间默认21*3600
|
|
|
|
- * @apiGroup My
|
|
|
|
- * @apiPermission Passport
|
|
|
|
- * @apiVersion 0.1.0
|
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
|
- * {
|
|
|
|
- * "status": true,
|
|
|
|
- * "status_code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": ""
|
|
|
|
- *}
|
|
|
|
- * HTTP/1.1 200 OK
|
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
|
- * {
|
|
|
|
- * "status": false,
|
|
|
|
- * "status_code": 600,
|
|
|
|
- * "message": "保存用户数据失败",
|
|
|
|
- * "data": null
|
|
|
|
- * }
|
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
|
- */
|
|
|
|
- public function storeDream(Request $request)
|
|
|
|
- {
|
|
|
|
- $user = $this->getUser();
|
|
|
|
- $validator = \Validator::make($request->all(),
|
|
|
|
- [
|
|
|
|
- 'name' => 'required',
|
|
|
|
- 'about' => 'required',
|
|
|
|
- 'coin' => 'required|integer',
|
|
|
|
- 'time' => 'required|integer',
|
|
|
|
- ],
|
|
|
|
- [
|
|
|
|
- 'name.required' => '梦想标题必填',
|
|
|
|
- 'about.required' => '梦想介绍必填',
|
|
|
|
- 'coin.required' => '梦想币必填',
|
|
|
|
- 'coin.integer' => '梦想币必须是正整数',
|
|
|
|
- 'time.required' => '实现时间必填',
|
|
|
|
- 'time.integer' => '实现时间必须是正整数',
|
|
|
|
- ]
|
|
|
|
- );
|
|
|
|
- if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
|
|
- \Log::debug($user);
|
|
|
|
- $data2 = $user->myCareNum;
|
|
|
|
- $care_num = count($data2);
|
|
|
|
- $setting = BaseSettingsModel::where('category','paihang')->first();
|
|
|
|
- $a = $setting?$setting->key:1;
|
|
|
|
- $b = $setting?$setting->value:1;
|
|
|
|
- $t = 21*3600 / 60;
|
|
|
|
-
|
|
|
|
- $data = $request->except('_token','pics');
|
|
|
|
- $data['user_id'] = $user->id;
|
|
|
|
- \Log::debug(' care_num:'.$care_num.' a:'.$a.' b:'.$b.' t:'.$t);
|
|
|
|
- if ($care_num == 0) {
|
|
|
|
- $data['score'] = (($a/$t) + $b)*100000000 ;
|
|
|
|
- }else{
|
|
|
|
- $data['score'] = (log($care_num) + ($a/$t) + $b)*100000000 ;
|
|
|
|
- }
|
|
|
|
- $data['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
- $data['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
- $dream_id = DreamInfoModel::insertGetId($data);
|
|
|
|
-
|
|
|
|
- if ($dream_id) {
|
|
|
|
-// 梦想创建成功 关联关系中最新动态+1
|
|
|
|
- /* $info = UserCareUser::where('other_user_id',$user->id)->paginate(20);
|
|
|
|
- foreach ($info as $item) {
|
|
|
|
- $item->dream_num += 1;
|
|
|
|
- $item->updated_at = date('Y-m-d H:i:s');
|
|
|
|
- $item->save();
|
|
|
|
- }*/
|
|
|
|
- $pics = $request->pics;
|
|
|
|
- $video = $request->video;
|
|
|
|
- if (empty($pics) && empty($video)) {
|
|
|
|
- DreamInfoModel::destroy($dream_id);
|
|
|
|
- return $this->error(ErrorCode::ATTACHMENT_NOT_EXIST);
|
|
|
|
- }
|
|
|
|
- $data = [];
|
|
|
|
- if (is_array($pics)) {
|
|
|
|
- foreach ($pics as $v){
|
|
|
|
- $data[] = [
|
|
|
|
- 'dream_id'=>$dream_id,
|
|
|
|
- 'pic' => $v,
|
|
|
|
- 'created_at' =>date('Y-m-d H:i:s'),
|
|
|
|
- 'updated_at' =>date('Y-m-d H:i:s'),
|
|
|
|
- ];
|
|
|
|
- }
|
|
|
|
- DreamImages::insert($data);
|
|
|
|
- }
|
|
|
|
- return $this->api('');
|
|
|
|
- }
|
|
|
|
|
|
+ return $this->api($data);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|