parent
abff10eea5
commit
a8dd4b7870
@ -0,0 +1,54 @@
|
|||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in new issue