Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kanyxmo
MineAdmin
提交
15985cff
M
MineAdmin
项目概览
kanyxmo
/
MineAdmin
10 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
MineAdmin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
15985cff
编写于
8月 16, 2023
作者:
kanyxmo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增sys_config() 和 sys_group_config() 函数
上级
22267d18
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
0 deletion
+61
-0
app/Setting/Mapper/SettingConfigMapper.php
app/Setting/Mapper/SettingConfigMapper.php
+14
-0
app/Setting/Service/SettingConfigService.php
app/Setting/Service/SettingConfigService.php
+10
-0
common/common.php
common/common.php
+37
-0
未找到文件。
app/Setting/Mapper/SettingConfigMapper.php
浏览文件 @
15985cff
...
...
@@ -32,6 +32,20 @@ class SettingConfigMapper extends AbstractMapper
return
$model
?
$model
->
toArray
()
:
[];
}
/**
* 按组的key获取一组配置信息
* @param string $groupKey
* @return array
*/
public
function
getConfigByGroupKey
(
string
$groupKey
):
array
{
$prefix
=
env
(
'DB_PREFIX'
);
return
$this
->
model
::
query
()
->
whereRaw
(
sprintf
(
'group_id = ( SELECT id FROM %ssetting_config_group WHERE code = ? )'
,
$prefix
),
[
$groupKey
]
)
->
get
()
->
toArray
();
}
/**
* 更新配置
* @param string $key
...
...
app/Setting/Service/SettingConfigService.php
浏览文件 @
15985cff
...
...
@@ -85,6 +85,16 @@ class SettingConfigService extends AbstractService implements ConfigServiceInter
}
}
/**
* 按组的key获取一组配置信息
* @param string $groupKey
* @return array|null
*/
public
function
getConfigByGroupKey
(
string
$groupKey
):
?array
{
return
$this
->
mapper
->
getConfigByGroupKey
(
$groupKey
);
}
/**
* 清除缓存
* @return bool
...
...
common/common.php
浏览文件 @
15985cff
...
...
@@ -45,4 +45,41 @@ if (! function_exists('make')) {
return
\
Hyperf\Support\make
(
$name
,
$parameters
);
}
}
if
(
!
function_exists
(
'sys_config'
))
{
/**
* 获取后台系统配置
*
* @param string $key
* @param null|mixed $default
* @return mixed
* @throws RedisException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
function
sys_config
(
string
$key
,
mixed
$default
=
null
):
mixed
{
return
container
()
->
get
(
\
App\Setting\Service\SettingConfigService
::
class
)
->
getConfigByKey
(
$key
)
??
$default
;
}
}
if
(
!
function_exists
(
'sys_group_config'
))
{
/**
* 获取后台系统配置
*
* @param string $groupKey
* @param null|mixed $default
* @return mixed
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
function
sys_group_config
(
string
$groupKey
,
mixed
$default
=
[]):
mixed
{
return
container
()
->
get
(
\
App\Setting\Service\SettingConfigService
::
class
)
->
getConfigByGroupKey
(
$groupKey
)
??
$default
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录