GoodsCategory.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\approve\controller;
  15. use app\common\constant\CommonConstant;
  16. use app\common\constant\MaintainConstant;
  17. use app\common\service\GoodsCategoryService;
  18. use library\Controller;
  19. use library\tools\Data;
  20. /**
  21. * 商品分类
  22. */
  23. class GoodsCategory extends Controller
  24. {
  25. /**
  26. * 绑定数据表
  27. * @var string
  28. */
  29. protected $table = 'GoodsCategory';
  30. /**
  31. * 控制器初始化
  32. */
  33. protected function initialize()
  34. {
  35. $this->get_type_title_list = MaintainConstant::get_type_title_list();
  36. }
  37. /**
  38. * 列表
  39. * @auth true
  40. * @menu true
  41. * @throws \think\Exception
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\ModelNotFoundException
  44. * @throws \think\exception\DbException
  45. */
  46. public function index()
  47. {
  48. $this->title = '商品分类列表';
  49. $query = $this->_query($this->table)
  50. ->field('is_deleted', true)
  51. ->where('is_deleted',CommonConstant::IS_DELETED_0)
  52. ->order('sort desc,id asc');
  53. $query->page(false);
  54. }
  55. /**
  56. * 列表数据处理
  57. * @param array $data
  58. * @throws \Exception
  59. */
  60. protected function _index_page_filter(&$data)
  61. {
  62. if($data) {
  63. foreach ($data as &$vo) {
  64. $vo['ids'] = join(',', Data::getArrSubIds($data, $vo['id']));
  65. }
  66. $data = Data::arr2table($data);
  67. }
  68. }
  69. /**
  70. * 添加
  71. * @auth true
  72. * @throws \think\Exception
  73. * @throws \think\db\exception\DataNotFoundException
  74. * @throws \think\db\exception\ModelNotFoundException
  75. * @throws \think\exception\DbException
  76. * @throws \think\exception\PDOException
  77. */
  78. public function add()
  79. {
  80. $this->title = '添加';
  81. $this->_form($this->table, 'form');
  82. }
  83. /**
  84. * 编辑
  85. * @auth true
  86. * @throws \think\Exception
  87. * @throws \think\db\exception\DataNotFoundException
  88. * @throws \think\db\exception\ModelNotFoundException
  89. * @throws \think\exception\DbException
  90. * @throws \think\exception\PDOException
  91. */
  92. public function edit()
  93. {
  94. $this->title = '编辑';
  95. $this->_form($this->table, 'form');
  96. }
  97. /**
  98. * 表单处理
  99. * @param array $data
  100. * @throws \think\db\exception\DataNotFoundException
  101. * @throws \think\db\exception\ModelNotFoundException
  102. * @throws \think\exception\DbException
  103. */
  104. protected function _form_filter(&$data)
  105. {
  106. if ($this->request->isGet()) {
  107. $this->cate_list = GoodsCategoryService::get_list([]);
  108. }
  109. if ($this->request->isPost()) {
  110. }
  111. }
  112. /**
  113. * 删除
  114. * @auth true
  115. * @throws \think\Exception
  116. * @throws \think\exception\PDOException
  117. */
  118. public function remove()
  119. {
  120. $this->applyCsrfToken();
  121. $this->_delete($this->table);
  122. }
  123. }