|
@@ -11,6 +11,7 @@ namespace app\admin\controller; |
|
@@ -11,6 +11,7 @@ namespace app\admin\controller; |
11
|
|
11
|
|
12
|
use cmf\controller\AdminBaseController;
|
12
|
use cmf\controller\AdminBaseController;
|
13
|
use think\Db;
|
13
|
use think\Db;
|
|
|
14
|
+use think\Validate;
|
14
|
|
15
|
|
15
|
class QuestionController extends AdminBaseController
|
16
|
class QuestionController extends AdminBaseController
|
16
|
{
|
17
|
{
|
|
@@ -56,4 +57,63 @@ class QuestionController extends AdminBaseController |
|
@@ -56,4 +57,63 @@ class QuestionController extends AdminBaseController |
56
|
]);
|
57
|
]);
|
57
|
return $this->fetch();
|
58
|
return $this->fetch();
|
58
|
}
|
59
|
}
|
|
|
60
|
+ public function edit(){
|
|
|
61
|
+ $id=$this->request->param('id', 0, 'intval');
|
|
|
62
|
+ if($this->request->isPost()){
|
|
|
63
|
+ $param=$this->request->param();
|
|
|
64
|
+ $validate = new Validate([
|
|
|
65
|
+ 'name' => 'require',
|
|
|
66
|
+ ]);
|
|
|
67
|
+ $validate->message([
|
|
|
68
|
+ 'name' => '姓名不能为空!',
|
|
|
69
|
+ ]);
|
|
|
70
|
+ if (!$validate->check($param)) {
|
|
|
71
|
+ $this->error($validate->getError());
|
|
|
72
|
+ }
|
|
|
73
|
+ Db::name('question')
|
|
|
74
|
+ ->where('id',$id)
|
|
|
75
|
+ ->update($param);
|
|
|
76
|
+ $this->success('更新成功!');
|
|
|
77
|
+ }else{
|
|
|
78
|
+ $data=Db::name('question')
|
|
|
79
|
+ ->alias('q')
|
|
|
80
|
+ ->field('q.*,u.user_nickname')
|
|
|
81
|
+ ->join('cmf_user u','u.id = q.user_id')
|
|
|
82
|
+ ->where('q.id',$id)
|
|
|
83
|
+ ->find();
|
|
|
84
|
+ $this->assign([
|
|
|
85
|
+ 'data'=>$data,
|
|
|
86
|
+ ]);
|
|
|
87
|
+ return $this->fetch();
|
|
|
88
|
+ }
|
|
|
89
|
+ }
|
|
|
90
|
+ //删除
|
|
|
91
|
+ public function delete(){
|
|
|
92
|
+ $param = $this->request->param();
|
|
|
93
|
+
|
|
|
94
|
+ if (isset($param['id'])) {
|
|
|
95
|
+ $id = $this->request->param('id', 0, 'intval');
|
|
|
96
|
+ $resultPortal = Db::name('question')
|
|
|
97
|
+ ->where(['id' => $id])
|
|
|
98
|
+ ->update(['delete_time' => time()]);
|
|
|
99
|
+ if($resultPortal){
|
|
|
100
|
+ $this->success("删除成功!", '');
|
|
|
101
|
+ }else{
|
|
|
102
|
+ $this->error("删除失败!", '');
|
|
|
103
|
+ }
|
|
|
104
|
+
|
|
|
105
|
+ }
|
|
|
106
|
+
|
|
|
107
|
+ if (isset($param['ids'])) {
|
|
|
108
|
+ $ids = $this->request->param('ids/a');
|
|
|
109
|
+ $result = Db::name('question')
|
|
|
110
|
+ ->where(['id' => ['in', $ids]])
|
|
|
111
|
+ ->update(['delete_time' => time()]);
|
|
|
112
|
+ if ($result) {
|
|
|
113
|
+ $this->success("删除成功!", '');
|
|
|
114
|
+ }else{
|
|
|
115
|
+ $this->error("删除失败!", '');
|
|
|
116
|
+ }
|
|
|
117
|
+ }
|
|
|
118
|
+ }
|
59
|
} |
119
|
} |