1
0

2 Commits

Author SHA1 Message Date
41032f74af fix(web): ware增加数据资源选择 2024-12-15 23:08:29 +08:00
4ef9c61201 fix(web): 修复ware没有逻辑删除 2024-12-15 23:07:48 +08:00
6 changed files with 70 additions and 3 deletions

View File

@@ -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: "<span class='text-primary' style='cursor: pointer'>${resourceName}</span>",
onEvent: {
click: {
actions: [
{
actionType: 'dialog',
...resourceDetailDialog('resourceId'),
}
]
}
}
}
},
{
type: 'input-text',
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
protected DataResource fromSaveItem(SaveItem item) throws JsonProcessingException {
ResourceType type = generateResourceType(item);

View File

@@ -81,6 +81,7 @@ public class WareController extends SimpleControllerSupport<Ware, WareController
@Data
@EqualsAndHashCode(callSuper = true)
public static class DetailItem extends SaveItem {
private String resourceName;
private LocalDateTime createdTime;
private String createdUsername;
private LocalDateTime modifiedTime;
@@ -89,6 +90,7 @@ public class WareController extends SimpleControllerSupport<Ware, WareController
public DetailItem(Ware ware) {
this.setId(ware.getId());
this.setResourceId(ware.getResource().getId());
this.setResourceName(ware.getResource().getName());
this.setName(ware.getName());
this.setDescription(ware.getDescription());
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")
@ToString.Exclude
private Set<Authentication> authentications;
@OneToOne(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, mappedBy = "resource")
@ToString.Exclude
private Ware ware;
}

View File

@@ -2,7 +2,6 @@ package com.eshore.gringotts.web.domain.entity;
import com.eshore.gringotts.core.Constants;
import com.eshore.gringotts.web.domain.base.entity.LogicDeleteEntity;
import com.eshore.gringotts.web.domain.base.entity.SimpleEntity;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -49,7 +48,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
})
@SQLDelete(sql = "update " + Constants.TABLE_PREFIX + "ware" + " set deleted = true where id = ?")
@Where(clause = LogicDeleteEntity.LOGIC_DELETE_CLAUSE)
public class Ware extends SimpleEntity {
public class Ware extends LogicDeleteEntity {
@OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
@JoinColumn(nullable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
@ToString.Exclude

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.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<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
public Long save(DataResource entity) {
ResourceType type = resourceTypeRepository.save(entity.getType());