正在显示
2 个修改的文件
包含
88 行增加
和
16 行删除
@@ -282,14 +282,57 @@ class User extends Api | @@ -282,14 +282,57 @@ class User extends Api | ||
282 | * @ApiReturn({ | 282 | * @ApiReturn({ |
283 | "code": 1, | 283 | "code": 1, |
284 | "msg": "成功", | 284 | "msg": "成功", |
285 | - "time": "1599017563", | ||
286 | - "data": "暂不登录提示内容" //暂不登录提示内容 | 285 | + "time": "1602813642", |
286 | + "data": { | ||
287 | + "id": 15, | ||
288 | + "group_id": 1, //身份:0=个人用户,1=企业用户 | ||
289 | + "username": "", | ||
290 | + "nickname": "", //真实姓名 | ||
291 | + "password": "743fee718194570689974bad08666a56", | ||
292 | + "salt": "UDnPtj", | ||
293 | + "email": "", | ||
294 | + "mobile": "15133120361", | ||
295 | + "avatar": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgaGVpZ2h0PSIxMDAiIHdpZHRoPSIxMDAiPjxyZWN0IGZpbGw9InJnYigxNjAsMjI5LDE3OSkiIHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIj48L3JlY3Q+PHRleHQgeD0iNTAiIHk9IjUwIiBmb250LXNpemU9IjUwIiB0ZXh0LWNvcHk9ImZhc3QiIGZpbGw9IiNmZmZmZmYiIHRleHQtYW5jaG9yPSJtaWRkbGUiIHRleHQtcmlnaHRzPSJhZG1pbiIgYWxpZ25tZW50LWJhc2VsaW5lPSJjZW50cmFsIj48L3RleHQ+PC9zdmc+", | ||
296 | + "level": 1, | ||
297 | + "gender": 0, | ||
298 | + "birthday": null, | ||
299 | + "bio": "", | ||
300 | + "money": "0.00", | ||
301 | + "score": 0, | ||
302 | + "successions": 1, | ||
303 | + "maxsuccessions": 3, | ||
304 | + "prevtime": 1601340700, | ||
305 | + "logintime": 1602242130, | ||
306 | + "loginip": "127.0.0.1", | ||
307 | + "loginfailure": 0, | ||
308 | + "joinip": "127.0.0.1", | ||
309 | + "jointime": 1599914736, | ||
310 | + "createtime": 1599914736, | ||
311 | + "updatetime": 1602242130, | ||
312 | + "token": "", | ||
313 | + "status": "normal", | ||
314 | + "verification": { | ||
315 | + "email": 0, | ||
316 | + "mobile": 0 | ||
317 | + }, | ||
318 | + "pwd": null, | ||
319 | + "card": null, | ||
320 | + "sex": null, | ||
321 | + "phone": null, | ||
322 | + "work_address": null, | ||
323 | + "image": "", //头像 | ||
324 | + "expirationtime": null, | ||
325 | + "studynum": null, | ||
326 | + "message_count": 1, //未读消息数量 | ||
327 | + "url": "/u/15" | ||
328 | + } | ||
287 | }) | 329 | }) |
288 | */ | 330 | */ |
289 | public function index() | 331 | public function index() |
290 | { | 332 | { |
291 | $user = $this->auth->getUser(); | 333 | $user = $this->auth->getUser(); |
292 | $user->image = !empty($user->image) ? cdnurl($user->image,true) : ''; | 334 | $user->image = !empty($user->image) ? cdnurl($user->image,true) : ''; |
335 | + $user->message_count = Message::where('user_id',$user->id)->where('is_read','0')->count(); | ||
293 | $this->success('成功', $user); | 336 | $this->success('成功', $user); |
294 | } | 337 | } |
295 | 338 | ||
@@ -1039,7 +1082,7 @@ class User extends Api | @@ -1039,7 +1082,7 @@ class User extends Api | ||
1039 | } | 1082 | } |
1040 | 1083 | ||
1041 | /** | 1084 | /** |
1042 | - * @ApiWeigh (43) | 1085 | + * @ApiWeigh (44) |
1043 | * @ApiTitle (消息) | 1086 | * @ApiTitle (消息) |
1044 | * @ApiSummary (消息) | 1087 | * @ApiSummary (消息) |
1045 | * @ApiMethod (POST) | 1088 | * @ApiMethod (POST) |
@@ -1049,18 +1092,19 @@ class User extends Api | @@ -1049,18 +1092,19 @@ class User extends Api | ||
1049 | * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)") | 1092 | * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)") |
1050 | * | 1093 | * |
1051 | * @ApiReturn({ | 1094 | * @ApiReturn({ |
1052 | - "code": 1, | ||
1053 | - "msg": "成功", | ||
1054 | - "time": "1600167138", | ||
1055 | - "data": { | ||
1056 | - "total": 1, //数据总数 | ||
1057 | - "list": [{ | ||
1058 | - "id": 7, //消息ID | ||
1059 | - "title": "这是个消息", //消息标题 | ||
1060 | - "createtime": "2020.09.12 20:45" //发送时间 | ||
1061 | - }] | ||
1062 | - } | ||
1063 | - }) | 1095 | + "code": 1, |
1096 | + "msg": "成功", | ||
1097 | + "time": "1602813893", | ||
1098 | + "data": { | ||
1099 | + "total": 1, //数据总数 | ||
1100 | + "list": [{ | ||
1101 | + "id": 7, //消息ID | ||
1102 | + "title": "这是个消息", //消息标题 | ||
1103 | + "is_read": "1", //是否已读:0=否,1=是 | ||
1104 | + "createtime": "2020.09.12 20:45" //发送时间 | ||
1105 | + }] | ||
1106 | + } | ||
1107 | + }) | ||
1064 | */ | 1108 | */ |
1065 | public function messageList() | 1109 | public function messageList() |
1066 | { | 1110 | { |
@@ -1071,13 +1115,41 @@ class User extends Api | @@ -1071,13 +1115,41 @@ class User extends Api | ||
1071 | ->paginate($page_num,false,['page'=>$page]) | 1115 | ->paginate($page_num,false,['page'=>$page]) |
1072 | ->each(function($v){ | 1116 | ->each(function($v){ |
1073 | $v['createtime'] = date('Y.m.d H:i',$v['createtime']); | 1117 | $v['createtime'] = date('Y.m.d H:i',$v['createtime']); |
1074 | - $v->visible(['id','title','createtime']); | 1118 | + $v->visible(['id','title','is_read','createtime']); |
1075 | })->toArray(); | 1119 | })->toArray(); |
1076 | $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]); | 1120 | $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]); |
1077 | } | 1121 | } |
1078 | 1122 | ||
1079 | /** | 1123 | /** |
1080 | * @ApiWeigh (43) | 1124 | * @ApiWeigh (43) |
1125 | + * @ApiTitle (消息-一键已读) | ||
1126 | + * @ApiSummary (消息-一键已读) | ||
1127 | + * @ApiMethod (POST) | ||
1128 | + * | ||
1129 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
1130 | + * | ||
1131 | + * @ApiReturn({ | ||
1132 | + "code": 1, | ||
1133 | + "msg": "成功", | ||
1134 | + "time": "1600167138", | ||
1135 | + "data": { | ||
1136 | + "total": 1, //数据总数 | ||
1137 | + "list": [{ | ||
1138 | + "id": 7, //消息ID | ||
1139 | + "title": "这是个消息", //消息标题 | ||
1140 | + "createtime": "2020.09.12 20:45" //发送时间 | ||
1141 | + }] | ||
1142 | + } | ||
1143 | + }) | ||
1144 | + */ | ||
1145 | + public function allRead() | ||
1146 | + { | ||
1147 | + Message::where('user_id',$this->auth->id)->update(['is_read'=>'1']); | ||
1148 | + $this->success('成功'); | ||
1149 | + } | ||
1150 | + | ||
1151 | + /** | ||
1152 | + * @ApiWeigh (43) | ||
1081 | * @ApiTitle (消息-详情) | 1153 | * @ApiTitle (消息-详情) |
1082 | * @ApiSummary (消息-详情) | 1154 | * @ApiSummary (消息-详情) |
1083 | * @ApiMethod (POST) | 1155 | * @ApiMethod (POST) |
此 diff 太大无法显示。
-
请 注册 或 登录 后发表评论