ProductCdkey.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\merchant\store\product;
  12. use app\common\repositories\store\product\ProductCdkeyRepository;
  13. use app\validate\merchant\ProductCdkeyValidate;
  14. use crmeb\basic\BaseController;
  15. use think\App;
  16. use think\exception\ValidateException;
  17. /**
  18. * Class CdkeyLibrary
  19. * app\controller\merchant\store\product
  20. * 卡密信息
  21. */
  22. class ProductCdkey extends BaseController
  23. {
  24. protected $repository ;
  25. /**
  26. * ProductGroup constructor.
  27. * @param App $app
  28. * @param ProductCdkeyRepository $repository
  29. */
  30. public function __construct(App $app ,ProductCdkeyRepository $repository)
  31. {
  32. parent::__construct($app);
  33. $this->repository = $repository;
  34. }
  35. /**
  36. * 列表
  37. * @return \think\response\Json
  38. * @author Qinii
  39. */
  40. public function lst()
  41. {
  42. [$page, $limit] = $this->getPage();
  43. $where = $this->request->params(['library_id','status']);
  44. $where['mer_id'] = $this->request->merId();
  45. if (!$where['library_id']) return app('json')->fail('参数错误');
  46. $data = $this->repository->getList($where,$page,$limit);
  47. return app('json')->success($data);
  48. }
  49. /**
  50. * 添加表单
  51. * @return \think\response\Json
  52. * @author Qinii
  53. */
  54. public function create()
  55. {
  56. $data = $this->request->params(['csList','library_id']);
  57. app()->make(ProductCdkeyValidate::class)->check($data);
  58. $this->repository->save($data,$this->request->merId());
  59. return app('json')->success('添加成功');
  60. }
  61. /**
  62. * 修改
  63. * @param $id
  64. * @return \think\response\Json
  65. * @author Qinii
  66. */
  67. public function update($id)
  68. {
  69. $data = $this->request->params(['key','pwd']);
  70. $data['mer_id'] = $this->request->merId();
  71. $this->repository->edit($id,$data);
  72. return app('json')->success('修改成功');
  73. }
  74. /**
  75. * 删除
  76. * @param $id
  77. * @return \think\response\Json
  78. * @author Qinii
  79. */
  80. public function delete($id)
  81. {
  82. $this->repository->dostory($id,$this->request->merId());
  83. return app('json')->success('删除成功');
  84. }
  85. /**
  86. * 批量删除
  87. * @return void
  88. * @author Qinii
  89. */
  90. public function batchDelete()
  91. {
  92. $data = $this->request->params(['ids']);
  93. $this->repository->batchDelete($data['ids'],$this->request->merId());
  94. return app('json')->success('删除成功');
  95. }
  96. }