正在显示
1 个修改的文件
包含
85 行增加
和
25 行删除
| @@ -68,39 +68,31 @@ class TranslateController extends BaseController | @@ -68,39 +68,31 @@ class TranslateController extends BaseController | ||
| 68 | $this->map['type'] = 1; | 68 | $this->map['type'] = 1; |
| 69 | $data = $translate->formatQuery($this->map)->with('translate_data')->get()->toArray(); | 69 | $data = $translate->formatQuery($this->map)->with('translate_data')->get()->toArray(); |
| 70 | $keyModel = new TranslateKey(); | 70 | $keyModel = new TranslateKey(); |
| 71 | - $keyList = $keyModel->list(); | 71 | + $keyList = $keyModel->list([],'id',['*'],'asc'); |
| 72 | if(empty($data) && empty($keyList)){ | 72 | if(empty($data) && empty($keyList)){ |
| 73 | $this->response('导出数据为空',Code::SYSTEM_ERROR); | 73 | $this->response('导出数据为空',Code::SYSTEM_ERROR); |
| 74 | } | 74 | } |
| 75 | if(empty($data)){ | 75 | if(empty($data)){ |
| 76 | - foreach ($keyList as $values){ | ||
| 77 | - $key_data = json_decode($values['proof_key'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | ||
| 78 | - $resData['route'] = $values['url']; | ||
| 79 | - $resData['source'] = $values['source']; | ||
| 80 | - $resData['source_id'] = $values['source_id']; | ||
| 81 | - $resData['is_list'] = $values['is_list']; | ||
| 82 | - $resData['is_custom'] = $values['is_custom']; | ||
| 83 | - $resData['page'] = $values['page']; | ||
| 84 | - foreach ($key_data as $key_val){ | ||
| 85 | - $resData['data'][] = [$key_val => '']; | ||
| 86 | - } | ||
| 87 | - $res_data[] = $resData; | ||
| 88 | - } | 76 | + $res_data = $this->resEmptyData($keyList); |
| 89 | $this->response('success',Code::SUCCESS,$res_data); | 77 | $this->response('success',Code::SUCCESS,$res_data); |
| 90 | } | 78 | } |
| 91 | if(empty($keyList)){ | 79 | if(empty($keyList)){ |
| 92 | - foreach ($data as $values){ | ||
| 93 | - $resData['route'] = $values['url']; | ||
| 94 | - $resData['source'] = $values['source']; | ||
| 95 | - $resData['source_id'] = $values['source_id']; | ||
| 96 | - $resData['is_list'] = $values['is_list']; | ||
| 97 | - $resData['is_custom'] = $values['is_custom']; | ||
| 98 | - $resData['page'] = $values['page']; | ||
| 99 | - $resData['data'] = json_decode($values['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | ||
| 100 | - $res_data[] = $resData; | ||
| 101 | - } | 80 | + $res_data = $this->resEmptyKey($data); |
| 102 | $this->response('success',Code::SUCCESS,$res_data); | 81 | $this->response('success',Code::SUCCESS,$res_data); |
| 103 | } | 82 | } |
| 83 | + $res_data = $this->resData($keyList,$data); | ||
| 84 | + $this->response('success',Code::SUCCESS,$res_data); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * @remark :都不为处理数据 | ||
| 89 | + * @name :resData | ||
| 90 | + * @author :lyh | ||
| 91 | + * @method :post | ||
| 92 | + * @time :2024/11/22 17:50 | ||
| 93 | + */ | ||
| 94 | + public function resData($keyList,$data){ | ||
| 95 | + $result_key_data = []; | ||
| 104 | foreach ($data as $values){ | 96 | foreach ($data as $values){ |
| 105 | $resData['route'] = $values['url']; | 97 | $resData['route'] = $values['url']; |
| 106 | $resData['source'] = $values['source']; | 98 | $resData['source'] = $values['source']; |
| @@ -120,13 +112,81 @@ class TranslateController extends BaseController | @@ -120,13 +112,81 @@ class TranslateController extends BaseController | ||
| 120 | } | 112 | } |
| 121 | } | 113 | } |
| 122 | $resData['data'] = $translate_data; | 114 | $resData['data'] = $translate_data; |
| 115 | + //去除,已匹配的页面统计出来 | ||
| 116 | + $result_key_data[] = $v1; | ||
| 123 | } | 117 | } |
| 124 | } | 118 | } |
| 125 | $res_data[] = $resData; | 119 | $res_data[] = $resData; |
| 126 | } | 120 | } |
| 127 | - $this->response('success',Code::SUCCESS,$res_data); | 121 | + // 排除掉 $result_key_data 中的元素 |
| 122 | + $result = array_udiff($keyList, $result_key_data, function ($a, $b) { | ||
| 123 | + return strcmp(json_encode($a), json_encode($b)); | ||
| 124 | + }); | ||
| 125 | + $result_key_list = array_values($result); // 重置键名 | ||
| 126 | + if(!empty($result_key_list)){ | ||
| 127 | + foreach ($result_key_list as $values){ | ||
| 128 | + $resData['route'] = $values['url']; | ||
| 129 | + $resData['source'] = $values['source']; | ||
| 130 | + $resData['source_id'] = $values['source_id']; | ||
| 131 | + $resData['is_list'] = $values['is_list']; | ||
| 132 | + $resData['is_custom'] = $values['is_custom']; | ||
| 133 | + $resData['page'] = $values['page']; | ||
| 134 | + $key_data = json_decode($values['proof_key'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | ||
| 135 | + foreach ($key_data as $key_val){ | ||
| 136 | + $resData['data'][] = [$key_val => '']; | ||
| 137 | + } | ||
| 138 | + $res_data[] = $resData; | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + return $res_data; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * @remark :data值为空 按原key返回 | ||
| 146 | + * @name :resEmptyKeyList | ||
| 147 | + * @author :lyh | ||
| 148 | + * @method :post | ||
| 149 | + * @time :2024/11/22 17:45 | ||
| 150 | + */ | ||
| 151 | + public function resEmptyData($keyList){ | ||
| 152 | + $res_data = []; | ||
| 153 | + foreach ($keyList as $values){ | ||
| 154 | + $key_data = json_decode($values['proof_key'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | ||
| 155 | + $resData['route'] = $values['url']; | ||
| 156 | + $resData['source'] = $values['source']; | ||
| 157 | + $resData['source_id'] = $values['source_id']; | ||
| 158 | + $resData['is_list'] = $values['is_list']; | ||
| 159 | + $resData['is_custom'] = $values['is_custom']; | ||
| 160 | + $resData['page'] = $values['page']; | ||
| 161 | + foreach ($key_data as $key_val){ | ||
| 162 | + $resData['data'][] = [$key_val => '']; | ||
| 163 | + } | ||
| 164 | + $res_data[] = $resData; | ||
| 165 | + } | ||
| 166 | + return $res_data; | ||
| 128 | } | 167 | } |
| 129 | 168 | ||
| 169 | + /** | ||
| 170 | + * @remark :key为空 直接返回data | ||
| 171 | + * @name :resEmptyKey | ||
| 172 | + * @author :lyh | ||
| 173 | + * @method :post | ||
| 174 | + * @time :2024/11/22 17:48 | ||
| 175 | + */ | ||
| 176 | + public function resEmptyKey($data){ | ||
| 177 | + $res_data = []; | ||
| 178 | + foreach ($data as $values){ | ||
| 179 | + $resData['route'] = $values['url']; | ||
| 180 | + $resData['source'] = $values['source']; | ||
| 181 | + $resData['source_id'] = $values['source_id']; | ||
| 182 | + $resData['is_list'] = $values['is_list']; | ||
| 183 | + $resData['is_custom'] = $values['is_custom']; | ||
| 184 | + $resData['page'] = $values['page']; | ||
| 185 | + $resData['data'] = json_decode($values['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | ||
| 186 | + $res_data[] = $resData; | ||
| 187 | + } | ||
| 188 | + return $res_data; | ||
| 189 | + } | ||
| 130 | 190 | ||
| 131 | /** | 191 | /** |
| 132 | * @remark :图片列表 | 192 | * @remark :图片列表 |
-
请 注册 或 登录 后发表评论