package jnpf.limsController; import com.alibaba.fastjson.JSONObject; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.Collections; import java.util.List; import java.util.Map; /** * 工作流表配置测试数据查询。 * *
该 Controller 仅用于验证前端配置页面,保持只读,不影响现有业务接口。
*/ @Slf4j @Tag(name = "工作流表配置测试", description = "按流程查询发起表单关联的数据表") @RestController @RequestMapping("/custom/workflow-table-config") public class WorkflowTableConfigTestController { private static final String DEFAULT_FLOW_ID = "864125763559883717"; private final JdbcTemplate jdbcTemplate; public WorkflowTableConfigTestController(JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } @Operation(summary = "查询流程表配置") @GetMapping public JSONObject list(@RequestParam(value = "flowId", required = false) String flowId) { String queryFlowId = StringUtils.hasText(flowId) ? flowId.trim() : DEFAULT_FLOW_ID; JSONObject result = new JSONObject(); result.put("code", 200); result.put("msg", "查询成功"); try { String sql = "SELECT n.f_form_id AS \"formId\", " + "v.f_full_name AS \"formName\", " + "item.value ->> 'typeId' AS \"tableType\", " + "item.value ->> 'table' AS \"tableName\", " + "item.value ->> 'tableName' AS \"tableDisplayName\" " + "FROM public.workflow_node n " + "JOIN public.base_visual_release v ON v.f_id = n.f_form_id " + "CROSS JOIN LATERAL jsonb_array_elements(" + "CASE WHEN v.f_tables_data IS NULL OR btrim(v.f_tables_data) = '' " + "THEN '[]'::jsonb ELSE v.f_tables_data::jsonb END) AS item(value) " + "WHERE n.f_flow_id = ? AND n.f_node_type = 'start' " + "AND item.value ->> 'typeId' = '1'"; List