From 3d6fcfac8a6c27a9dc3edf8acde2200cdef9bbc1 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Sun, 4 Jan 2026 14:41:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=B9=E6=AC=A1=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=94=AF=E6=8C=81=E8=BF=94=E5=9B=9Esource=5F?= =?UTF-8?q?near?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wpm/views.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/wpm/views.py b/apps/wpm/views.py index 1a0fc458..29e2074f 100644 --- a/apps/wpm/views.py +++ b/apps/wpm/views.py @@ -1077,6 +1077,15 @@ class BatchStViewSet(CustomListModelMixin, ComplexQueryMixin, CustomGenericViewS ordering = ["batch"] filterset_class = BatchStFilter + def add_info_for_list(self, data): + if self.request.query_params.get("with_source_near", None) == "yes": + batchstIds = [ins["id"] for ins in data] + batchlog_qs = BatchLog.objects.filter(target__id__in=batchstIds).values("id", "source", "target") + source_data = BatchStSerializer(instance=BatchSt.objects.filter(id__in=[ins["source"] for ins in batchlog_qs]), many=True).data + source_data_dict = {ins["id"]: ins for ins in source_data} + for item in data: + item["source_near"] = [source_data_dict[ins["source"]] for ins in batchlog_qs if ins["target"] == item["id"]] + return data class MlogbwViewSet(CustomModelViewSet): perms_map = {"get": "*", "post": "mlog.update", "put": "mlog.update", "delete": "mlog.update", "patch": "mlog.update"}