Award.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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\UserAwardRepository;
  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 Award extends BaseController
  25. {
  26. /**
  27. * @var UserAwardRepository
  28. */
  29. protected $repository;
  30. /**
  31. * Config constructor.
  32. * @param App $app
  33. * @param UserAwardRepository $repository
  34. */
  35. public function __construct(App $app, UserAwardRepository $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. * @return mixed
  57. * @throws DataNotFoundException
  58. * @throws DbException
  59. * @throws ModelNotFoundException
  60. * @throws FormBuilderException
  61. * @author xaboy
  62. * @day 2020-03-31
  63. */
  64. public function updateTable()
  65. {
  66. $data = $this->request->param();
  67. $form = $this->repository->updateForm($data);
  68. return app('json')->success(formToData($form));
  69. }
  70. /**
  71. * @param int $key
  72. * @return mixed
  73. * @throws DbException
  74. * @author xaboy
  75. * @day 2020-03-27
  76. */
  77. public function update($key)
  78. {
  79. $data = $this->request->param();
  80. $this->repository->updateAward($key,$data);
  81. return app('json')->success('修改成功');
  82. }
  83. }