From 76e4b9712c4451f982d8d48b2f7b1ee7ccc97a45 Mon Sep 17 00:00:00 2001
From: vilson <545522390@qq.com>
Date: Mon, 15 Jul 2019 07:18:37 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: vilson <545522390@qq.com>
---
 application/common/Model/Member.php        |  8 ++++----
 application/project/controller/Account.php | 12 ++++++------
 application/project/controller/Index.php   |  6 +++---
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/application/common/Model/Member.php b/application/common/Model/Member.php
index 482a646..a8d6b2e 100644
--- a/application/common/Model/Member.php
+++ b/application/common/Model/Member.php
@@ -30,16 +30,16 @@ class Member extends CommonModel
         $organizationList = [];
         if ($list) {
             foreach ($list as &$item) {
-                $departments = '';
+                $departments = [];
                 $departmentCodes = $item['department_code'];
                 if ($departmentCodes) {
                     $departmentCodes = explode(',', $departmentCodes);
                     foreach ($departmentCodes as $departmentCode) {
                         $department = Department::where(['code' => $departmentCode])->field('name')->find();
-                        $departments .= "{$department['name']} ";
+                        $departments[] = $department['name'];
                     }
                 }
-                $item['department'] = $departments;
+                $item['department'] = implode(' - ', $departments);
                 $organization = Organization::where(['code' => $item['organization_code']])->find();
                 if ($organization) {
                     $organizationList[] = $organization;
@@ -50,7 +50,7 @@ class Member extends CommonModel
         $member['is_owner'] = $list[0]['is_owner'];
         $member['authorize'] = $list[0]['authorize'];
         $member['position'] = $list[0]['position'];
-        $member['department'] = $list[0]['department'];
+        $member['department'] = implode(' - ', $list[0]['department']);
 
         setCurrentMember($member);
         !empty($member['authorize']) && NodeService::applyProjectAuthNode();
diff --git a/application/project/controller/Account.php b/application/project/controller/Account.php
index c857a8b..a7963db 100644
--- a/application/project/controller/Account.php
+++ b/application/project/controller/Account.php
@@ -78,16 +78,16 @@ class Account extends BasicApi
                 if ($memberInfo) {
                     $item['avatar'] = $memberInfo['avatar'];
                 }
-                $departments = '';
+                $departments = [];
                 $departmentCodes = $item['department_code'];
                 if ($departmentCodes) {
                     $departmentCodes = explode(',', $departmentCodes);
                     foreach ($departmentCodes as $departmentCode) {
                         $department = \app\common\Model\Department::where(['code' => $departmentCode])->field('name')->find();
-                        $departments .= "{$department['name']} ";
+                        $departments[] = $department['name'];
                     }
                 }
-                $item['departments'] = $departments;
+                $item['departments'] = implode(' - ', $departments);
             }
             unset($item);
         }
@@ -103,16 +103,16 @@ class Account extends BasicApi
         }
         $memberAccount = $this->model->where(['code' => $code])->field('id', true)->find();
         if ($memberAccount) {
-            $departments = '';
+            $departments = [];
             $departmentCodes = $memberAccount['department_code'];
             if ($departmentCodes) {
                 $departmentCodes = explode(',', $departmentCodes);
                 foreach ($departmentCodes as $departmentCode) {
                     $department = \app\common\Model\Department::where(['code' => $departmentCode])->field('name')->find();
-                    $departments .= "{$department['name']} ";
+                    $departments[] = $department['name'];
                 }
             }
-            $memberAccount['departments'] = $departments;
+            $memberAccount['departments'] = implode(' - ', $departments);
         }
         $this->success('', $memberAccount);
     }
diff --git a/application/project/controller/Index.php b/application/project/controller/Index.php
index a918d02..07ab69e 100644
--- a/application/project/controller/Index.php
+++ b/application/project/controller/Index.php
@@ -60,17 +60,17 @@ class Index extends BasicApi
             $memberAccount = MemberAccount::where(['member_code' => $member['code'], 'organization_code' => $organizationCode])->find();
             $member = Member::where(['account' => $member['account']])->order('id asc')->find()->toArray();
 
-            $departments = '';
+            $departments = [];
             $departmentCodes = $memberAccount['department_code'];
             if ($departmentCodes) {
                 $departmentCodes = explode(',', $departmentCodes);
                 foreach ($departmentCodes as $departmentCode) {
                     $department = Department::where(['code' => $departmentCode])->field('name')->find();
-                    $departments .= "{$department['name']} ";
+                    $departments[] = $department['name'];
                 }
             }
             $member['position'] = $memberAccount['position'];
-            $member['department'] = $departments;
+            $member['department'] = implode(' - ', $departments);
             $member['account_id'] = $memberAccount['id'];
             $member['is_owner'] = $memberAccount['is_owner'];
             $member['authorize'] = $memberAccount['authorize'];