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.
55 lines
1.3 KiB
55 lines
1.3 KiB
<?php
|
|
namespace app\adminapi\controller\v1;
|
|
|
|
use app\adminapi\ApiController;
|
|
use think\facade\Db;
|
|
|
|
class Shop extends ApiController
|
|
{
|
|
public function getShopConfig(){
|
|
$result = Db::name('shop_config')
|
|
->where('parent_id','<>',0)
|
|
->select();
|
|
|
|
|
|
foreach($result as $key => $val){
|
|
$rtn[$val['code']]=$val['value'];
|
|
}
|
|
|
|
return $this->success($rtn);
|
|
}
|
|
|
|
public function setShopConfig(){
|
|
$data = input('post.');
|
|
|
|
try{
|
|
foreach($data as $key => $val){
|
|
Db::name('shop_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);
|
|
}
|
|
|
|
public function uploadLogo(){
|
|
$file = request()->file('file');
|
|
try{
|
|
$savename = \think\facade\Filesystem::disk('public')->putFile('images', $file);
|
|
}catch(\Exception $e){
|
|
return $this->Error($e->getMessage());
|
|
}
|
|
return $this->Success($savename);
|
|
}
|
|
}
|