You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ConfigService
|
|
{
|
|
|
|
//获取配置信息
|
|
public function GetConfigInfo($arr){
|
|
$q=DB::table('configs')->select(['label','value'])->whereIn('label',$arr)->get();
|
|
if(count($q)>0) {
|
|
$result = [];
|
|
foreach ($q as $k => $v) {
|
|
$result[$v->label] = $v->value;
|
|
}
|
|
return \Yz::Return(true, '查询成功', $result);
|
|
}else{
|
|
return \Yz::Return(false, '查询失败');
|
|
}
|
|
}
|
|
public function SaveConfig($info){
|
|
$result=array();
|
|
DB::beginTransaction();
|
|
try {
|
|
foreach ($info as $key=>$value){
|
|
$d= DB::table('configs')->where('label', '=', $key)->update(['value'=>$value]);
|
|
}
|
|
DB::commit(); // 手动提交事务
|
|
return \Yz::Return(true, '操作成功');
|
|
} catch (\Exception $e) {
|
|
DB::rollback(); // 发生异常时手动回滚事务
|
|
return \Yz::Return(false, '操作失败');
|
|
}
|
|
|
|
|
|
}
|
|
}
|