feat(web): 实现任务显示文件列表
This commit is contained in:
@@ -21,7 +21,10 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.collections.api.factory.Sets;
|
||||
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.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -56,6 +59,26 @@ public class DataFileController {
|
||||
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("")
|
||||
public AmisResponse<FinishResponse> upload(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
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
|
||||
public static final class StartRequest {
|
||||
private String name;
|
||||
|
||||
@@ -107,7 +107,7 @@ const FlowTask: React.FC = () => {
|
||||
return {
|
||||
...payload,
|
||||
data: {
|
||||
...generateInputForm(payload.data, undefined, false),
|
||||
...generateInputForm(payload.data, undefined, false, true),
|
||||
id: 'db8a4d10-0c47-4e27-b1a4-d0f2e1c15992',
|
||||
initApi: {
|
||||
method: 'get',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type {Schema} from 'amis'
|
||||
import {commonInfo} from '../../../util/amis.tsx'
|
||||
import {commonInfo, formInputFileStaticColumns} from '../../../util/amis.tsx'
|
||||
|
||||
export const typeMap: Record<string, string> = {
|
||||
text: '文本',
|
||||
@@ -13,7 +13,7 @@ export type InputField = {
|
||||
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[] = []
|
||||
for (const name of Object.keys(inputSchema)) {
|
||||
let field = inputSchema[name]
|
||||
@@ -34,18 +34,30 @@ export const generateInputForm: (inputSchema: Record<string, InputField>, title?
|
||||
commonMeta.type = 'input-number'
|
||||
break
|
||||
case 'files':
|
||||
items.push({
|
||||
...commonMeta,
|
||||
type: 'input-file',
|
||||
autoUpload: false,
|
||||
drag: true,
|
||||
multiple: true,
|
||||
joinValues: false,
|
||||
extractValue: true,
|
||||
accept: '*',
|
||||
maxSize: 104857600,
|
||||
receiver: `${commonInfo.baseAiUrl}/upload`,
|
||||
})
|
||||
if (staticView) {
|
||||
items.push({
|
||||
...commonMeta,
|
||||
type: 'control',
|
||||
body: {
|
||||
type: 'crud',
|
||||
api: `${commonInfo.baseAiUrl}/upload/detail?ids=\${JOIN(inputData.${name}, ',')}`,
|
||||
columns: formInputFileStaticColumns,
|
||||
}
|
||||
})
|
||||
} 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2519,7 +2519,7 @@ export function pictureFromIds(field: string) {
|
||||
return `\${ARRAYMAP(${field},id => '${commonInfo.baseAiUrl}/upload/download/' + id)}`
|
||||
}
|
||||
|
||||
const formInputFileStaticColumns = [
|
||||
export const formInputFileStaticColumns = [
|
||||
{
|
||||
name: 'filename',
|
||||
label: '文件名',
|
||||
|
||||
Reference in New Issue
Block a user