fix:更新已知bug,优化代码
This commit is contained in:
@@ -3,10 +3,9 @@ declare (strict_types = 1);
|
||||
|
||||
namespace app\common\model\system;
|
||||
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\Model;
|
||||
use think\facade\Db;
|
||||
use think\model\concern\SoftDelete;
|
||||
use think\model\relation\HasMany;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
@@ -19,36 +18,12 @@ class UserGroup extends Model
|
||||
protected $createTime = 'create_time';
|
||||
protected $updateTime = 'update_time';
|
||||
|
||||
|
||||
/**
|
||||
* 关联用户组
|
||||
*
|
||||
* @return int|\think\model\relation\HasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function userTotal()
|
||||
public function userTotal(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class,'group_id','id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户组
|
||||
*
|
||||
* @param integer $id
|
||||
* @param boolean $mark
|
||||
* @return void|array
|
||||
* @throws DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function ToObtain(int $id = 0, bool $mark = true)
|
||||
{
|
||||
$groupList = system_cache('groupList');
|
||||
if (empty($groupList)) {
|
||||
$groupList = self::select()->toArray();
|
||||
system_cache('groupList',$groupList,86400);
|
||||
}
|
||||
|
||||
return $groupList;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user