| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\api\controller\v2;
- use app\api\controller\Api;
- class SystemMessage extends Api
- {
- public function getMessageList()
- {
- $checkResult = $this->validate($this->input,
- [
- ['page', 'require|integer|egt:1', '页数不能为空|页数必须是整数|页数必须大于1'],
- ['pageSize', 'require|integer|egt:10', '页码不能为空|页码必须是整数|页码必须大于10'],
- ]);
- if (true !== $checkResult) {
- $this->jsonResult('', 0, $checkResult);
- }
- $list = model('SystemMessage')
- ->where('member_id', $this->input['userid'])
- ->order("id desc")
- ->paginate(['list_rows' => $this->input['pageSize'], 'page' => $this->input['page']])
- ->toArray();
- $this->jsonResult($list, 1, '获取数据成功');
- }
- public function getMessageDetail(){
- $checkResult = $this->validate($this->input,
- [
- ['id', 'require|integer|egt:1', '记录不能为空|记录必须是整数|记录必须大于1']
- ]);
- if (true !== $checkResult) {
- $this->jsonResult('', 0, $checkResult);
- }
- $info = model('SystemMessage')
- ->where('id', $this->input['id'])
- ->where('member_id', $this->input['userid'])
- ->find();
- if($info && $info['is_show'] == 1){
- model('SystemMessage')
- ->where('id', $this->input['id'])
- ->where('member_id', $this->input['userid'])
- ->update(['is_show'=>2,'update_time'=>time()]);
- }
- $this->jsonResult($info, 1, '获取数据成功');
- }
- public function read(){
- model('SystemMessage')
- ->where('is_show', 1)
- ->where('member_id', $this->input['userid'])
- ->update(['is_show'=>2,'update_time'=>time()]);
- $this->jsonResult([], 1, '操作成功');
- }
- }
|