|
@@ -67,21 +67,31 @@ class ForbiddenController extends BaseController |
|
@@ -67,21 +67,31 @@ class ForbiddenController extends BaseController |
67
|
{
|
67
|
{
|
68
|
$model = new Forbidden();
|
68
|
$model = new Forbidden();
|
69
|
if ($posts = Yii::$app->request->post()) {
|
69
|
if ($posts = Yii::$app->request->post()) {
|
70
|
- $model->room_id = $posts['room_id'];
|
|
|
71
|
- $model->uid = $posts['uid'];
|
|
|
72
|
- $model->name = $posts['name'];
|
|
|
73
|
- $model->status = 1;
|
|
|
74
|
- $model->create_time = time();
|
|
|
75
|
- if (!$model->save()) {
|
70
|
+ do {
|
|
|
71
|
+ $model->room_id = $posts['room_id'];
|
|
|
72
|
+ $model->uid = $posts['uid'];
|
|
|
73
|
+ $model->name = $posts['name'];
|
|
|
74
|
+
|
|
|
75
|
+ if (!$model->uid || !$model->name) {
|
|
|
76
|
+ $code = 400;
|
|
|
77
|
+ $msg = '用户id、昵称必填!';
|
|
|
78
|
+ break;
|
|
|
79
|
+ }
|
|
|
80
|
+ $model->status = 1;
|
|
|
81
|
+ $model->create_time = time();
|
|
|
82
|
+ if (!$model->save()) {
|
76
|
// var_dump($model->errors);
|
83
|
// var_dump($model->errors);
|
77
|
- $code = 400;
|
|
|
78
|
- $code_str = 'error';
|
|
|
79
|
- $msg = '添加失败。'.current($model->getFirstErrors());
|
|
|
80
|
- } else {
|
|
|
81
|
- $code = 200;
|
|
|
82
|
- $code_str = 'success';
|
|
|
83
|
- $msg = '添加成功。';
|
84
|
+ $code = 400;
|
|
|
85
|
+ $code_str = 'error';
|
|
|
86
|
+ $msg = '添加失败。'.current($model->getFirstErrors());
|
|
|
87
|
+ } else {
|
|
|
88
|
+ $code = 200;
|
|
|
89
|
+ $code_str = 'success';
|
|
|
90
|
+ $msg = '添加成功。';
|
|
|
91
|
+ }
|
84
|
}
|
92
|
}
|
|
|
93
|
+ while(false);
|
|
|
94
|
+
|
85
|
if(Yii::$app->request->isAjax){
|
95
|
if(Yii::$app->request->isAjax){
|
86
|
$this->renderJson($code,$msg);
|
96
|
$this->renderJson($code,$msg);
|
87
|
}else{
|
97
|
}else{
|