// +---------------------------------------------------------------------- namespace app\dao\system\config; use app\dao\BaseDao; use app\model\system\config\SystemConfig; /** * 系统配置 * Class SystemConfigDao * @package app\dao\system\config */ class SystemConfigDao extends BaseDao { /** * 设置模型 * @return string */ protected function setModel(): string { return SystemConfig::class; } /** * 获取某个系统配置 * @param string $configNmae * @return mixed * @throws \ReflectionException */ public function getConfigValue(string $configNmae) { return $this->search(['menu_name' => $configNmae])->value('value'); } /** * 获取所有配置 * @param array $configName * @return array * @throws \ReflectionException */ public function getConfigAll(array $configName = []) { if ($configName) { return $this->search(['menu_name' => $configName])->column('value', 'menu_name'); } else { return $this->getModel()->column('value', 'menu_name'); } } /** * 获取配置列表分页 * @param array $where * @param int $page * @param int $limit * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getConfigList(array $where, int $page, int $limit) { return $this->search($where)->page($page, $limit)->order('sort desc,id asc')->select()->toArray(); } /** * 获取某些分类配置下的配置列表 * @param int $tabId * @param int $status * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getConfigTabAllList(int $tabId, int $status = 1) { $where['tab_id'] = $tabId; if ($status == 1) $where['status'] = $status; return $this->search($where)->order('sort desc,id ASC')->select()->toArray(); } /** * 获取上传配置中的上传类型 * @param string $configName * @return array * @throws \ReflectionException */ public function getUploadTypeList(string $configName) { return $this->search(['menu_name' => $configName])->column('upload_type', 'type'); } }