1
0

fix(web): ware增加数据资源选择

This commit is contained in:
2024-12-15 23:08:29 +08:00
parent 4ef9c61201
commit 41032f74af
5 changed files with 69 additions and 1 deletions

View File

@@ -1,5 +1,13 @@
import './dialog-ware.css' 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() { function detailForm() {
return { return {
@@ -19,6 +27,34 @@ function detailForm() {
name: 'icon', name: 'icon',
label: '图标', 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: "<span class='text-primary' style='cursor: pointer'>${resourceName}</span>",
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
...resourceDetailDialog('resourceId'),
}
]
}
}
}
},
{ {
type: 'input-text', type: 'input-text',
name: 'name', name: 'name',

View File

@@ -80,6 +80,17 @@ public class DataResourceController extends SimpleControllerSupport<DataResource
})); }));
} }
@GetMapping(LIST + "_no_ware")
public AmisResponse<ImmutableList<ListItem>> listNoWare() {
return AmisResponse.responseSuccess(dataResourceService.listNoWare().collect(entity -> {
try {
return toListItem(entity);
} catch (Exception e) {
throw new RuntimeException(e);
}
}));
}
@Override @Override
protected DataResource fromSaveItem(SaveItem item) throws JsonProcessingException { protected DataResource fromSaveItem(SaveItem item) throws JsonProcessingException {
ResourceType type = generateResourceType(item); ResourceType type = generateResourceType(item);

View File

@@ -81,6 +81,7 @@ public class WareController extends SimpleControllerSupport<Ware, WareController
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class DetailItem extends SaveItem { public static class DetailItem extends SaveItem {
private String resourceName;
private LocalDateTime createdTime; private LocalDateTime createdTime;
private String createdUsername; private String createdUsername;
private LocalDateTime modifiedTime; private LocalDateTime modifiedTime;
@@ -89,6 +90,7 @@ public class WareController extends SimpleControllerSupport<Ware, WareController
public DetailItem(Ware ware) { public DetailItem(Ware ware) {
this.setId(ware.getId()); this.setId(ware.getId());
this.setResourceId(ware.getResource().getId()); this.setResourceId(ware.getResource().getId());
this.setResourceName(ware.getResource().getName());
this.setName(ware.getName()); this.setName(ware.getName());
this.setDescription(ware.getDescription()); this.setDescription(ware.getDescription());
this.setIcon(new FileInfo(ware.getIcon())); this.setIcon(new FileInfo(ware.getIcon()));

View File

@@ -71,4 +71,7 @@ public class DataResource extends LogicDeleteEntity {
@OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, mappedBy = "target") @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, mappedBy = "target")
@ToString.Exclude @ToString.Exclude
private Set<Authentication> authentications; private Set<Authentication> authentications;
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, mappedBy = "resource")
@ToString.Exclude
private Ware ware;
} }

View File

@@ -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.DataResource_; import com.eshore.gringotts.web.domain.entity.DataResource_;
import com.eshore.gringotts.web.domain.entity.User; 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.format.ResourceFormat;
import com.eshore.gringotts.web.domain.entity.type.ResourceType; import com.eshore.gringotts.web.domain.entity.type.ResourceType;
import com.eshore.gringotts.web.domain.repository.DataResourceRepository; import com.eshore.gringotts.web.domain.repository.DataResourceRepository;
@@ -110,6 +111,21 @@ public class DataResourceService extends SimpleServiceSupport<DataResource> {
)); ));
} }
public ImmutableList<DataResource> listNoWare() {
return Lists.immutable.ofAll(dataResourceRepository.findAll(
(root, query, builder) -> {
Join<DataResource, Confirmation> confirmationJoin = root.join(DataResource_.confirmation, JoinType.LEFT);
Join<DataResource, Ware> 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 @Override
public Long save(DataResource entity) { public Long save(DataResource entity) {
ResourceType type = resourceTypeRepository.save(entity.getType()); ResourceType type = resourceTypeRepository.save(entity.getType());