diff --git a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/controller/task/TaskController.java b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/controller/task/TaskController.java index 8d42e94..dd84d50 100644 --- a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/controller/task/TaskController.java +++ b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/controller/task/TaskController.java @@ -2,19 +2,22 @@ package com.lanyuanxiaoyao.service.ai.web.controller.task; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse; import com.lanyuanxiaoyao.service.ai.web.base.controller.SimpleControllerSupport; import com.lanyuanxiaoyao.service.ai.web.base.entity.SimpleItem; import com.lanyuanxiaoyao.service.ai.web.entity.FlowTask; import com.lanyuanxiaoyao.service.ai.web.entity.FlowTaskTemplate; import com.lanyuanxiaoyao.service.ai.web.service.task.FlowTaskService; import com.lanyuanxiaoyao.service.ai.web.service.task.FlowTaskTemplateService; +import java.util.Map; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; -import org.mapstruct.Context; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -22,15 +25,23 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("flow_task") public class TaskController extends SimpleControllerSupport { + private final FlowTaskService flowTaskService; private final FlowTaskTemplateService flowTaskTemplateService; private final ObjectMapper mapper; public TaskController(FlowTaskService flowTaskService, FlowTaskTemplateService flowTaskTemplateService, Jackson2ObjectMapperBuilder builder) { super(flowTaskService); + this.flowTaskService = flowTaskService; this.flowTaskTemplateService = flowTaskTemplateService; this.mapper = builder.build(); } + @GetMapping("input_data/{id}") + public AmisResponse getInputSchema(@PathVariable("id") Long id) throws JsonProcessingException { + var task = flowTaskService.detailOrThrow(id); + return AmisResponse.responseSuccess(mapper.readValue(task.getInput(), Map.class)); + } + @Override protected SaveItemMapper saveItemMapper() { return item -> { @@ -45,13 +56,13 @@ public class TaskController extends SimpleControllerSupport listItemMapper() { ListItem.Mapper map = Mappers.getMapper(ListItem.Mapper.class); - return task -> map.from(task, mapper); + return map::from; } @Override protected DetailItemMapper detailItemMapper() { DetailItem.Mapper map = Mappers.getMapper(DetailItem.Mapper.class); - return task -> map.from(task, mapper); + return map::from; } @Data @@ -64,17 +75,14 @@ public class TaskController extends SimpleControllerSupport getInputSchema(@PathVariable("id") Long id) throws JsonProcessingException { + var template = flowTaskTemplateService.detailOrThrow(id); + return AmisResponse.responseSuccess(mapper.readValue(template.getInputSchema(), Map.class)); + } + @PostMapping("update_flow_graph") public AmisResponse updateFlowGraph(@RequestBody UpdateGraphItem item) throws JsonProcessingException { flowTaskTemplateService.updateFlowGraph(item.getId(), mapper.writeValueAsString(item.getGraph())); @@ -41,7 +49,7 @@ public class TaskTemplateController extends SimpleControllerSupport saveItemMapper() { - SaveItem.Mapper map = Mappers.getMapper(SaveItem.Mapper.class); + var map = Mappers.getMapper(SaveItem.Mapper.class); return item -> map.from(item, mapper); } @@ -52,7 +60,7 @@ public class TaskTemplateController extends SimpleControllerSupport detailItemMapper() { - DetailItem.Mapper map = Mappers.getMapper(DetailItem.Mapper.class); + var map = Mappers.getMapper(DetailItem.Mapper.class); return template -> map.from(template, mapper); } diff --git a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/service/task/FlowTaskTemplateService.java b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/service/task/FlowTaskTemplateService.java index c46e759..41f6ab1 100644 --- a/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/service/task/FlowTaskTemplateService.java +++ b/service-ai/service-ai-web/src/main/java/com/lanyuanxiaoyao/service/ai/web/service/task/FlowTaskTemplateService.java @@ -16,7 +16,7 @@ public class FlowTaskTemplateService extends SimpleServiceSupport { actionType: 'setValue', args: { value: { - inputPreview: generateInputForm(inputSchema), + inputPreview: generateInputForm(inputSchema, '入参表单预览'), }, }, }) @@ -75,6 +75,8 @@ const FlowTaskTemplateEdit: React.FC = () => { label: '名称', required: true, clearable: true, + maxLength: 10, + showCounter: true, }, { type: 'textarea', @@ -82,6 +84,8 @@ const FlowTaskTemplateEdit: React.FC = () => { label: '描述', required: true, clearable: true, + maxLength: 500, + showCounter: true, }, { type: 'group', diff --git a/service-web/client/src/util/amis.tsx b/service-web/client/src/util/amis.tsx index d6c2c6f..34cd420 100644 --- a/service-web/client/src/util/amis.tsx +++ b/service-web/client/src/util/amis.tsx @@ -10,8 +10,8 @@ import {isEqual} from 'licia' export const commonInfo = { debug: isEqual(import.meta.env.MODE, 'development'), baseUrl: 'http://132.126.207.130:35690/hudi_services/service_web', - // baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web', - baseAiUrl: 'http://localhost:8080', + baseAiUrl: 'http://132.126.207.130:35690/hudi_services/service_ai_web', + // baseAiUrl: 'http://localhost:8080', authorizationHeaders: { 'Authorization': 'Basic QXhoRWJzY3dzSkRiWU1IMjpjWXhnM2I0UHRXb1ZENVNqRmF5V3h0blNWc2p6UnNnNA==', 'Content-Type': 'application/json', @@ -278,7 +278,7 @@ export function horizontalFormOptions() { return { mode: 'horizontal', horizontal: { - leftFixed: 'sm' + leftFixed: 'sm', }, } } @@ -2517,4 +2517,61 @@ export function time(field: string) { export function pictureFromIds(field: string) { return `\${ARRAYMAP(${field},id => '${commonInfo.baseAiUrl}/upload/download/' + id)}` +} + +const formInputFileStaticColumns = [ + { + name: 'filename', + label: '文件名', + }, + { + type: 'operation', + label: '操作', + width: 140, + buttons: [ + { + type: 'action', + label: '预览', + level: 'link', + icon: 'fas fa-eye' + }, + { + type: 'action', + label: '下载', + level: 'link', + icon: 'fa fa-download', + actionType: 'ajax', + // api: { + // ...apiGet('${base}/upload/download/${id}'), + // responseType: 'blob', + // } + } + ] + } +] + +export function formInputSingleFileStatic(field: string, label: string) { + return { + visibleOn: '${static}', + type: 'control', + label: label, + required: true, + body: { + type: 'table', + source: `\${${field}|asArray}`, + columns: formInputFileStaticColumns, + }, + } +} + +export function formInputMultiFileStatic(field: string, label: string) { + return { + visibleOn: '${static}', + type: 'input-table', + label: label, + name: field, + required: true, + resizable: false, + columns: formInputFileStaticColumns, + } } \ No newline at end of file