diff --git a/app/api/logic/UserLogic.php b/app/api/logic/UserLogic.php index 55f90bf1b..ea8592f3c 100755 --- a/app/api/logic/UserLogic.php +++ b/app/api/logic/UserLogic.php @@ -69,8 +69,12 @@ class UserLogic extends BaseLogic */ public static function info(int $userId) { - $user = User::where(['id' => $userId]) - ->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,create_time,user_money,income') + $user = User::where(['id' => $userId])->with(['admin' => [ + 'company' => function ($query) { + $query->field('id,company_name'); + } + ]]) + ->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,create_time,user_money,income,admin_id') ->findOrEmpty(); $user['has_password'] = !empty($user['password']); $user['has_auth'] = self::hasWechatAuth($userId); diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index 36bffa06c..d0c94e7fb 100755 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -17,6 +17,7 @@ namespace app\common\model\user; use app\common\enum\user\UserEnum; +use app\common\model\auth\Admin; use app\common\model\BaseModel; use app\common\service\FileService; use think\model\concern\SoftDelete; @@ -172,5 +173,9 @@ class User extends BaseModel return $sn; } + public function admin() + { + return $this->hasOne(Admin::class, 'id', 'admin_id')->field('id,name,company_id'); + } } \ No newline at end of file