194 lines
5.8 KiB
PHP
194 lines
5.8 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\controller\home;
|
|
|
|
use app\common\controller\AdminApi;
|
|
use app\adminapi\model\home\LeaveWord as LeaveWordModel;
|
|
|
|
/**
|
|
* 网站留言管理
|
|
*/
|
|
class LeaveWord extends AdminApi
|
|
{
|
|
|
|
|
|
/**
|
|
* @var \app\adminapi\model\home\LeaveWord
|
|
*/
|
|
protected $model = null;
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->model = new LeaveWordModel;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* @ApiTitle( 网站留言列表)
|
|
* @ApiSummary(网站留言列表)
|
|
* @ApiMethod(GET)
|
|
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
|
|
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
|
|
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
|
|
* @ApiParams(name = "status", type = "string",required=true,description = "状态:1=未处理,2=已处理")
|
|
* @ApiParams(name = "mobile", type = "string",required=false,description = "联系电话")
|
|
* @ApiReturn({
|
|
*
|
|
*})
|
|
*/
|
|
public function index()
|
|
{
|
|
$user_id = 0;
|
|
$user = $this->auth->getUser();//登录用户
|
|
if($user)$user_id = $user['id'];
|
|
$page = $this->request->get('page/d', 0); //页数
|
|
$limit = $this->request->get('limit/d', 0); //条数
|
|
$params = [];
|
|
|
|
$params["keywords"] = $this->request->get('keywords/s', ''); //搜索关键字
|
|
$params["status"] = $this->request->get('status/s', ''); //搜索关键字
|
|
$params["mobile"] = $this->request->get('mobile/s', ''); //搜索关键字
|
|
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
|
|
|
|
try{
|
|
//当前申请状态
|
|
$res = $this->model::allList($page, $limit,$params);
|
|
// if($user_id =='670153'){
|
|
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
|
|
// }
|
|
}catch (\Exception $e){
|
|
|
|
$this->error($e->getMessage());
|
|
}
|
|
$this->success('查询成功', $res);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 查看网站留言详情
|
|
*
|
|
* @ApiMethod (GET)
|
|
* @ApiParams (name="id", type="string", required=true, description="ID")
|
|
*/
|
|
public function detail()
|
|
{
|
|
$admin_id = $this->auth->id;
|
|
$id = $this->request->get('id/d');
|
|
|
|
try{
|
|
$menulist = $this->model->detail($id,$show_field=[],$except_field=[]);
|
|
} catch (\Exception $e) {
|
|
$this->error($e->getMessage());
|
|
}
|
|
|
|
|
|
|
|
$this->success('查询成功', $menulist);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* 删除网站留言
|
|
*
|
|
* @ApiMethod (POST)
|
|
* @ApiParams (name="ids", type="string", required=true, description="要删除的ids")
|
|
*/
|
|
public function del()
|
|
{
|
|
// $admin_id = $this->auth->id;
|
|
$ids = $this->request->post('ids/s');
|
|
|
|
try{
|
|
$menulist = $this->model->del($ids,true);
|
|
} catch (\Exception $e) {
|
|
$this->error($e->getMessage());
|
|
}
|
|
|
|
$this->success('删除成功', $menulist);
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* @ApiTitle(新增网站留言)
|
|
* @ApiSummary(新增网站留言)
|
|
* @ApiMethod(POST)
|
|
* @ApiParams(name = "name", type = "string",required=false,description = "提交者姓名")
|
|
* @ApiParams(name = "mobile", type = "string",required=true,description = "联系电话")
|
|
* @ApiParams(name = "emil", type = "string",required=true,description = "邮箱地址")
|
|
* @ApiParams(name = "message", type = "string",required=false,description = "留言内容")
|
|
* @ApiReturn({
|
|
*
|
|
*})
|
|
*/
|
|
public function add()
|
|
{
|
|
$user_id = 0;
|
|
$user = $this->auth->getUser();//登录用户
|
|
if($user)$user_id = $user['id'];
|
|
$params=[];
|
|
$params["name"] = $this->request->post('name/s', ''); //页数
|
|
$params["mobile"] = $this->request->post('mobile/s', ''); //条数
|
|
$params["emil"] = $this->request->post('emil/s', ''); //搜索关键字
|
|
$params["message"] = $this->request->post('message/s', ''); //搜索关键字
|
|
|
|
|
|
|
|
try{
|
|
//当前申请状态
|
|
$res = $this->model->add($params,true);
|
|
// var_dump($this->model->getLastSql());
|
|
}catch (\Exception $e){
|
|
|
|
$this->error($e->getMessage());
|
|
}
|
|
$this->success('添加成功', $res);
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* @ApiTitle(编辑网站留言)
|
|
* @ApiSummary(编辑网站留言)
|
|
* @ApiMethod(POST)
|
|
* @ApiRoute (/adminapi/home.leave_word/edit/ids/{ids})
|
|
* @ApiParams (name="ids", type="string", required=true, description="需要编辑的id")
|
|
* @ApiParams(name = "name", type = "string",required=false,description = "提交者姓名")
|
|
* @ApiParams(name = "mobile", type = "string",required=true,description = "联系电话")
|
|
* @ApiParams(name = "emil", type = "string",required=true,description = "邮箱地址")
|
|
* @ApiParams(name = "message", type = "string",required=false,description = "留言内容")
|
|
* @ApiReturn({
|
|
*
|
|
*})
|
|
*/
|
|
public function edit($ids = null){
|
|
|
|
// $user_id = 73;
|
|
// $user = $this->auth->getUser();//登录用户
|
|
// if($user)$user_id = $user['id'];
|
|
$params = [];
|
|
// $params["user_id"] = $user_id; //老师id
|
|
$params["name"] = $this->request->post('name/s', ''); //页数
|
|
$params["mobile"] = $this->request->post('mobile/s', ''); //条数
|
|
$params["emil"] = $this->request->post('emil/s', ''); //搜索关键字
|
|
$params["message"] = $this->request->post('message/s', ''); //搜索关键字
|
|
|
|
try{
|
|
$res = $this->model->edit($ids,$params,true);
|
|
}catch (\Throwable $e){
|
|
$this->error($e->getMessage());
|
|
}
|
|
$this->success('编辑成功', $res);
|
|
}
|
|
|
|
|
|
|
|
} |