88 lines
2.0 KiB
PHP
88 lines
2.0 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\controller\admin;
|
|
|
|
use app\model\Client as ClientM;
|
|
use app\controller\Admin;
|
|
|
|
/**
|
|
* @title 客户端管理
|
|
*/
|
|
class Client extends Admin {
|
|
|
|
/**
|
|
* @title 客户端列表
|
|
*/
|
|
public function index() {
|
|
$map = [];
|
|
|
|
$list = ClientM::where($map)->paginate($this->request->pageConfig);
|
|
|
|
$this->data = array(
|
|
'list' => $list,
|
|
'page' => $list->render(),
|
|
);
|
|
return $this->fetch();
|
|
}
|
|
|
|
/**
|
|
* @title 添加客户端
|
|
*/
|
|
public function add() {
|
|
if ($this->request->isPost()) {
|
|
$data = $this->request->param();
|
|
|
|
$result = ClientM::create($data);
|
|
if (false !== $result) {
|
|
return $this->success('成功添加', url('client/index'));
|
|
} else {
|
|
return $this->error('添加失败!');
|
|
}
|
|
} else {
|
|
$info['appid'] = rand_string(10, 1); //八位数字appid
|
|
$info['appsecret'] = rand_string(32); //32位数字加字母秘钥
|
|
|
|
$this->data = array(
|
|
'info' => $info,
|
|
);
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 编辑客户端
|
|
*/
|
|
public function edit() {
|
|
if ($this->request->isPost()) {
|
|
$data = $this->request->param();
|
|
|
|
$result = ClientM::update($data, ['id' => $this->request->param('id')]);
|
|
if (false !== $result) {
|
|
return $this->success('修改添加', url('client/index'));
|
|
} else {
|
|
return $this->error($this->model->getError());
|
|
}
|
|
} else {
|
|
$info = $ClientM::where('id', $request->param('id'))->find();
|
|
|
|
$this->data = array(
|
|
'info' => $info,
|
|
);
|
|
return $this->fetch('admin/client/add');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @title 删除客户端
|
|
*/
|
|
public function del(\think\Request $request) {
|
|
|
|
}
|
|
} |