feat(web): 实现任务显示文件列表
This commit is contained in:
@@ -21,7 +21,10 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.eclipse.collections.api.factory.Sets;
|
||||||
import org.eclipse.collections.api.list.ImmutableList;
|
import org.eclipse.collections.api.list.ImmutableList;
|
||||||
|
import org.eclipse.collections.api.set.ImmutableSet;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@@ -56,6 +59,26 @@ public class DataFileController {
|
|||||||
this.sliceFolderPath = StrUtil.format("{}/slice", uploadFolderPath);
|
this.sliceFolderPath = StrUtil.format("{}/slice", uploadFolderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/detail")
|
||||||
|
public AmisResponse<?> detail(@RequestBody DetailRequest request) {
|
||||||
|
var mapper = Mappers.getMapper(DetailResponse.Mapper.class);
|
||||||
|
return AmisResponse.responseCrudData(dataFileService.downloadFile(request.ids).collect(mapper::from));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public AmisResponse<?> detail(@RequestParam("ids") String ids) {
|
||||||
|
if (StrUtil.isBlank(ids)) {
|
||||||
|
return AmisResponse.responseCrudData(Sets.immutable.empty());
|
||||||
|
}
|
||||||
|
var mapper = Mappers.getMapper(DetailResponse.Mapper.class);
|
||||||
|
return AmisResponse.responseCrudData(
|
||||||
|
dataFileService.downloadFile(
|
||||||
|
Sets.immutable.ofAll(StrUtil.split(ids, ","))
|
||||||
|
.collect(Long::parseLong)
|
||||||
|
).collect(mapper::from)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("")
|
@PostMapping("")
|
||||||
public AmisResponse<FinishResponse> upload(@RequestParam("file") MultipartFile file) throws IOException {
|
public AmisResponse<FinishResponse> upload(@RequestParam("file") MultipartFile file) throws IOException {
|
||||||
String filename = file.getOriginalFilename();
|
String filename = file.getOriginalFilename();
|
||||||
@@ -170,6 +193,24 @@ public class DataFileController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static final class DetailRequest {
|
||||||
|
private ImmutableSet<Long> ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static final class DetailResponse {
|
||||||
|
private Long id;
|
||||||
|
private String filename;
|
||||||
|
private Long size;
|
||||||
|
private String md5;
|
||||||
|
|
||||||
|
@org.mapstruct.Mapper
|
||||||
|
public interface Mapper {
|
||||||
|
DetailResponse from(DataFile file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static final class StartRequest {
|
public static final class StartRequest {
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ const FlowTask: React.FC = () => {
|
|||||||
return {
|
return {
|
||||||
...payload,
|
...payload,
|
||||||
data: {
|
data: {
|
||||||
...generateInputForm(payload.data, undefined, false),
|
...generateInputForm(payload.data, undefined, false, true),
|
||||||
id: 'db8a4d10-0c47-4e27-b1a4-d0f2e1c15992',
|
id: 'db8a4d10-0c47-4e27-b1a4-d0f2e1c15992',
|
||||||
initApi: {
|
initApi: {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type {Schema} from 'amis'
|
import type {Schema} from 'amis'
|
||||||
import {commonInfo} from '../../../util/amis.tsx'
|
import {commonInfo, formInputFileStaticColumns} from '../../../util/amis.tsx'
|
||||||
|
|
||||||
export const typeMap: Record<string, string> = {
|
export const typeMap: Record<string, string> = {
|
||||||
text: '文本',
|
text: '文本',
|
||||||
@@ -13,7 +13,7 @@ export type InputField = {
|
|||||||
description?: string
|
description?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generateInputForm: (inputSchema: Record<string, InputField>, title?: string, border?: boolean, staticView?: boolean) => Schema = (inputSchema, title, border) => {
|
export const generateInputForm: (inputSchema: Record<string, InputField>, title?: string, border?: boolean, staticView?: boolean) => Schema = (inputSchema, title, border, staticView) => {
|
||||||
let items: Schema[] = []
|
let items: Schema[] = []
|
||||||
for (const name of Object.keys(inputSchema)) {
|
for (const name of Object.keys(inputSchema)) {
|
||||||
let field = inputSchema[name]
|
let field = inputSchema[name]
|
||||||
@@ -34,18 +34,30 @@ export const generateInputForm: (inputSchema: Record<string, InputField>, title?
|
|||||||
commonMeta.type = 'input-number'
|
commonMeta.type = 'input-number'
|
||||||
break
|
break
|
||||||
case 'files':
|
case 'files':
|
||||||
items.push({
|
if (staticView) {
|
||||||
...commonMeta,
|
items.push({
|
||||||
type: 'input-file',
|
...commonMeta,
|
||||||
autoUpload: false,
|
type: 'control',
|
||||||
drag: true,
|
body: {
|
||||||
multiple: true,
|
type: 'crud',
|
||||||
joinValues: false,
|
api: `${commonInfo.baseAiUrl}/upload/detail?ids=\${JOIN(inputData.${name}, ',')}`,
|
||||||
extractValue: true,
|
columns: formInputFileStaticColumns,
|
||||||
accept: '*',
|
}
|
||||||
maxSize: 104857600,
|
})
|
||||||
receiver: `${commonInfo.baseAiUrl}/upload`,
|
} else {
|
||||||
})
|
items.push({
|
||||||
|
...commonMeta,
|
||||||
|
type: 'input-file',
|
||||||
|
autoUpload: false,
|
||||||
|
drag: true,
|
||||||
|
multiple: true,
|
||||||
|
joinValues: false,
|
||||||
|
extractValue: true,
|
||||||
|
accept: '*',
|
||||||
|
maxSize: 104857600,
|
||||||
|
receiver: `${commonInfo.baseAiUrl}/upload`,
|
||||||
|
})
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2519,7 +2519,7 @@ export function pictureFromIds(field: string) {
|
|||||||
return `\${ARRAYMAP(${field},id => '${commonInfo.baseAiUrl}/upload/download/' + id)}`
|
return `\${ARRAYMAP(${field},id => '${commonInfo.baseAiUrl}/upload/download/' + id)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const formInputFileStaticColumns = [
|
export const formInputFileStaticColumns = [
|
||||||
{
|
{
|
||||||
name: 'filename',
|
name: 'filename',
|
||||||
label: '文件名',
|
label: '文件名',
|
||||||
|
|||||||
Reference in New Issue
Block a user