|
@@ -348,13 +348,14 @@ class DreamController extends Controller
|
|
* @apiPermission Passport
|
|
* @apiPermission Passport
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
* @apiParam {int} id 梦想ID
|
|
* @apiParam {int} id 梦想ID
|
|
|
|
+ * @apiParam {int} is_collection 0取消关注 1关注
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
*{
|
|
*{
|
|
* "status": true,
|
|
* "status": true,
|
|
* "status_code": 0,
|
|
* "status_code": 0,
|
|
* "message": "",
|
|
* "message": "",
|
|
- * "data": ""
|
|
|
|
|
|
+ * "data": 1 is_collection 关注值
|
|
*}
|
|
*}
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
*HTTP/1.1 400 Bad Request
|
|
*HTTP/1.1 400 Bad Request
|
|
@@ -372,9 +373,11 @@ class DreamController extends Controller
|
|
$validator = \Validator::make($request->all(),
|
|
$validator = \Validator::make($request->all(),
|
|
[
|
|
[
|
|
'id' => 'required',
|
|
'id' => 'required',
|
|
|
|
+ 'is_collection' => 'required',
|
|
],
|
|
],
|
|
[
|
|
[
|
|
'id.required' => '收藏梦想id不能为空',
|
|
'id.required' => '收藏梦想id不能为空',
|
|
|
|
+ 'is_collection.required' => '关注值不存在',
|
|
]
|
|
]
|
|
);
|
|
);
|
|
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);
|
|
@@ -385,12 +388,21 @@ class DreamController extends Controller
|
|
'dream_id' =>$request->id,
|
|
'dream_id' =>$request->id,
|
|
'dream_user_id' =>DreamInfoModel::find($request->id)->user_id,
|
|
'dream_user_id' =>DreamInfoModel::find($request->id)->user_id,
|
|
];
|
|
];
|
|
|
|
+ $is_collection = $request->is_collection;
|
|
$user_care_dream = UserCareDream::where('user_id',$user->id)->
|
|
$user_care_dream = UserCareDream::where('user_id',$user->id)->
|
|
where('dream_id',$request->id)->first();
|
|
where('dream_id',$request->id)->first();
|
|
- if (!$user_care_dream) {
|
|
|
|
- UserCareDream::create($data);
|
|
|
|
|
|
+ if ($is_collection) {
|
|
|
|
+ if (empty($user_care_dream)) {
|
|
|
|
+ UserCareDream::create($data);
|
|
|
|
+ }
|
|
|
|
+ $is_collection = 0 ;
|
|
|
|
+ return $this->api($is_collection);
|
|
|
|
+ }else{
|
|
|
|
+ UserCareDream::where('user_id',$user->id)->
|
|
|
|
+ where('dream_id',$request->id)->delete();
|
|
|
|
+ $is_collection = 1 ;
|
|
|
|
+ return $this->api($is_collection);
|
|
}
|
|
}
|
|
- return $this->api('');
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|