MerchantContribute.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\controller\admin\merchant;
  3. use crmeb\basic\BaseController;
  4. use think\App;
  5. use app\common\repositories\merchant\apply\MerchantContributeRepository;
  6. class MerchantContribute extends BaseController
  7. {
  8. /**
  9. * @var MerchantContributeRepository
  10. */
  11. protected $repository;
  12. /**
  13. * MerchantContribute constructor.
  14. * @param MerchantContributeRepository $repository
  15. */
  16. public function __construct(App $app,MerchantContributeRepository $repository)
  17. {
  18. parent::__construct($app);
  19. $this->repository = $repository;
  20. }
  21. /**
  22. * @return mixed
  23. * @author Qinii
  24. */
  25. public function list()
  26. {
  27. return app('json')->success($this->repository->queryList());
  28. }
  29. public function add()
  30. {
  31. $data = $this->request->params([
  32. 'contribute_name',
  33. 'ratio_start',
  34. 'ratio_end',
  35. 'jing_dou',
  36. 'contribute_value'
  37. ]);
  38. $this->repository->add($data);
  39. return app('json')->success('添加成功');
  40. }
  41. public function edit()
  42. {
  43. $id = $this->request->id();
  44. if(empty($id)){
  45. return app('json')->fail('参数ID缺失');
  46. }
  47. $data = $this->request->params([
  48. 'contribute_name',
  49. 'ratio_start',
  50. 'ratio_end',
  51. 'jing_dou',
  52. 'contribute_value'
  53. ]);
  54. $this->repository->updateById($data, $id);
  55. return app('json')->success('更新成功');
  56. }
  57. public function delete()
  58. {
  59. $id = $this->request->id();
  60. if(empty($id)){
  61. return app('json')->fail('参数ID缺失');
  62. }
  63. $this->repository->deleteById($data, $id);
  64. return app('json')->success('删除成功');
  65. }
  66. }