Identity.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020-03-24
  7. *
  8. *
  9. */
  10. namespace app\controller\admin\system\config;
  11. use crmeb\basic\BaseController;
  12. use app\common\repositories\user\UserIdentityRepository;
  13. use FormBuilder\Exception\FormBuilderException;
  14. use think\App;
  15. use think\db\exception\DataNotFoundException;
  16. use think\db\exception\DbException;
  17. use think\db\exception\ModelNotFoundException;
  18. /**
  19. * Class Config
  20. * @package app\controller\admin\system\config
  21. * @author xaboy
  22. * @day 2020-03-27
  23. */
  24. class Identity extends BaseController
  25. {
  26. /**
  27. * @var UserIdentityRepository
  28. */
  29. protected $repository;
  30. /**
  31. * Config constructor.
  32. * @param App $app
  33. * @param UserIdentityRepository $repository
  34. */
  35. public function __construct(App $app, UserIdentityRepository $repository)
  36. {
  37. parent::__construct($app);
  38. $this->repository = $repository;
  39. }
  40. /**
  41. * @return mixed
  42. * @throws DataNotFoundException
  43. * @throws DbException
  44. * @throws ModelNotFoundException
  45. * @author xaboy
  46. * @day 2020-03-31
  47. */
  48. public function lst()
  49. {
  50. $where = $this->request->params(['keyword']);
  51. [$page, $limit] = $this->getPage();
  52. $lst = $this->repository->getList($where, $page, $limit);
  53. return app('json')->success($lst);
  54. }
  55. /**
  56. * @param int $id
  57. * @return mixed
  58. * @throws DataNotFoundException
  59. * @throws DbException
  60. * @throws ModelNotFoundException
  61. * @throws FormBuilderException
  62. * @author xaboy
  63. * @day 2020-03-31
  64. */
  65. public function updateTable($id)
  66. {
  67. if (!$this->repository->exists($id)) app('json')->fail('数据不存在');
  68. $form = $this->repository->updateForm($id);
  69. return app('json')->success(formToData($form));
  70. }
  71. /**
  72. * @param int $id
  73. * @return mixed
  74. * @throws DbException
  75. * @author xaboy
  76. * @day 2020-03-27
  77. */
  78. public function update($id)
  79. {
  80. $data = $this->request->params(['arrive_num_own', 'arrive_num_team']);
  81. $this->repository->update($id, $data);
  82. return app('json')->success('修改成功');
  83. }
  84. }