feat: 新增

This commit is contained in:
陈狼 2025-02-23 17:22:44 +08:00
parent dd55b301a8
commit a6941b8a81
4 changed files with 52 additions and 19 deletions

View File

@ -8,6 +8,7 @@ use App\Utils\ApiResponseApp;
use App\model\Dictionary; use App\model\Dictionary;
use App\model\Message;
use App\model\ExchangeRate; use App\model\ExchangeRate;
use hg\apidoc\annotation as Apidoc; use hg\apidoc\annotation as Apidoc;
use support\Db; use support\Db;
@ -60,30 +61,37 @@ class CommonController
* @Apidoc\Title("1.0 消息根据type 判断类型") * @Apidoc\Title("1.0 消息根据type 判断类型")
* @Apidoc\Url("api/common/messageList") * @Apidoc\Url("api/common/messageList")
* 3是首页弹窗 1是消息中心 * 3是首页弹窗 1是消息中心
* {
"data": [
{
"id": 2,
"title": "Announcement",
"content": "<p><img src=\"https://112233job.com/uploads/20250120/039faa1fb225ef5814a325218f2e00ee.jpg\" data-filename=\"filename\" style=\"width: 277.516px; height: 275.69px;\"><br></p>",
"status": 1,
"createtime": 1737370611,
"updatetime": 0,
"status_text": "Status 1"
}
],
"total": 0
}
* @Apidoc\Method("POST") * @Apidoc\Method("POST")
*/ */
public function messageList(Request $request){ public function messageList(Request $request){
$type=$request->get('type'); $type = $request->get('type');
/** $query = Message::query();
* 返回轮播图
*/
if($type==5){
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);
} }
} }

25
app/model/Message.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace app\model;
use support\Model;
class Message extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'message';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
public $timestamps = false;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

After

Width:  |  Height:  |  Size: 186 KiB