Files
2020-08-06 15:26:41 +08:00

91 lines
2.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 Share extends _Init
{
/**
* 文章列表
* @param string $title 要搜索的文章标题
* @return [type] [description]
*/
public function index($title = '')
{
$CategoryIds = ContentService::getCategoryIds('share');
$map = [
'status' => ['egt', 0],
'title' => ['like', "%$title%"],
'category_id' => ['in', $CategoryIds],
];
$this->list = ContentModel::where($map)->order('create_time 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('share');
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('share');
$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);
}
}