|
@@ -3365,4 +3365,37 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
return Result::error($e->getMessage(), 0);
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 删除网站url
|
|
|
+ * @param array $data
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function delWebsiteUrl(array $data): array{
|
|
|
+ try {
|
|
|
+ $wensiteInfo = Website::where(["id" => $data['website_id']])->first();
|
|
|
+ if (empty($wensiteInfo)) {
|
|
|
+ return Result::error("找不到该网站", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ $websiteUrlArray = [];
|
|
|
+ if (!empty($wensiteInfo->website_url)) {
|
|
|
+ $decoded = json_decode((string) $wensiteInfo->website_url, true);
|
|
|
+ $websiteUrlArray = is_array($decoded) ? $decoded : [];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从数组中按值删除对应的 URL
|
|
|
+ $index = array_search($data['website_url'] ?? null, $websiteUrlArray, true);
|
|
|
+ if ($index !== false) {
|
|
|
+ unset($websiteUrlArray[$index]);
|
|
|
+ // 重新索引,保持为连续的 JSON 数组
|
|
|
+ $websiteUrlArray = array_values($websiteUrlArray);
|
|
|
+ }
|
|
|
+
|
|
|
+ $newWebsiteUrlJson = json_encode($websiteUrlArray, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
|
+ Website::where(["id" => $data['website_id']])->update(["website_url" => $newWebsiteUrlJson]);
|
|
|
+ return Result::success([]);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return Result::error($e->getMessage(), 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|