Selaa lähdekoodia

打招呼优化

lizhen_gitee 6 päivää sitten
vanhempi
commit
80ec2a5692
1 muutettua tiedostoa jossa 16 lisäystä ja 11 poistoa
  1. 16 11
      application/api/controller/Greet.php

+ 16 - 11
application/api/controller/Greet.php

@@ -26,6 +26,22 @@ class Greet extends Api
             $this->error(__('Invalid parameters'));
         }
 
+        //打招呼内容
+        $greet = null;
+        if($this->auth->gender == 0){
+            $where['user_id'] = $this->auth->id;
+            $greet = Db::name('user_greet_content')->where($where)->orderRaw('rand()')->find();
+            if(empty($greet)){
+                $this->error('先设置打招呼内容吧');
+            }
+            if(!empty($greet) && $greet['type'] != 0){
+                $greet['content'] = one_domain_image($greet['content']);
+            }
+        }else{
+            $greet = Db::name('user_greet_boy')->orderRaw('rand()')->find();
+        }
+
+        //
         $map = [];
         foreach($other_uids as $key => $other_uid){
             $map[] = [
@@ -51,17 +67,6 @@ class Greet extends Api
         }
         Db::commit();
 
-        $greet = null;
-        if($this->auth->gender == 0){
-            $where['user_id'] = $this->auth->id;
-            $greet = Db::name('user_greet_content')->where($where)->orderRaw('rand()')->find();
-            if(!empty($greet) && $greet['type'] != 0){
-                $greet['content'] = one_domain_image($greet['content']);
-            }
-        }else{
-            $greet = Db::name('user_greet_boy')->orderRaw('rand()')->find();
-        }
-
         $rs = [
             'gender' => $this->auth->gender,
             'greet'  => $greet,