64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\operation;
|
|
|
|
use app\common\controller\Backend;
|
|
use support\Response;
|
|
use Webman\Http\Request as WebmanRequest;
|
|
|
|
/**
|
|
* 用户公告阅读记录
|
|
*/
|
|
class UserNoticeRead extends Backend
|
|
{
|
|
protected ?object $model = null;
|
|
|
|
protected string|array $preExcludeFields = ['id', 'create_time'];
|
|
|
|
protected string|array $quickSearchField = ['id', 'user_id', 'notice_id'];
|
|
|
|
protected string|array $defaultSortField = ['id' => 'desc'];
|
|
|
|
protected string|array $orderGuarantee = ['id' => 'desc'];
|
|
|
|
protected array $withJoinTable = ['user', 'operationNotice'];
|
|
|
|
protected bool $modelValidate = true;
|
|
|
|
protected bool $modelSceneValidate = true;
|
|
|
|
protected function initController(WebmanRequest $request): ?Response
|
|
{
|
|
$this->model = new \app\common\model\UserNoticeRead();
|
|
return null;
|
|
}
|
|
|
|
protected function _index(): Response
|
|
{
|
|
if ($this->request && $this->request->get('select')) {
|
|
return $this->select($this->request);
|
|
}
|
|
|
|
list($where, $alias, $limit, $order) = $this->queryBuilder();
|
|
$table = strtolower($this->model->getTable());
|
|
$mainShort = $alias[$table] ?? '';
|
|
if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) {
|
|
$where[] = ['user.admin_id', '=', intval(strval($this->auth->id))];
|
|
}
|
|
|
|
$res = $this->model
|
|
->withJoin($this->withJoinTable, $this->withJoinType)
|
|
->with($this->withJoinTable)
|
|
->alias($alias)
|
|
->where($where)
|
|
->order($order)
|
|
->paginate($limit);
|
|
|
|
return $this->success('', [
|
|
'list' => $res->items(),
|
|
'total' => $res->total(),
|
|
'remark' => get_route_remark(),
|
|
]);
|
|
}
|
|
}
|