更新前端文件
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
namespace app\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use think\facade\Config;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* @title 后端公共模块
|
||||
@@ -22,13 +22,13 @@ class Admin extends BaseController {
|
||||
'\app\middleware\Admin'
|
||||
];
|
||||
|
||||
protected $data = ['meta' => ['title'=>''], 'data' => [], 'code' => 0, 'msg' => ''];
|
||||
protected $data = ['data' => [], 'code' => 0, 'msg' => ''];
|
||||
|
||||
protected function initialize(){
|
||||
$config = Config::get('system');
|
||||
$config = Cache::get('system_config');
|
||||
if (!$config) {
|
||||
$config = (new \app\model\Config())->lists();
|
||||
Config::set($config, 'system');
|
||||
Cache::set('system_config', $config);
|
||||
}
|
||||
$this->data['config'] = $config;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,5 @@ class Action extends Admin{
|
||||
* @title 系统首页
|
||||
*/
|
||||
public function index(){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,11 @@ class Addons extends Admin{
|
||||
public function index(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 钩子列表
|
||||
*/
|
||||
public function hooks(){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,73 @@
|
||||
namespace app\controller\admin;
|
||||
|
||||
use app\controller\Admin;
|
||||
use think\facade\Db;
|
||||
|
||||
use app\model\Client as ClientModel;
|
||||
|
||||
class Client extends Admin{
|
||||
|
||||
/**
|
||||
* @title 系统首页
|
||||
*/
|
||||
public function index(){
|
||||
public function index(ClientModel $client){
|
||||
$res = $client->paginate(25, false, array(
|
||||
'query' => $this->request->param()
|
||||
));
|
||||
|
||||
$data = $res->toArray();
|
||||
$data['page'] = $res->render();
|
||||
$this->data = $data;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加客户端
|
||||
*/
|
||||
public function add(ClientModel $client){
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->param();
|
||||
$result = $client->validate(true)->save($data);
|
||||
if (false !== $result) {
|
||||
return $this->success('成功添加', url('client/index'));
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$info['appid'] = rand_string(10, 1); //八位数字appid
|
||||
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
||||
$data = array(
|
||||
'info' => $info
|
||||
);
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 编辑客户端
|
||||
*/
|
||||
public function edit(ClientModel $client){
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->param();
|
||||
$result = $client->validate(true)->save($data, array('id'=>$request->param('id')));
|
||||
if (false !== $result) {
|
||||
return $this->success('修改添加', url('client/index'));
|
||||
}else{
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
$info = $client->where('id', $this->request->param('id'))->find();
|
||||
$data = array(
|
||||
'info' => $info
|
||||
);
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 删除客户端
|
||||
*/
|
||||
public function del(ClientModel $client){
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user