PageCategroy.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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\admin\system\diy;
  12. use app\common\repositories\system\diy\PageCategoryRepository;
  13. use app\common\repositories\system\diy\PageLinkRepository;
  14. use crmeb\basic\BaseController;
  15. use think\App;
  16. class PageCategroy extends BaseController
  17. {
  18. protected $repository;
  19. public function __construct(App $app, PageCategoryRepository $repository)
  20. {
  21. parent::__construct($app);
  22. $this->repository = $repository;
  23. }
  24. /**
  25. * 列表
  26. * @return mixed
  27. * @author Qinii
  28. */
  29. public function lst()
  30. {
  31. $where['is_mer'] = $this->request->param('type',0);
  32. return app('json')->success($this->repository->getFormatList($where));
  33. }
  34. /**
  35. * @Author:Qinii
  36. * @Date: 2020/5/11
  37. * @return mixed
  38. */
  39. public function createForm()
  40. {
  41. $type = $this->request->param('type',0);
  42. return app('json')->success(formToData($this->repository->form(0,$type)));
  43. }
  44. public function create()
  45. {
  46. $data = $this->request->params([
  47. 'pid',
  48. 'type',
  49. 'name',
  50. 'status',
  51. 'sort',
  52. 'is_mer',
  53. [ 'level',3],
  54. ]);
  55. $this->repository->create($data);
  56. return app('json')->success('添加成功');
  57. }
  58. public function updateForm($id)
  59. {
  60. return app('json')->success(formToData($this->repository->form($id)));
  61. }
  62. public function update($id)
  63. {
  64. $data = $this->request->params([
  65. 'pid',
  66. 'type',
  67. 'name',
  68. 'status',
  69. 'sort',
  70. 'is_mer'
  71. ]);
  72. $this->repository->update($id, $data);
  73. return app('json')->success('编辑成功');
  74. }
  75. public function options()
  76. {
  77. $type = $this->request->param('type',0);
  78. return app('json')->success($this->repository->getSonCategoryList($type,0));
  79. }
  80. public function switchStatus($id)
  81. {
  82. $status = $this->request->param('status') == 1 ? 1: 0;
  83. $this->repository->update($id,['status' => $status]);
  84. return app('json')->success('修改成功');
  85. }
  86. public function delete($id)
  87. {
  88. $this->repository->delete($id);
  89. return app('json')->success('删除成功');
  90. }
  91. }