AuthGroupAccess.php 999 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\common\model;
  3. use app\common\library\Redis;
  4. use think\Log;
  5. use think\Model;
  6. class AuthGroupAccess extends Model
  7. {
  8. // 表名
  9. protected $table = 'auth_group_access';
  10. // 自动写入时间戳字段
  11. protected $autoWriteTimestamp = false;
  12. // 定义时间戳字段名
  13. protected $createTime = false;
  14. protected $updateTime = false;
  15. // 追加属性
  16. protected $append = [
  17. ];
  18. //获得分组权限ID
  19. public function getGroupId($adminId){
  20. $redis = Redis::instance();
  21. $key = 'AG:'.$adminId;
  22. if($redis->exists($key)){
  23. return $redis->get($key);
  24. }else{
  25. $ag = $this->where('uid',$adminId)->find();
  26. if(!empty($ag)){
  27. $redis->setex($key,86400,$ag->group_id);
  28. return $ag->group_id;
  29. }else{
  30. Log::notice('参数$adminId在数据库中不存在,没有找到');
  31. return 0;
  32. }
  33. }
  34. }
  35. }