first commit
This commit is contained in:
119
application/system/controller/Suggest.php
Normal file
119
application/system/controller/Suggest.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\system\controller;
|
||||
|
||||
use app\common\model\Member as MemberModel;
|
||||
use app\common\model\Suggest as SuggestModel;
|
||||
use app\common\service\Suggest as SuggestService;
|
||||
use think\Request;
|
||||
|
||||
class Suggest extends _Init
|
||||
{
|
||||
/**
|
||||
* 意见列表
|
||||
* @param string $title 要搜索的意见标题
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function index($status = '', $username = '', $start_date = '', $end_date = '')
|
||||
{
|
||||
$map['pid'] = 0;
|
||||
if (!in_array(UID, [1, 2])) {
|
||||
$map['dep'] = MemberModel::where('id', UID)->value('dep') ?: true;
|
||||
}
|
||||
if ($username) {
|
||||
$ids = MemberModel::where('username|id', 'like', "%$username%")->column('id');
|
||||
$map['uid'] = ['in', $ids];
|
||||
}
|
||||
if (is_numeric($status)) {
|
||||
$map['status'] = $status;
|
||||
}
|
||||
|
||||
if ($start_date && $end_date) {
|
||||
$map['create_time'] = ['between time', [$start_date, date('Y-m-d H:i:s', strtotime('+1 day', strtotime($end_date)) - 1)]];
|
||||
} elseif ($start_date) {
|
||||
$map['create_time'] = ['> time', $start_date];
|
||||
} elseif ($end_date) {
|
||||
$map['create_time'] = ['< time', date('Y-m-d H:i:s', strtotime('+1 day', strtotime($end_date)) - 1)];
|
||||
}
|
||||
|
||||
$this->list = SuggestModel::where($map)->order('create_time desc')->paginate($this->list_rows);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加意见
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function add(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = SuggestService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
return $this->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回复意见
|
||||
* @param Request $Request 数据集
|
||||
*/
|
||||
public function revert(Request $Request)
|
||||
{
|
||||
if (IS_POST) {
|
||||
$data = $Request->post();
|
||||
$result = SuggestService::create($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
// $this->info = SuggestModel::get($Request->param('id'));
|
||||
$this->info = SuggestService::read($Request->param('id'));
|
||||
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 = SuggestService::edit($data);
|
||||
return $this->back($result);
|
||||
} else {
|
||||
$this->info = SuggestModel::get($id);
|
||||
return $this->fetch('add');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除意见
|
||||
* @param [type] $id 意见id
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
$result = SuggestService::del($id);
|
||||
return $this->back($result);
|
||||
}
|
||||
/**
|
||||
* 修改意见状态
|
||||
* @param [type] $id 意见id
|
||||
* @param [type] $status 状态
|
||||
* @return [type] 修改意见结果
|
||||
*/
|
||||
public function status($id, $status)
|
||||
{
|
||||
$result = SuggestService::status($id, $status);
|
||||
return $this->back($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user