You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
<?php
|
|
namespace app\adminapi\controller\v1;
|
|
|
|
use app\adminapi\ApiController;
|
|
use think\facade\Db;
|
|
|
|
class Site extends ApiController
|
|
{
|
|
public function getSiteConfig(){
|
|
$result = Db::name('site_config')
|
|
->where('parent_id','<>',0)
|
|
->select();
|
|
|
|
foreach($result as $key => $val){
|
|
$rtn[$val['code']]=$val['value'];
|
|
}
|
|
|
|
return $this->success($rtn);
|
|
}
|
|
|
|
public function setSiteConfig(){
|
|
$data = input();
|
|
unset($data['version']);
|
|
unset($data['controller']);
|
|
unset($data['action']);
|
|
try{
|
|
foreach($data as $key => $val){
|
|
Db::name('site_config')
|
|
->where('code',$key)
|
|
->update(['value'=>$val]);
|
|
}
|
|
}catch(\Exception $e){
|
|
return $this->error('更新失敗');
|
|
}
|
|
|
|
return $this->success('更新成功');
|
|
}
|
|
|
|
public function getAgents(){
|
|
$result = Db::name('agent')
|
|
->select();
|
|
|
|
return $this->success($result);
|
|
}
|
|
}
|