fix(web): ware增加数据资源选择
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user