indexMethod.code 805 B

123456789101112131415161718192021
  1. #[NodeAnnotation(title: '列表', auth: true)]
  2. public function index(\app\Request $request): \think\response\Json|string
  3. {
  4. if ($request->isAjax()) {
  5. if (input('selectFields')) {
  6. return $this->selectList();
  7. }
  8. list($page, $limit, $where) = $this->buildTableParams();
  9. $count = self::$model::where($where)->{{relationIndexMethod}}->count();
  10. $list = self::$model::where($where)->{{relationIndexMethod}}->page($page, $limit)->order($this->sort)->select()->toArray();
  11. $data = [
  12. 'code' => 0,
  13. 'msg' => '',
  14. 'count' => $count,
  15. 'data' => $list,
  16. ];
  17. return json($data);
  18. }
  19. return $this->fetch();
  20. }