From 41032f74af2654f96792179f3be94d47502f7f95 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Sun, 15 Dec 2024 23:08:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(web):=20ware=E5=A2=9E=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=B5=84=E6=BA=90=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ware/dialog-ware.js | 38 ++++++++++++++++++- .../controller/DataResourceController.java | 11 ++++++ .../web/domain/controller/WareController.java | 2 + .../web/domain/entity/DataResource.java | 3 ++ .../domain/service/DataResourceService.java | 16 ++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/gringotts-frontend/components/ware/dialog-ware.js b/gringotts-frontend/components/ware/dialog-ware.js index 49ac8b6..08e91ba 100644 --- a/gringotts-frontend/components/ware/dialog-ware.js +++ b/gringotts-frontend/components/ware/dialog-ware.js @@ -1,5 +1,13 @@ import './dialog-ware.css' -import {apiGet, apiPost, formInputClearable, horizontalFormOptions, information} from "../constants.js"; +import { + apiGet, + apiPost, + formInputClearable, + horizontalFormOptions, + information, +} from "../constants.js"; +import {resourceList} from '../../pages/index/tab-data.js' +import {resourceDetailDialog} from '../resource/dialog-resource.js' function detailForm() { return { @@ -19,6 +27,34 @@ function detailForm() { name: 'icon', label: '图标', }, + { + type: 'picker', + name: 'resourceId', + label: '数据资源', + required: true, + multiple: false, + size: 'md', + valueField: 'id', + labelField: 'name', + source: apiGet('${base}/data_resource/list_no_ware'), + pickerSchema: { + ...resourceList(), + }, + staticSchema: { + type: 'tpl', + tpl: "${resourceName}", + onEvent: { + click: { + actions: [ + { + actionType: 'dialog', + ...resourceDetailDialog('resourceId'), + } + ] + } + } + } + }, { type: 'input-text', name: 'name', diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/DataResourceController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/DataResourceController.java index b1bc27e..2ce8df8 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/DataResourceController.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/DataResourceController.java @@ -80,6 +80,17 @@ public class DataResourceController extends SimpleControllerSupport> listNoWare() { + return AmisResponse.responseSuccess(dataResourceService.listNoWare().collect(entity -> { + try { + return toListItem(entity); + } catch (Exception e) { + throw new RuntimeException(e); + } + })); + } + @Override protected DataResource fromSaveItem(SaveItem item) throws JsonProcessingException { ResourceType type = generateResourceType(item); diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/WareController.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/WareController.java index 13b8e43..7b54f5d 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/WareController.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/controller/WareController.java @@ -81,6 +81,7 @@ public class WareController extends SimpleControllerSupport authentications; + @OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, mappedBy = "resource") + @ToString.Exclude + private Ware ware; } diff --git a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/DataResourceService.java b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/DataResourceService.java index 9ece2f9..6e540a3 100644 --- a/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/DataResourceService.java +++ b/gringotts-web/src/main/java/com/eshore/gringotts/web/domain/service/DataResourceService.java @@ -8,6 +8,7 @@ import com.eshore.gringotts.web.domain.entity.Confirmation_; import com.eshore.gringotts.web.domain.entity.DataResource; import com.eshore.gringotts.web.domain.entity.DataResource_; import com.eshore.gringotts.web.domain.entity.User; +import com.eshore.gringotts.web.domain.entity.Ware; import com.eshore.gringotts.web.domain.entity.format.ResourceFormat; import com.eshore.gringotts.web.domain.entity.type.ResourceType; import com.eshore.gringotts.web.domain.repository.DataResourceRepository; @@ -110,6 +111,21 @@ public class DataResourceService extends SimpleServiceSupport { )); } + public ImmutableList listNoWare() { + return Lists.immutable.ofAll(dataResourceRepository.findAll( + (root, query, builder) -> { + Join confirmationJoin = root.join(DataResource_.confirmation, JoinType.LEFT); + Join wareJoin = root.join(DataResource_.ware, JoinType.LEFT); + return builder.and( + builder.isNotNull(confirmationJoin), + builder.equal(confirmationJoin.get(Confirmation_.state), Confirmation.State.NORMAL), + builder.isNull(wareJoin), + builder.equal(root.get(DataResource_.createdUser), userService.currentLoginUser()) + ); + } + )); + } + @Override public Long save(DataResource entity) { ResourceType type = resourceTypeRepository.save(entity.getType());