68 lines
1.4 KiB
PHP
68 lines
1.4 KiB
PHP
<?php
|
||
/**
|
||
* 商业使用授权协议
|
||
*
|
||
* Copyright (c) 2025 [云泽网]. 保留所有权利.
|
||
*
|
||
* 本软件仅供评估使用。任何商业用途必须获得书面授权许可。
|
||
* 未经授权商业使用本软件属于侵权行为,将承担法律责任。
|
||
*
|
||
* 授权购买请联系: 357099073@qq.com
|
||
* 官方网站: https://www.yunzer.cn
|
||
*
|
||
* 评估用户须知:
|
||
* 1. 禁止移除版权声明
|
||
* 2. 禁止用于生产环境
|
||
* 3. 禁止转售或分发
|
||
*/
|
||
|
||
/**
|
||
* 配置表
|
||
*/
|
||
namespace app\api\model;
|
||
|
||
use think\Model;
|
||
|
||
class YzAdminConfig extends Model
|
||
{
|
||
// 设置当前模型对应的数据表名称(不含前缀)
|
||
protected $name = 'admin_config';
|
||
|
||
// 设置主键
|
||
protected $pk = 'config_id';
|
||
|
||
/**
|
||
* 列出全部配置,key对应value
|
||
*/
|
||
public function getAll(){
|
||
$aList = static::where('config_status',1)->order('config_sort DESC')->select()->toArray();
|
||
if(empty($aList)){
|
||
return [];
|
||
}else{
|
||
$return = [];
|
||
foreach($aList as $k=>$v){
|
||
$return[$v['config_name']] = $v['config_value'];
|
||
}
|
||
}
|
||
return $return;
|
||
}
|
||
|
||
/**
|
||
* 多条数据更新
|
||
*/
|
||
public function updateAll($data){
|
||
$lists = static::order('config_sort DESC,config_id')->select()->toArray();
|
||
if(empty($lists)){
|
||
return false;
|
||
}else{
|
||
foreach($lists as &$lists_v){
|
||
$lists_v['config_value'] = $data[$lists_v['config_name']];
|
||
}
|
||
$save = static::saveAll($lists);
|
||
if(empty($save)){
|
||
return false;
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
} |