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