refactor: 附件

This commit is contained in:
2025-04-15 17:20:19 +08:00
parent 3f2c8ab540
commit e44dbbc9a2
11 changed files with 260 additions and 173 deletions

View File

@@ -4,6 +4,7 @@ declare (strict_types = 1);
namespace app\index\controller;
use app\index\model\AttachmentCategoryModel;
use app\index\model\AttachmentModel;
use think\facade\View;
/**
@@ -11,13 +12,66 @@ use think\facade\View;
*/
class Attachment extends Common
{
// 分页列表
/**
* 分页列表
*/
public function index()
{
// 获取分类
$category = AttachmentCategoryModel::language($this->lang_id)->select();
View::assign('category', $category);
$param = request()->param([
'id',
'page/d' => 1,
'size/d' => 12,
]);
// 获取附件分类
$categorys = AttachmentCategoryModel::field([
'id',
'name'
])
->language($this->lang_id)
->parent(0)
->isShow(true)
->select();
View::assign('categorys', $categorys);
// 获取附件
$attachements = AttachmentModel::field([
'id',
'name',
'desc',
'image',
'applicable_to',
'support_platform',
'attach',
])
->language($this->lang_id)
->category($param['id']??null)
->paginate([
'list_rows' => $param['size'],
'page' => $param['page'],
]);
View::assign('attachements', $attachements);
View::assign('page', $attachements->render());
return View::fetch('index');
}
/**
* 视频
*/
public function video()
{
// 获取附件分类
$categorys = AttachmentCategoryModel::field([
'id',
'name'
])
->language($this->lang_id)
->parent(0)
->isShow(true)
->select();
View::assign('categorys', $categorys);
return View::fetch('video');
}
}