first commit
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Administrator
|
||||
* Date: 2020/4/24
|
||||
* Time: 15:05
|
||||
*/
|
||||
|
||||
namespace app\admin\controller\custom;
|
||||
|
||||
|
||||
use app\admin\controller\AdminController;
|
||||
|
||||
class Message extends AdminController
|
||||
{
|
||||
/**
|
||||
* User模型对象
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* User constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->model = new \app\admin\model\costom\Message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 留言建议列表
|
||||
*/
|
||||
public function index() {
|
||||
|
||||
//ajax访问
|
||||
if ($this->request->get('type') == 'ajax') {
|
||||
$page = $this->request->get('page', 1);
|
||||
$limit = $this->request->get('limit', 10);
|
||||
$search = (array)$this->request->get('search', []);
|
||||
return json($this->model->messageList($page, $limit, $search));
|
||||
}
|
||||
|
||||
$basic_data = [
|
||||
'title' => '留言建议列表',
|
||||
'data' => '',
|
||||
];
|
||||
|
||||
return $this->fetch('', $basic_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 留言回复
|
||||
* @return mixed|string|\think\response\Json
|
||||
*/
|
||||
public function reply() {
|
||||
if (!$this->request->isPost()) {
|
||||
|
||||
//查找所需修改的数据
|
||||
$data = $this->model->where('id', $this->request->get('id'))->find();
|
||||
if($data['img1']){
|
||||
$data['img1'] = config('secure.mpic_url'). $data['img1'];
|
||||
}
|
||||
if($data['img2']){
|
||||
$data['img2'] = config('secure.mpic_url'). $data['img2'];
|
||||
}
|
||||
|
||||
if (empty($data)) return msg_error('暂无数据,请重新刷新页面!');
|
||||
|
||||
//基础数据
|
||||
$basic_data = [
|
||||
'title' => '工单回复',
|
||||
'result' => $data,
|
||||
];
|
||||
return $this->fetch('form', $basic_data);
|
||||
} else {
|
||||
$post = $this->request->post();
|
||||
$post['reply_time'] = time();
|
||||
//验证数据
|
||||
$validate = $this->validate($post, 'app\admin\validate\custom\Message.reply');
|
||||
if (true !== $validate) return __error($validate);
|
||||
|
||||
//保存数据,返回结果
|
||||
return $this->model->reply($post);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user