Initial commit: 小众厨房项目代码

Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
可乐加冰
2026-09-23 17:04:10 +08:00
当前提交 f7d3d7d1bd
共有 1761 个文件被更改,包括 453668 次插入 和 0 次删除

查看文件

@@ -0,0 +1,94 @@
<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\ContentCategoryModel;
use app\common\model\ContentModel;
use app\common\model\NoticeModel;
use think\Db;
/**
* 公告
* Class Notice
* @package app\api\controller
*/
class Notice extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 公告列表
* @param NoticeModel $noticeModel
* @throws \think\exception\DbException
*/
public function index(NoticeModel $noticeModel)
{
$page = $this->request->get('page/d', 1);
$key = $this->request->get('key', '');
$type = $this->request->get('type', 1);
$result = $noticeModel->getLists([
'search' => [
'title' => $key,
'type' => $type
],
], 10, $page, [
'id',
'title',
'cover',
'desc',
'views'
]);
$this->success('获取成功', [
'total' => $result['total'],
'pageSize' => $result['pageSize'],
'totalSize' => $result['totalSize'],
'list' => $result['list'],
]);
}
/**
* 公告详情
* @param NoticeModel $noticeModel
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function detail(NoticeModel $noticeModel)
{
$id = $this->request->get('id/d');
if (empty($id)) {
$this->success('参数错误', [], 501);
}
$detail = $noticeModel->getItem($id, [
'id',
'title',
'views',
'content',
'create_time',
'status'
]);
if (empty($detail)) {
$this->success('内容不存在', [], 502);
}
if ($detail->status == 2) {
$this->success('内容以下架', [], 502);
}
// 浏览量+1
$detail->views += 1;
$noticeModel->where(['id' => $id])->setInc('views');
$detail->create_time = date('Y-m-d H:i:s', $detail->create_time);
$this->success('获取成功', [
'detail' => $detail
]);
}
}