...
|
...
|
@@ -11,6 +11,7 @@ namespace app\admin\controller; |
|
|
|
|
|
use cmf\controller\AdminBaseController;
|
|
|
use think\Db;
|
|
|
use think\Validate;
|
|
|
|
|
|
class QuestionController extends AdminBaseController
|
|
|
{
|
...
|
...
|
@@ -56,4 +57,63 @@ class QuestionController extends AdminBaseController |
|
|
]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
public function edit(){
|
|
|
$id=$this->request->param('id', 0, 'intval');
|
|
|
if($this->request->isPost()){
|
|
|
$param=$this->request->param();
|
|
|
$validate = new Validate([
|
|
|
'name' => 'require',
|
|
|
]);
|
|
|
$validate->message([
|
|
|
'name' => '姓名不能为空!',
|
|
|
]);
|
|
|
if (!$validate->check($param)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
Db::name('question')
|
|
|
->where('id',$id)
|
|
|
->update($param);
|
|
|
$this->success('更新成功!');
|
|
|
}else{
|
|
|
$data=Db::name('question')
|
|
|
->alias('q')
|
|
|
->field('q.*,u.user_nickname')
|
|
|
->join('cmf_user u','u.id = q.user_id')
|
|
|
->where('q.id',$id)
|
|
|
->find();
|
|
|
$this->assign([
|
|
|
'data'=>$data,
|
|
|
]);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
}
|
|
|
//删除
|
|
|
public function delete(){
|
|
|
$param = $this->request->param();
|
|
|
|
|
|
if (isset($param['id'])) {
|
|
|
$id = $this->request->param('id', 0, 'intval');
|
|
|
$resultPortal = Db::name('question')
|
|
|
->where(['id' => $id])
|
|
|
->update(['delete_time' => time()]);
|
|
|
if($resultPortal){
|
|
|
$this->success("删除成功!", '');
|
|
|
}else{
|
|
|
$this->error("删除失败!", '');
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isset($param['ids'])) {
|
|
|
$ids = $this->request->param('ids/a');
|
|
|
$result = Db::name('question')
|
|
|
->where(['id' => ['in', $ids]])
|
|
|
->update(['delete_time' => time()]);
|
|
|
if ($result) {
|
|
|
$this->success("删除成功!", '');
|
|
|
}else{
|
|
|
$this->error("删除失败!", '');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|