LedgerWallet.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace app\admin\controller\ledger;
  3. use app\common\controller\Backend;
  4. use app\common\model\UserModel;
  5. use fast\Action;
  6. use think\exception\DbException;
  7. use think\response\Json;
  8. /**
  9. * 资产余额管理
  10. *
  11. * @icon fa fa-circle-o
  12. */
  13. class LedgerWallet extends Backend
  14. {
  15. /**
  16. * LedgerWallet模型对象
  17. * @var \app\admin\model\LedgerWallet
  18. */
  19. protected $model = null;
  20. public function _initialize()
  21. {
  22. parent::_initialize();
  23. $this->model = new \app\common\model\LedgerWalletModel();
  24. }
  25. /**
  26. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  27. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  28. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  29. */
  30. /**
  31. * 查看
  32. *
  33. * @return string|Json
  34. * @throws \think\Exception
  35. * @throws DbException
  36. */
  37. public function index()
  38. {
  39. //设置过滤方法
  40. $this->request->filter(['strip_tags', 'trim']);
  41. if (false === $this->request->isAjax()) {
  42. return $this->view->fetch();
  43. }
  44. //如果发送的来源是 Selectpage,则转发到 Selectpage
  45. if ($this->request->request('keyField')) {
  46. return $this->selectpage();
  47. }
  48. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  49. $list = $this->model->with('users')
  50. ->where($where)
  51. ->order($sort, $order)
  52. ->paginate($limit);
  53. $result = ['total' => $list->total(), 'rows' => $list->items()];
  54. return json($result);
  55. }
  56. }