fix:更新已知bug,优化代码

This commit is contained in:
Ying
2022-11-28 19:11:12 +08:00
parent f6aee95cfc
commit 9445b206a2
1378 changed files with 53759 additions and 20789 deletions

View File

@@ -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;
}
}
}