| xqd
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\V1;
|
|
|
use App\Models\AccountLog;
|
|
|
use App\Models\BaseDictionaryOptionModel;
|
|
|
use App\Models\BaseSettingsModel;
|
|
|
+use App\Models\CommentInfoModel;
|
|
|
use App\Models\DreamInfoModel;
|
|
|
use App\Models\SearchInfoModel;
|
|
|
use App\Models\Suggest;
|
| xqd
@@ -221,6 +222,63 @@ class MyController extends Controller
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @api {get} /api/my/reply 回复我的
|
|
|
+ * @apiDescription 回复我的
|
|
|
+ * @apiGroup My
|
|
|
+ * @apiPermission Passport
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ *{
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": [
|
|
|
+ * {
|
|
|
+ * ....
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ */
|
|
|
+ public function reply()
|
|
|
+ {
|
|
|
+ $user = $this->getUser();
|
|
|
+ $data = CommentInfoModel::where('user_id',$user->id)->orderBy('id','desc')->get();
|
|
|
+
|
|
|
+ foreach ($data as $item){ //访问接口 标记已读
|
|
|
+ $item->update(['is_read'=>1]);
|
|
|
+ }
|
|
|
+ return $this->api($data);
|
|
|
+ } /**
|
|
|
+ * @api {get} /api/my/letter 私信
|
|
|
+ * @apiDescription 私信
|
|
|
+ * @apiGroup My
|
|
|
+ * @apiPermission Passport
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ *{
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": [
|
|
|
+ * {
|
|
|
+ * ....
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ */
|
|
|
+ public function letter()
|
|
|
+ {
|
|
|
+ $user = $this->getUser();
|
|
|
+ $data = SystemInfoModel::where('user_id',$user->id)->whereNotNull('to_user_id')->orderBy('id','desc')->get();
|
|
|
+ foreach ($data as $item){ //访问接口 标记已读
|
|
|
+ $item->update(['is_read'=>1]);
|
|
|
+ }
|
|
|
+ return $this->api($data);
|
|
|
+ } /**
|
|
|
* @api {get} /api/my/system_info 系统消息
|
|
|
* @apiDescription 系统消息
|
|
|
* @apiGroup My
|
| xqd
@@ -232,19 +290,119 @@ class MyController extends Controller
|
|
|
* "status": true,
|
|
|
* "status_code": 0,
|
|
|
* "message": "",
|
|
|
+ * "data": [
|
|
|
+ * {
|
|
|
+ * ....
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ */
|
|
|
+ public function systemInfo()
|
|
|
+ {
|
|
|
+ $user = $this->getUser();
|
|
|
+ $data = SystemInfoModel::where('user_id',$user->id)->whereNull('to_user_id')->orderBy('id','desc')->get();
|
|
|
+ foreach ($data as $item){ //访问接口 标记已读
|
|
|
+ $item->update(['is_read'=>1]);
|
|
|
+ }
|
|
|
+ return $this->api($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {get} /api/my/info 消息中心
|
|
|
+ * @apiDescription 消息中心
|
|
|
+ * @apiGroup My
|
|
|
+ * @apiPermission Passport
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ *{
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
* "data": {
|
|
|
- * "data": [
|
|
|
- * ...
|
|
|
- * ]
|
|
|
+ * "systemInfo": {
|
|
|
+ * "number": 3,
|
|
|
+ * "is_read": 3
|
|
|
+ * },
|
|
|
+ * "letter": {
|
|
|
+ * "number": 0,
|
|
|
+ * "is_read": 0
|
|
|
+ * },
|
|
|
+ * "reply": {
|
|
|
+ * "number": 3,
|
|
|
+ * "is_read": 3
|
|
|
+ * }
|
|
|
+ * }
|
|
|
*}
|
|
|
* @apiErrorExample {json} Error-Response:
|
|
|
* HTTP/1.1 400 Bad Request
|
|
|
*/
|
|
|
- public function systemInfo()
|
|
|
+ public function info()
|
|
|
+ {
|
|
|
+ $user = $this->getUser();
|
|
|
+ $systemInfo1 = SystemInfoModel::where('user_id',$user->id)->whereNull('to_user_id')->orderBy('id','desc')->get();
|
|
|
+ $systemInfo2 = SystemInfoModel::where('user_id',$user->id)->where('is_read','0')
|
|
|
+ ->whereNull('to_user_id')->orderBy('id','desc')->get();
|
|
|
+ $letter1 = SystemInfoModel::where('user_id',$user->id)->whereNotNull('to_user_id')->orderBy('id','desc')->get();
|
|
|
+ $letter2 = SystemInfoModel::where('user_id',$user->id)->where('is_read','0')
|
|
|
+ ->whereNotNull('to_user_id')->orderBy('id','desc')->get();
|
|
|
+ $comments1 = CommentInfoModel::where('user_id',$user->id)->orderBy('id','desc')->get();
|
|
|
+ $comments2 = CommentInfoModel::where('user_id',$user->id)->where('is_read','0')->orderBy('id','desc')->get();
|
|
|
+ $arr = [];
|
|
|
+ $arr['systemInfo']['number'] = count($systemInfo1) ;
|
|
|
+ $arr['systemInfo']['is_read'] = count($systemInfo2) ;
|
|
|
+ $arr['letter']['number'] = count($letter1) ;
|
|
|
+ $arr['letter']['is_read'] = count($letter2) ;
|
|
|
+ $arr['reply']['number'] = count($comments1) ;
|
|
|
+ $arr['reply']['is_read'] = count($comments2) ;
|
|
|
+ return $this->api($arr);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {get} /api/my/read 设为已读
|
|
|
+ * @apiDescription 设为已读
|
|
|
+ * @apiGroup My
|
|
|
+ * @apiPermission Passport
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
+ *{
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": ""
|
|
|
+ *}
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "status": false,
|
|
|
+ * "status_code": 700,
|
|
|
+ * "message": "操作失败",
|
|
|
+ * "data": null
|
|
|
+ *}
|
|
|
+ */
|
|
|
+ public function read()
|
|
|
{
|
|
|
$user = $this->getUser();
|
|
|
- $data = SystemInfoModel::where('user_id',$user->id)->orderBy('id','desc')->get();
|
|
|
- return $this->api(compact('data'));
|
|
|
+ $id = $user->id;
|
|
|
+ $system_infos = SystemInfoModel::where(function ($query) use($id){
|
|
|
+ $query->where('user_id',$id)->where('is_read','0');
|
|
|
+ })->orWhere(function ($query) use($id){
|
|
|
+ $query->where('to_user_id',$id)->where('is_read','0');
|
|
|
+ })->orderBy('id','desc')->get();
|
|
|
+ $comments = CommentInfoModel::where('user_id',$user->id)->where('is_read','0')->orderBy('id','desc')->get();
|
|
|
+ foreach ($system_infos as $system_info){
|
|
|
+ $system_info->update(['is_read'=>1]);
|
|
|
+ }
|
|
|
+ foreach ($comments as $comment){
|
|
|
+ $comment->update(['is_read'=>1]);
|
|
|
+ }
|
|
|
+ if (count($system_infos) > 0 || count($comments) > 0) {
|
|
|
+ return $this->api('');
|
|
|
+ }else{
|
|
|
+ return $this->error(ErrorCode::OPERATION_FAILED);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
| xqd
@@ -591,8 +749,8 @@ class MyController extends Controller
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @api {get} /api/my/setting 设置
|
|
|
- * @apiDescription 设置
|
|
|
+ * @api {get} /api/my/miao 关于喵喵
|
|
|
+ * @apiDescription 关于喵喵
|
|
|
* @apiGroup My
|
|
|
* @apiPermission Passport
|
|
|
* @apiVersion 0.1.0
|
| xqd
@@ -610,7 +768,7 @@ class MyController extends Controller
|
|
|
* @apiErrorExample {json} Error-Response:
|
|
|
* HTTP/1.1 400 Bad Request
|
|
|
*/
|
|
|
- public function setting()
|
|
|
+ public function aboutMiao()
|
|
|
{
|
|
|
$data = BaseSettingsModel::where('category','miaomiao')->select('key','value')->first();
|
|
|
return $this->api($data);
|