CheckPower.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. namespace app\common\service;
  3. use app\common\model\ArticleCate;
  4. use app\common\model\ArticleIntro;
  5. use app\common\model\ArticleItem;
  6. use app\common\model\DatumCate;
  7. use app\common\model\DatumIntro;
  8. use app\common\model\DatumUrl;
  9. use app\common\model\DiscountActivity;
  10. use app\common\model\DiscountGoods;
  11. use app\common\model\GoodsCate;
  12. use app\common\model\GroupActivity;
  13. use app\common\model\GroupGoods;
  14. use app\common\model\PlatformDemand;
  15. use app\common\model\Press;
  16. use app\common\model\Recruit;
  17. use app\common\model\RecruitCate;
  18. use app\common\model\ReductionActivity;
  19. use app\common\model\SeckillActivity;
  20. use app\common\model\SeckillGoods;
  21. use app\common\model\SeriesArticleCate;
  22. use app\common\model\SeriesVideoCate;
  23. use app\common\model\StoreGoods;
  24. use app\common\model\Supplier;
  25. use app\common\model\SupplierCate;
  26. use app\common\model\SupplierGoods;
  27. use app\common\model\UserForum;
  28. use app\common\model\VideoCate;
  29. use app\common\model\VideoIntro;
  30. use app\common\model\VideoUrl;
  31. /**
  32. * 验证权限
  33. * Class Activity
  34. */
  35. class CheckPower
  36. {
  37. // 检查各个模块详情是否能跳转
  38. public static function checkModulesPower($first_id,$second_id,$module)
  39. {
  40. $check_val = 1;
  41. $module= strtolower($module);
  42. switch ($module)
  43. {
  44. case 'video':
  45. $item = VideoUrl::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
  46. if(!$item) return 0;
  47. $parent = VideoIntro::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  48. if(!$parent) return 0;
  49. if($parent->type == 1)
  50. {
  51. $cate = VideoCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  52. ->where('status',1)->where('is_deleted',0)->count();
  53. }else{
  54. $cate = SeriesVideoCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  55. ->where('status',1)->where('is_deleted',0)->count();
  56. }
  57. if($cate != 2) return 0;
  58. break;
  59. case 'article':
  60. $item = ArticleItem::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
  61. if(!$item) return 0;
  62. $parent = ArticleIntro::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  63. if(!$parent) return 0;
  64. if($parent->type == 1)
  65. {
  66. $cate = ArticleCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  67. ->where('status',1)->where('is_deleted',0)->count();
  68. }else{
  69. $cate = SeriesArticleCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  70. ->where('status',1)->where('is_deleted',0)->count();
  71. }
  72. if($cate != 2) return 0;
  73. break;
  74. case 'datum':
  75. $item = DatumUrl::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
  76. if(!$item) return 0;
  77. $parent = DatumIntro::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  78. if(!$parent) return 0;
  79. if(!$parent->datum_cate) return 1;
  80. $cate = DatumCate::where('id','in',[$parent->datum_cate])
  81. ->where('status',1)->where('is_deleted',0)->count();
  82. if($cate != 1) return 0;
  83. break;
  84. case 'press':
  85. $item = Press::where('id',$first_id)->where('status',1)->where('is_deleted',0)->value('id');
  86. if(!$item) return 0;
  87. break;
  88. case 'forum':
  89. $item = UserForum::where('id',$first_id)->where('status',1)->where('is_deleted',0)->value('id');
  90. if(!$item) return 0;
  91. break;
  92. case 'recruit':
  93. $item = Recruit::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  94. if(!$item) return 0;
  95. $cate = RecruitCate::where('id','in',[$item->first_classify,$item->second_classify])
  96. ->where('status',1)->where('is_deleted',0)->count();
  97. if($cate != 2) return 0;
  98. break;
  99. case 'mall':
  100. $item = StoreGoods::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  101. if(!$item) return 0;
  102. $cate = GoodsCate::where('id','in',[$item->first_classify,$item->second_classify])
  103. ->where('status',1)->where('is_deleted',0)->count();
  104. if($cate != 2) return 0;
  105. break;
  106. case 'supplier':
  107. $item = SupplierGoods::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  108. if(!$item) return 0;
  109. $parent = Supplier::where('id',$item->supplier_id)->where('status',1)->where('is_deleted',0)->find();
  110. if(!$parent) return 0;
  111. $cate = SupplierCate::where('id','in',[$parent->first_classify,$parent->second_classify])
  112. ->where('status',1)->where('is_deleted',0)->count();
  113. if($cate != 2) return 0;
  114. break;
  115. case 'demand':
  116. $item = PlatformDemand::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  117. if(!$item) return 0;
  118. break ;
  119. case 'activity':
  120. $item = \app\common\model\Activity::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
  121. if(!$item) return 0;
  122. break;
  123. }
  124. return $check_val;
  125. }
  126. // 检查各个模块是否能跳转
  127. public static function checkItemPower($first_id,$second_id,$module)
  128. {
  129. }
  130. }