81 lines
2.1 KiB
PHP
81 lines
2.1 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\controller\Admin;
|
|
use think\facade\Db;
|
|
|
|
use app\model\Client as ClientModel;
|
|
|
|
class Client extends Admin{
|
|
|
|
/**
|
|
* @title 系统首页
|
|
*/
|
|
public function index(ClientModel $client){
|
|
$res = $client->paginate(25, false, array(
|
|
'query' => $this->request->param()
|
|
));
|
|
|
|
$data['list'] = $res;
|
|
$data['page'] = $res->render();
|
|
$this->data['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){
|
|
|
|
}
|
|
} |