소스 검색

修改两个接口

lizhen_gitee 1 년 전
부모
커밋
0fe82a5cf3
4개의 변경된 파일36개의 추가작업 그리고 4개의 파일을 삭제
  1. 6 3
      application/api/controller/Gift.php
  2. 1 0
      application/common/library/Auth.php
  3. 13 0
      application/common/model/Enumjob.php
  4. 16 1
      application/common/model/User.php

+ 6 - 3
application/api/controller/Gift.php

@@ -248,9 +248,9 @@ class Gift extends Api
         }
 
         $list = Db::name('gift_user_party')->alias('gup')
-            ->join('user',$joinstr,'LEFT')->field('gup.*,user.nickname')
+            ->join('user',$joinstr,'LEFT')->field('gup.*,user.nickname,user.avatar,user.gender')
             ->where($where)->order('id desc')->autopage()->select();
-        $list = list_domain_image($list,['gift_gif_image']);
+        $list = list_domain_image($list,['gift_gif_image','avatar']);
 
         $rs = [];
         if(empty($list)){
@@ -267,7 +267,10 @@ class Gift extends Api
                 'id'         => $val['id'],
                 'gift_image' => $val['gift_gif_image'],
                 'createtime' => $val['createtime'],
-                'remark'     => $remark
+                'remark'     => $remark,
+                'nickname'    => $val['nickname'],
+                'avatar'     => $val['avatar'],
+                'gender'     => $val['gender'],
             ];
         }
         $this->success(1,$rs);

+ 1 - 0
application/common/library/Auth.php

@@ -552,6 +552,7 @@ class Auth
         $userInfo['look_num'] = $userInfoA['look_num'];
         // 是否设置密码
         $userinfo['is_setpwd'] = $data['password'] ? 1 : 0;
+
         $field = 'id,age_id,constellation_id,province_id,city_id,desc';
         $fieldArr = explode(',',$field);
         $fieldTextArr = ['age_text','constellation_text','province_text','city_text','friends_num','look_num'];

+ 13 - 0
application/common/model/Enumjob.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+
+class Enumjob extends Model
+{
+    // 表名
+    protected $name = 'enum_job';
+
+}

+ 16 - 1
application/common/model/User.php

@@ -45,6 +45,16 @@ class User extends Model
         return isset($list['name']) ? $list['name'] : '';
     }
 
+    public function getJobTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['job_id']) ? $data['job_id'] : 0);
+        $list = [];
+        if (!empty($value)) {
+            $list = model('enumjob')->field('name')->find($value);
+        }
+        return isset($list['name']) ? $list['name'] : '';
+    }
+
     public function getProvinceTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['province_id']) ? $data['province_id'] : 0);
@@ -115,7 +125,7 @@ class User extends Model
     {
         if (!$value) {
             //如果不需要启用首字母头像,请使用
-            $value = '/assets/img/avatar.png';
+            $value = '';
             //$value = letter_avatar($data['nickname']);
         }
         return $value;
@@ -395,6 +405,7 @@ class User extends Model
             $ageId = isset($userInfo['age_id']) ? $userInfo['age_id'] : 0;
             $provinceId = isset($userInfo['province_id']) ? $userInfo['province_id'] : 0;
             $cityId = isset($userInfo['city_id']) ? $userInfo['city_id'] : 0;
+            $userInfo['job_text'] = $this->getJobTextAttr(false,['job_id' => $userInfo['job_id']]);
             $userInfo['age_text'] = $this->getAgeTextAttr(false,['age_id' => $ageId]);
             $areaWhere['id'] = ['in',[$provinceId,$cityId]];
             $areaData = Db::name('shopro_area')->where($areaWhere)->column('id,name');
@@ -414,6 +425,10 @@ class User extends Model
     {
         return $this->hasOne('Constellation', 'id', 'constellation_id',[],'LEFT');
     }
+    public function job()
+    {
+        return $this->hasOne('EnumJob', 'id', 'job_id',[],'LEFT');
+    }
     public function useralipay()
     {
         return $this->hasOne('UserAlipay', 'user_id', 'id',[],'LEFT');