Files
sentcms/application/admin/controller/Client.php
2017-09-18 23:29:51 +08:00

76 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\admin\controller;
use app\common\controller\Admin;
class Client extends Admin {
public function _initialize() {
parent::_initialize();
$this->model = model('Client');
}
public function index(){
$list = $this->model->paginate(25);
$data = array(
'list' => $list,
'page' => $list->render()
);
$this->assign($data);
$this->setMeta('客户端列表');
return $this->fetch();
}
public function add(\think\Request $request){
if (IS_POST) {
$data = $request->param();
$result = $this->model->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
);
$this->assign($data);
$this->setMeta('添加客户端');
return $this->fetch('add');
}
}
public function edit(\think\Request $request){
if (IS_POST) {
$data = $request->param();
$result = $this->model->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 = $this->model->where('id', $request->param('id'))->find();
$data = array(
'info' => $info
);
$this->assign($data);
$this->setMeta('编辑客户端');
return $this->fetch('add');
}
}
public function del(\think\Request $request){
}
}