first commit
This commit is contained in:
84
application/system/controller/Articlemodel.php
Normal file
84
application/system/controller/Articlemodel.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\ArticleModel as ArticleModelModel;
|
||||
use app\common\service\ArticleModel as ArticleModelService;
|
||||
use think\Request;
|
||||
|
||||
class Articlemodel extends _Init
|
||||
{
|
||||
/**
|
||||
* 文章列表
|
||||
* @param string $title 要搜索的文章标题
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index($title = '')
|
||||
{
|
||||
$map['status'] = ['egt', 0];
|
||||
$this->list = ArticleModelModel::where($map)->paginate();
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文章
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ArticleModelService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑文章
|
||||
* @param Request $Request 数据集
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] 返回 编辑的结果
|
||||
*/
|
||||
public function edit(Request $Request, $id)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = ArticleModelService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = ArticleModelModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文章
|
||||
* @param [type] $id 文章id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = ArticleModelService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章状态
|
||||
* @param [type] $id 文章id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改文章结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = ArticleModelService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user