初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\config;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
/**
|
||||
* 支付配置
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Pay extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* Column模型对象
|
||||
* @var \app\admin\model\course\Column
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $AddonContro = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\config\Pay;
|
||||
$this->AddonContro = new \app\admin\controller\Addon;
|
||||
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
return $this->success("获取成功",$this->model->getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
* @return mixed
|
||||
*/
|
||||
public function getConfig(){
|
||||
$name = $this->request->post("name");
|
||||
|
||||
$config = $this->AddonContro->getConfig('epay',false);
|
||||
|
||||
if(!$config['config']){
|
||||
return $this->error("获取失败");
|
||||
}
|
||||
|
||||
foreach ($config['config'] as $item){
|
||||
if($item['name'] == $name){
|
||||
$config['config'] = [$item];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $this->success("获取成功",$config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
* @return mixed
|
||||
*/
|
||||
public function setConfig(){
|
||||
$name = $this->request->post("name");
|
||||
|
||||
$params = $this->request->post("row/a", [], 'trim');
|
||||
|
||||
$config = $this->AddonContro->getConfig('epay',false)['config'];
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($config as $k => &$v) {
|
||||
|
||||
if($v['name'] == $name){
|
||||
$data[$v['name']] = $params[$name];
|
||||
}else{
|
||||
if($v['type'] == 'array'){
|
||||
$arr = [];
|
||||
foreach ($v['value'] as $option){
|
||||
$arr[$option['key']] = $option['value'];
|
||||
}
|
||||
$data[$v['name']] = $arr;
|
||||
}else{
|
||||
$data[$v['name']] = $v['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->AddonContro->setConfig('epay',$data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态
|
||||
* @return void
|
||||
*/
|
||||
public function setStatus(){
|
||||
$name = $this->request->post("name");
|
||||
$status = $this->request->post("status",false);
|
||||
|
||||
if(!$name){
|
||||
$this->error(__("Invalid parameters"));
|
||||
}
|
||||
|
||||
$this->model->setStatus($name,$status);
|
||||
|
||||
return $this->success("操作成功");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user