diff --git a/app/controller/api/CommonController.php b/app/controller/api/CommonController.php index f87f68f..e10c82a 100644 --- a/app/controller/api/CommonController.php +++ b/app/controller/api/CommonController.php @@ -8,6 +8,7 @@ use App\Utils\ApiResponseApp; use App\model\Dictionary; +use App\model\Message; use App\model\ExchangeRate; use hg\apidoc\annotation as Apidoc; use support\Db; @@ -60,30 +61,37 @@ class CommonController * @Apidoc\Title("1.0 消息根据type 判断类型") * @Apidoc\Url("api/common/messageList") * 3是首页弹窗 1是消息中心 - * { - "data": [ - { - "id": 2, - "title": "Announcement", - "content": "


", - "status": 1, - "createtime": 1737370611, - "updatetime": 0, - "status_text": "Status 1" - } - ], - "total": 0 -} * @Apidoc\Method("POST") */ public function messageList(Request $request){ - $type=$request->get('type'); - /** - * 返回轮播图 - */ - if($type==5){ + $type = $request->get('type'); + $query = Message::query(); + if ($type == 5) { + // 大于 type(注意:这里假设你想比较的是 'id' 字段) + $query->where('id', '>', $type); } + + if ($type == 3) { + // 小于 type(同样假设是 'id' 字段) + $query->where('id', '<', $type); + } + + if ($type == 1) { + // 等于特定值(这里是6) + $query->where('id', '=', 6); + } + + // 执行查询并获取结果 + $list = $query->get(); + var_dump(1111); + + // 准备返回的数据 + $map = [ + 'data' => $list->toArray(), + ]; + + return ApiResponseApp::success($map); } } diff --git a/app/model/Message.php b/app/model/Message.php new file mode 100644 index 0000000..8956f01 --- /dev/null +++ b/app/model/Message.php @@ -0,0 +1,25 @@ +