|
@@ -0,0 +1,116 @@
|
|
|
+<?php
|
|
|
+namespace app\common\service;
|
|
|
+use app\common\model\ArticleCate;
|
|
|
+use app\common\model\ArticleIntro;
|
|
|
+use app\common\model\ArticleItem;
|
|
|
+use app\common\model\DatumCate;
|
|
|
+use app\common\model\DatumIntro;
|
|
|
+use app\common\model\DatumUrl;
|
|
|
+use app\common\model\DiscountActivity;
|
|
|
+use app\common\model\DiscountGoods;
|
|
|
+use app\common\model\GoodsCate;
|
|
|
+use app\common\model\GroupActivity;
|
|
|
+use app\common\model\GroupGoods;
|
|
|
+use app\common\model\PlatformDemand;
|
|
|
+use app\common\model\Press;
|
|
|
+use app\common\model\Recruit;
|
|
|
+use app\common\model\RecruitCate;
|
|
|
+use app\common\model\ReductionActivity;
|
|
|
+use app\common\model\SeckillActivity;
|
|
|
+use app\common\model\SeckillGoods;
|
|
|
+use app\common\model\StoreGoods;
|
|
|
+use app\common\model\Supplier;
|
|
|
+use app\common\model\SupplierCate;
|
|
|
+use app\common\model\SupplierGoods;
|
|
|
+use app\common\model\UserForum;
|
|
|
+use app\common\model\VideoCate;
|
|
|
+use app\common\model\VideoIntro;
|
|
|
+use app\common\model\VideoUrl;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证权限
|
|
|
+ * Class Activity
|
|
|
+ */
|
|
|
+class CheckPower
|
|
|
+{
|
|
|
+ // 检查各个模块是否能跳转
|
|
|
+ public static function checkModulesPower($first_id,$second_id,$module)
|
|
|
+ {
|
|
|
+ $check_val = 1;
|
|
|
+ $module= strtolower($module);
|
|
|
+ switch ($module)
|
|
|
+ {
|
|
|
+ case 'video':
|
|
|
+ $item = VideoUrl::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
|
|
|
+ if(!$item) return 0;
|
|
|
+ $parent = VideoIntro::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
|
|
|
+ if(!$parent) return 0;
|
|
|
+ $cate = VideoCate::where('id','in',[$parent->first_classify,$parent->second_classify])
|
|
|
+ ->where('status',1)->where('is_deleted',0)->count();
|
|
|
+ if(count($cate) != 2) return 0;
|
|
|
+ break;
|
|
|
+ case 'article':
|
|
|
+ $item = ArticleItem::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
|
|
|
+ if(!$item) return 0;
|
|
|
+ $parent = ArticleIntro::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
|
|
|
+ if(!$parent) return 0;
|
|
|
+ $cate = ArticleCate::where('id','in',[$parent->first_classify,$parent->second_classify])
|
|
|
+ ->where('status',1)->where('is_deleted',0)->count();
|
|
|
+ if(count($cate) != 2) return 0;
|
|
|
+ break;
|
|
|
+ case 'datum':
|
|
|
+ $item = DatumUrl::where('id',$second_id)->where('status',1)->where('is_deleted',0)->value('id');
|
|
|
+ if(!$item) return 0;
|
|
|
+ $parent = DatumIntro::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
|
|
|
+ if(!$parent) return 0;
|
|
|
+ $cate = DatumCate::where('id','in',[$parent->first_classify,$parent->second_classify])
|
|
|
+ ->where('status',1)->where('is_deleted',0)->count();
|
|
|
+ if(count($cate) != 2) return 0;
|
|
|
+ break;
|
|
|
+ case 'press':
|
|
|
+ $item = Press::where('id',$first_id)->where('status',1)->where('is_deleted',0)->value('id');
|
|
|
+ if(!$item) return 0;
|
|
|
+ break;
|
|
|
+ case 'forum':
|
|
|
+ $item = UserForum::where('id',$first_id)->where('status',1)->where('is_deleted',0)->value('id');
|
|
|
+ if(!$item) return 0;
|
|
|
+ break;
|
|
|
+ case 'recruit':
|
|
|
+ $item = Recruit::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
|
|
|
+ if(!$item) return 0;
|
|
|
+ $cate = RecruitCate::where('id','in',[$item->first_classify,$item->second_classify])
|
|
|
+ ->where('status',1)->where('is_deleted',0)->count();
|
|
|
+ if(count($cate) != 2) return 0;
|
|
|
+ break;
|
|
|
+ case 'mall':
|
|
|
+ $item = StoreGoods::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
|
|
|
+ if(!$item) return 0;
|
|
|
+ $cate = GoodsCate::where('id','in',[$item->first_classify,$item->second_classify])
|
|
|
+ ->where('status',1)->where('is_deleted',0)->count();
|
|
|
+ if(count($cate) != 2) return 0;
|
|
|
+ break;
|
|
|
+ case 'supplier':
|
|
|
+ $item = SupplierGoods::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
|
|
|
+ if(!$item) return 0;
|
|
|
+ $parent = Supplier::where('id',$item->supplier_id)->where('status',1)->where('is_deleted',0)->find();
|
|
|
+ if(!$parent) return 0;
|
|
|
+ $cate = SupplierCate::where('id','in',[$parent->first_classify,$parent->second_classify])
|
|
|
+ ->where('status',1)->where('is_deleted',0)->count();
|
|
|
+ if(count($cate) != 2) return 0;
|
|
|
+ break;
|
|
|
+ case 'demand':
|
|
|
+ $item = PlatformDemand::where('id',$first_id)->where('status',1)->where('is_deleted',0)->find();
|
|
|
+ if(!$item) return 0;
|
|
|
+ break ;
|
|
|
+ }
|
|
|
+ return $check_val;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查各个模块是否能跳转
|
|
|
+ public static function checkItemPower($first_id,$second_id,$module)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|