接口更新
This commit is contained in:
@@ -35,11 +35,31 @@ class Index extends Base {
|
||||
*/
|
||||
public function update(){
|
||||
$version = new \com\Version();
|
||||
|
||||
$info = $version->check();
|
||||
|
||||
$this->data['info'] = $info;
|
||||
return $this->fetch();
|
||||
if($this->request->isPost()){
|
||||
switch ($type) {
|
||||
case 'down':
|
||||
//下载升级包
|
||||
$this->data['data'] = $version->downloadZip();
|
||||
break;
|
||||
case 'unzip':
|
||||
//解压升级包
|
||||
$this->data['data'] = $version->unzipFile();
|
||||
case 'move':
|
||||
//覆盖文件
|
||||
case 'sql':
|
||||
//升级数据库
|
||||
default:
|
||||
$this->data['data'] = "无操作";
|
||||
break;
|
||||
}
|
||||
$this->data['code'] = 1;
|
||||
return $this->data;
|
||||
}else{
|
||||
$info = $version->check();
|
||||
|
||||
$this->data['info'] = $info;
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,8 +41,13 @@ class Base {
|
||||
public function __construct(App $app) {
|
||||
$this->app = $app;
|
||||
$this->request = $this->app->request;
|
||||
// 控制器初始化
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
protected function initialize() {}
|
||||
|
||||
protected function success($msg, $url = '') {
|
||||
$this->data['code'] = 1;
|
||||
$this->data['msg'] = $msg;
|
||||
|
||||
@@ -15,6 +15,15 @@ use app\model\Category;
|
||||
*/
|
||||
class Content extends Base {
|
||||
|
||||
public $modelInfo = [];
|
||||
public $model = null;
|
||||
|
||||
public function initialize() {
|
||||
parent::initialize();
|
||||
$this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list', 'attr_group'])->toArray();
|
||||
$this->model = Db::name($this->modelInfo['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 内容列表
|
||||
* @method GET
|
||||
@@ -22,7 +31,18 @@ class Content extends Base {
|
||||
* @return [json]
|
||||
*/
|
||||
public function lists(Category $category){
|
||||
$param = $this->request->param();
|
||||
$order = "id desc";
|
||||
$map = [];
|
||||
|
||||
if (isset($param['keyword']) && $param['keyword'] != '') {
|
||||
$map[] = ['title', 'LIKE', '%'.$param['keyword'].'%'];
|
||||
}
|
||||
|
||||
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31,7 +51,14 @@ class Content extends Base {
|
||||
* @return [json]
|
||||
*/
|
||||
public function detail(){
|
||||
$id = $this->request->param('id');
|
||||
if (!$id) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
$info = $this->model->find($id);
|
||||
|
||||
$this->data['data'] = $info;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +67,20 @@ class Content extends Base {
|
||||
* @return [json]
|
||||
*/
|
||||
public function add(){
|
||||
$data = $this->request->post();
|
||||
$data['create_time'] = time();
|
||||
$data['update_time'] = time();
|
||||
$data['uid'] = $this->request->user['uid'];
|
||||
|
||||
$result = $this->model->save($data);
|
||||
if(false !== $result){
|
||||
$this->data['code'] = 1;
|
||||
}else{
|
||||
$this->data['code'] = 0;
|
||||
$this->data['msg'] = "添加失败!";
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +89,18 @@ class Content extends Base {
|
||||
* @return [json]
|
||||
*/
|
||||
public function edit(){
|
||||
$data = $this->request->post();
|
||||
$data['update_time'] = time();
|
||||
|
||||
$result = $this->model->save($data);
|
||||
if(false !== $result){
|
||||
$this->data['code'] = 1;
|
||||
}else{
|
||||
$this->data['code'] = 0;
|
||||
$this->data['msg'] = "修改失败!";
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,6 +109,26 @@ class Content extends Base {
|
||||
* @return [json]
|
||||
*/
|
||||
public function delete(){
|
||||
$id = $this->request->param('id', '');
|
||||
|
||||
$map = [];
|
||||
if (!$id) {
|
||||
return $this->error('请选择要操作的数据!');
|
||||
}
|
||||
if (is_array($id)) {
|
||||
$map[] = ['id', 'IN', $id];
|
||||
}else{
|
||||
$map[] = ['id', '=', $id];
|
||||
}
|
||||
|
||||
$result = $this->model->where($map)->delete();
|
||||
if(false !== $result){
|
||||
$this->data['code'] = 1;
|
||||
}else{
|
||||
$this->data['code'] = 0;
|
||||
$this->data['msg'] = "删除失败!";
|
||||
}
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
@@ -54,4 +54,18 @@ class Version{
|
||||
//throw $th;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 下载升级包
|
||||
*/
|
||||
public function downloadZip(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 解压升级包
|
||||
*/
|
||||
public function unzipFile(){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="col-sm-12">
|
||||
<div class="callout callout-info">
|
||||
<h4>当前版本:{$version}</h4>
|
||||
<h4>最新版本:{$info['version']}</h4>
|
||||
<h4>可升级版本:{$info['version']}</h4>
|
||||
{if isset($info['update']) && $info['update'] == 1}
|
||||
<p>
|
||||
<a href="{$info['file']}" class="btn btn-success" target="_blank">下载手动升级</a>
|
||||
|
||||
Reference in New Issue
Block a user