Files
xianyan/docs/toolsapi/application/admin/controller/UserNote.php
Developer b6441a8919 api
2026-04-27 23:47:18 +08:00

46 lines
1.3 KiB
PHP

<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 用户笔记管理
* @icon fa fa-sticky-note
* @time 2026-04-26
* @description 管理用户笔记,管理员可设置上限
*/
class UserNote extends Backend
{
protected $model = null;
protected $relationSearch = true;
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\UserNote;
}
public function index()
{
$this->relationSearch = true;
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->with(['user'])
->where($where)
->order($sort, $order)
->paginate($limit);
foreach ($list as $row) {
$row->visible(['id', 'user_id', 'title', 'category', 'is_public', 'views', 'status', 'createtime', 'updatetime']);
$row->visible(['user']);
if ($row->user) $row->getRelation('user')->visible(['id', 'nickname']);
}
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
}