M250905150803AddRbacAuthItem.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace addons\Mch\console\migrations;
  3. use common\models\rbac\AuthItem;
  4. use yii\db\Migration;
  5. /**
  6. * Class M250905150803AddRbacAuthItem
  7. */
  8. class M250905150803AddRbacAuthItem extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $check = AuthItem::findOne(['name' => 'mch/diy/index']);
  16. if (!$check) {
  17. $sql = "INSERT INTO `qimall_rbac_auth_item`( `name`, `title`, `app_id`, `addons_name`, `pid`, `level`, `is_addon`, `sort`, `tree`, `status`, `created_at`, `updated_at`, `cate_id`) VALUES ('mch/diy/index', '装修', 'backend', 'Mch', 624955, 2, 1, 10, 'tr_0 tr_624955 ', 1, 1757056425, 1757056425, 1);";
  18. $this->execute($sql);
  19. }
  20. $check = AuthItem::findOne(['name' => 'mch/store-audit/index']);
  21. if (!$check) {
  22. $sql = "INSERT INTO `qimall_rbac_auth_item`( `name`, `title`, `app_id`, `addons_name`, `pid`, `level`, `is_addon`, `sort`, `tree`, `status`, `created_at`, `updated_at`, `cate_id`) VALUES ('mch/store-audit/index', '商户审核', 'backend', 'Mch', 624955, 2, 1, 30, 'tr_0 tr_624955 ', 1, 1757056425, 1757056425, 1);";
  23. $this->execute($sql);
  24. }
  25. $check = AuthItem::findOne(['name' => 'mch/store-category/index']);
  26. if (!$check) {
  27. $sql = "INSERT INTO `qimall_rbac_auth_item`( `name`, `title`, `app_id`, `addons_name`, `pid`, `level`, `is_addon`, `sort`, `tree`, `status`, `created_at`, `updated_at`, `cate_id`) VALUES ('mch/store-category/index', '商户分类', 'backend', 'Mch', 624955, 2, 1, 40, 'tr_0 tr_624955 ', 1, 1757056425, 1757056425, 1);";
  28. $this->execute($sql);
  29. }
  30. $sql = "UPDATE `qimall_rbac_auth_item` SET `sort` = 20 WHERE `name` = 'mch/store/index' and `addons_name` = 'Mch';
  31. UPDATE `qimall_rbac_auth_item` SET `sort` = 50 WHERE `name` = 'mch/store-order/index' and `addons_name` = 'Mch';
  32. UPDATE `qimall_rbac_auth_item` SET `sort` = 60 WHERE `name` = 'mch/store-order/refund-list' and `addons_name` = 'Mch';
  33. UPDATE `qimall_rbac_auth_item` SET `sort` = 70 WHERE `name` = 'mch/store-goods/index' and `addons_name` = 'Mch';
  34. UPDATE `qimall_rbac_auth_item` SET `sort` = 80 WHERE `name` = 'mch/store-assets/index' and `addons_name` = 'Mch';
  35. UPDATE `qimall_rbac_auth_item` SET `sort` = 90 WHERE `name` = 'mch/store-cashdraw/index' and `addons_name` = 'Mch';
  36. UPDATE `qimall_rbac_auth_item` SET `sort` = 100 WHERE `name` = 'mch/store-setting/index' and `addons_name` = 'Mch'";
  37. $this->execute($sql);
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function safeDown()
  43. {
  44. echo "M250905150803AddRbacAuthItem cannot be reverted.\n";
  45. return false;
  46. }
  47. }