作者 jinglong
1 个管道 的构建 通过 耗费 13 秒

优化项目列表接口

@@ -262,6 +262,12 @@ class IndexController extends RestBaseController @@ -262,6 +262,12 @@ class IndexController extends RestBaseController
262 } 262 }
263 $acronym =array_values(array_unique($acronym)); 263 $acronym =array_values(array_unique($acronym));
264 sort($acronym); 264 sort($acronym);
  265 + if(in_array('#',$acronym)){
  266 + //去掉第一个
  267 + array_shift($acronym);
  268 + //增加一个到最后
  269 + array_push($acronym,'#');
  270 + }
265 $arr1 = []; 271 $arr1 = [];
266 foreach($acronym as $a_key=>$a_value){ 272 foreach($acronym as $a_key=>$a_value){
267 $k = 0; 273 $k = 0;
@@ -275,27 +281,7 @@ class IndexController extends RestBaseController @@ -275,27 +281,7 @@ class IndexController extends RestBaseController
275 } 281 }
276 } 282 }
277 } 283 }
278 -  
279 - if(in_array('#',$acronym)){  
280 - $count = count($acronym);  
281 - foreach ($arr1 as $key=>$a_value){  
282 - if($a_value['acronym'] == '#'){  
283 - $arr1[$count-1] = $a_value;  
284 - }else{  
285 - $arr1[$key-1] = $a_value;  
286 - }  
287 - }  
288 -  
289 - foreach($acronym as $key1=>$a_value1){  
290 - if($a_value1 == '#'){  
291 - $acronym[$count-1] = $a_value1;  
292 - }else{  
293 - $acronym[$key1-1] = $a_value1;  
294 - }  
295 - }  
296 - }  
297 -  
298 - $arr2['project_a'] = $acronym; 284 + $arr2['project_a'] = $acronym;//首字母数组
299 $arr2['project_n'] = $arr1; 285 $arr2['project_n'] = $arr1;
300 } 286 }
301 287
@@ -66,6 +66,12 @@ class InformationController extends RestBaseController @@ -66,6 +66,12 @@ class InformationController extends RestBaseController
66 } 66 }
67 $acronym =array_values(array_unique($acronym)); 67 $acronym =array_values(array_unique($acronym));
68 sort($acronym); 68 sort($acronym);
  69 + if(in_array('#',$acronym)){
  70 + //去掉第一个
  71 + array_shift($acronym);
  72 + //增加一个到最后
  73 + array_push($acronym,'#');
  74 + }
69 $arr1 = []; 75 $arr1 = [];
70 foreach($acronym as $a_key=>$a_value){ 76 foreach($acronym as $a_key=>$a_value){
71 $k = 0; 77 $k = 0;
@@ -79,26 +85,6 @@ class InformationController extends RestBaseController @@ -79,26 +85,6 @@ class InformationController extends RestBaseController
79 } 85 }
80 } 86 }
81 } 87 }
82 -  
83 - if(in_array('#',$acronym)){  
84 - $count = count($acronym);  
85 - foreach ($arr1 as $key=>$a_value){  
86 - if($a_value['acronym'] == '#'){  
87 - $arr1[$count-1] = $a_value;  
88 - }else{  
89 - $arr1[$key-1] = $a_value;  
90 - }  
91 - }  
92 -  
93 - foreach($acronym as $key1=>$a_value1){  
94 - if($a_value1 == '#'){  
95 - $acronym[$count-1] = $a_value1;  
96 - }else{  
97 - $acronym[$key1-1] = $a_value1;  
98 - }  
99 - }  
100 - }  
101 -  
102 $arr2['project_a'] = $acronym; 88 $arr2['project_a'] = $acronym;
103 $arr2['project_n'] = $arr1; 89 $arr2['project_n'] = $arr1;
104 } 90 }
@@ -74,6 +74,12 @@ class ReportController extends RestBaseController @@ -74,6 +74,12 @@ class ReportController extends RestBaseController
74 } 74 }
75 $acronym =array_values(array_unique($acronym)); 75 $acronym =array_values(array_unique($acronym));
76 sort($acronym); 76 sort($acronym);
  77 + if(in_array('#',$acronym)){
  78 + //去掉第一个
  79 + array_shift($acronym);
  80 + //增加一个到最后
  81 + array_push($acronym,'#');
  82 + }
77 $arr1 = []; 83 $arr1 = [];
78 foreach($acronym as $a_key=>$a_value){ 84 foreach($acronym as $a_key=>$a_value){
79 $k = 0; 85 $k = 0;
@@ -87,25 +93,6 @@ class ReportController extends RestBaseController @@ -87,25 +93,6 @@ class ReportController extends RestBaseController
87 } 93 }
88 } 94 }
89 } 95 }
90 - if(in_array('#',$acronym)){  
91 - $count = count($acronym);  
92 - foreach ($arr1 as $key=>$a_value){  
93 - if($a_value['acronym'] == '#'){  
94 - $arr1[$count-1] = $a_value;  
95 - }else{  
96 - $arr1[$key-1] = $a_value;  
97 - }  
98 - }  
99 -  
100 - foreach($acronym as $key1=>$a_value1){  
101 - if($a_value1 == '#'){  
102 - $acronym[$count-1] = $a_value1;  
103 - }else{  
104 - $acronym[$key1-1] = $a_value1;  
105 - }  
106 - }  
107 - }  
108 -  
109 $arr2['title_a'] = $acronym; 96 $arr2['title_a'] = $acronym;
110 $arr2['title_n'] = $arr1; 97 $arr2['title_n'] = $arr1;
111 } 98 }