new_naweigete/crmeb/app/dao/system/config/SystemConfigDao.php
2025-03-13 09:24:48 +08:00

101 lines
3.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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');
}
}