Commit 7477abd8 by inrgihc

获取接口出参

parent febf1e56
docs/images/002.PNG

80.4 KB | W: | H:

docs/images/002.PNG

55.2 KB | W: | H:

docs/images/002.PNG
docs/images/002.PNG
docs/images/002.PNG
docs/images/002.PNG
  • 2-up
  • Swipe
  • Onion skin
docs/images/003.PNG

88.5 KB | W: | H:

docs/images/003.PNG

70.4 KB | W: | H:

docs/images/003.PNG
docs/images/003.PNG
docs/images/003.PNG
docs/images/003.PNG
  • 2-up
  • Swipe
  • Onion skin
...@@ -12,7 +12,7 @@ import lombok.NoArgsConstructor; ...@@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ApiModel("参数信息") @ApiModel("入参信息")
public class ItemParam implements Serializable { public class ItemParam implements Serializable {
@ApiModelProperty("参数名") @ApiModelProperty("参数名")
......
package com.gitee.sqlrest.common.dto;
import com.gitee.sqlrest.common.enums.ParamTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("出参信息")
public class OutParam implements Serializable {
@ApiModelProperty("参数名")
private String name;
@ApiModelProperty("参数类型")
private ParamTypeEnum type;
@ApiModelProperty("参数描述")
private String remark;
}
...@@ -2,6 +2,7 @@ package com.gitee.sqlrest.core.dto; ...@@ -2,6 +2,7 @@ package com.gitee.sqlrest.core.dto;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.gitee.sqlrest.common.dto.ItemParam; import com.gitee.sqlrest.common.dto.ItemParam;
import com.gitee.sqlrest.common.dto.OutParam;
import com.gitee.sqlrest.common.enums.NamingStrategyEnum; import com.gitee.sqlrest.common.enums.NamingStrategyEnum;
import com.gitee.sqlrest.persistence.entity.ApiContextEntity; import com.gitee.sqlrest.persistence.entity.ApiContextEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -30,6 +31,9 @@ public class ApiAssignmentDetailResponse extends ApiAssignmentBaseResponse { ...@@ -30,6 +31,9 @@ public class ApiAssignmentDetailResponse extends ApiAssignmentBaseResponse {
@ApiModelProperty("接口入参") @ApiModelProperty("接口入参")
private List<ItemParam> params; private List<ItemParam> params;
@ApiModelProperty("接口出参")
private List<OutParam> outputs;
@ApiModelProperty("HTTP请求的contentType") @ApiModelProperty("HTTP请求的contentType")
private String contentType; private String contentType;
......
package com.gitee.sqlrest.core.dto; package com.gitee.sqlrest.core.dto;
import com.gitee.sqlrest.common.dto.ItemParam; import com.gitee.sqlrest.common.dto.ItemParam;
import com.gitee.sqlrest.common.enums.DataTypeFormatEnum; import com.gitee.sqlrest.common.dto.OutParam;
import com.gitee.sqlrest.common.enums.ExecuteEngineEnum; import com.gitee.sqlrest.common.enums.ExecuteEngineEnum;
import com.gitee.sqlrest.common.enums.HttpMethodEnum; import com.gitee.sqlrest.common.enums.HttpMethodEnum;
import com.gitee.sqlrest.common.enums.NamingStrategyEnum; import com.gitee.sqlrest.common.enums.NamingStrategyEnum;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
import java.util.Map;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -56,6 +55,9 @@ public class ApiAssignmentSaveRequest { ...@@ -56,6 +55,9 @@ public class ApiAssignmentSaveRequest {
@ApiModelProperty("接口入参列表") @ApiModelProperty("接口入参列表")
private List<ItemParam> params; private List<ItemParam> params;
@ApiModelProperty("接口出参列表")
private List<OutParam> outputs;
@ApiModelProperty("接口出参数据类型转换格式") @ApiModelProperty("接口出参数据类型转换格式")
private List<DataTypeFormatMapValue> formatMap; private List<DataTypeFormatMapValue> formatMap;
......
...@@ -37,6 +37,7 @@ import com.gitee.sqlrest.persistence.util.PageUtils; ...@@ -37,6 +37,7 @@ import com.gitee.sqlrest.persistence.util.PageUtils;
import com.gitee.sqlrest.template.Configuration; import com.gitee.sqlrest.template.Configuration;
import com.gitee.sqlrest.template.SqlTemplate; import com.gitee.sqlrest.template.SqlTemplate;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -160,7 +161,9 @@ public class ApiAssignmentService { ...@@ -160,7 +161,9 @@ public class ApiAssignmentService {
List<Object> results = ApiExecutorEngineFactory List<Object> results = ApiExecutorEngineFactory
.getExecutor(request.getEngine(), dataSource, dataSourceEntity.getType()) .getExecutor(request.getEngine(), dataSource, dataSourceEntity.getType())
.execute(scripts, params, request.getNamingStrategy()); .execute(scripts, params, request.getNamingStrategy());
entity = ResultEntity.success(results.size() > 1 ? results : results.get(0)); Object answer = results.size() > 1 ? results : results.get(0);
Map<String, ParamTypeEnum> types = JacksonUtils.parseFieldTypes(results);
entity = ResultEntity.success(ImmutableMap.of("answer", answer, "types", types));
} catch (Exception e) { } catch (Exception e) {
entity = ResultEntity.failed(ResponseErrorCode.ERROR_INTERNAL_ERROR, ExceptionUtil.getMessage(e)); entity = ResultEntity.failed(ResponseErrorCode.ERROR_INTERNAL_ERROR, ExceptionUtil.getMessage(e));
} }
...@@ -207,6 +210,7 @@ public class ApiAssignmentService { ...@@ -207,6 +210,7 @@ public class ApiAssignmentService {
assignmentEntity.setPath(request.getPath()); assignmentEntity.setPath(request.getPath());
assignmentEntity.setContentType(request.getContentType()); assignmentEntity.setContentType(request.getContentType());
assignmentEntity.setParams(request.getParams()); assignmentEntity.setParams(request.getParams());
assignmentEntity.setOutputs(request.getOutputs());
assignmentEntity.setOpen(Optional.ofNullable(request.getOpen()).orElse(false)); assignmentEntity.setOpen(Optional.ofNullable(request.getOpen()).orElse(false));
assignmentEntity.setEngine(request.getEngine()); assignmentEntity.setEngine(request.getEngine());
assignmentEntity.setStatus(false); assignmentEntity.setStatus(false);
...@@ -267,6 +271,7 @@ public class ApiAssignmentService { ...@@ -267,6 +271,7 @@ public class ApiAssignmentService {
//assignmentEntity.setPath(request.getPath()); //assignmentEntity.setPath(request.getPath());
assignmentEntity.setContentType(request.getContentType()); assignmentEntity.setContentType(request.getContentType());
assignmentEntity.setParams(request.getParams()); assignmentEntity.setParams(request.getParams());
assignmentEntity.setOutputs(request.getOutputs());
assignmentEntity.setOpen(Optional.ofNullable(request.getOpen()).orElse(false)); assignmentEntity.setOpen(Optional.ofNullable(request.getOpen()).orElse(false));
assignmentEntity.setStatus(false); assignmentEntity.setStatus(false);
assignmentEntity.setEngine(request.getEngine()); assignmentEntity.setEngine(request.getEngine());
...@@ -304,31 +309,6 @@ public class ApiAssignmentService { ...@@ -304,31 +309,6 @@ public class ApiAssignmentService {
return response; return response;
} }
public void testAssignment(Long id, HttpServletRequest request, HttpServletResponse response) {
ApiAssignmentEntity assignmentEntity = apiAssignmentDao.getById(id, true);
if (null == assignmentEntity) {
throw new CommonException(ResponseErrorCode.ERROR_RESOURCE_NOT_EXISTS, "id=" + id);
}
String json;
ResultEntity result = apiExecuteService.execute(assignmentEntity, request);
if (0 != result.getCode()) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
json = JacksonUtils.toJsonStr(ResultEntity.failed(ResponseErrorCode.ERROR_INTERNAL_ERROR));
} else {
response.setStatus(HttpServletResponse.SC_OK);
json = JacksonUtils.toJsonStr(result, assignmentEntity.getResponseFormat());
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding(Charsets.UTF_8.name());
try {
response.getWriter().append(json);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void deleteAssignment(Long id) { public void deleteAssignment(Long id) {
ApiAssignmentEntity assignmentEntity = apiAssignmentDao.getById(id, false); ApiAssignmentEntity assignmentEntity = apiAssignmentDao.getById(id, false);
if (null != assignmentEntity) { if (null != assignmentEntity) {
......
...@@ -6,9 +6,16 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -6,9 +6,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StdSerializer; import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.gitee.sqlrest.common.enums.DataTypeFormatEnum; import com.gitee.sqlrest.common.enums.DataTypeFormatEnum;
import com.gitee.sqlrest.common.enums.ParamTypeEnum;
import com.gitee.sqlrest.core.serdes.DateTimeSerDesFactory; import com.gitee.sqlrest.core.serdes.DateTimeSerDesFactory;
import java.math.BigInteger;
import java.sql.Time;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils;
public final class JacksonUtils { public final class JacksonUtils {
...@@ -40,4 +47,64 @@ public final class JacksonUtils { ...@@ -40,4 +47,64 @@ public final class JacksonUtils {
return module; return module;
} }
public static Map<String, ParamTypeEnum> parseFieldTypes(Object obj) {
Map<String, ParamTypeEnum> results = new LinkedHashMap<>();
if (null == obj) {
return results;
}
if (obj instanceof Map) {
parseFieldTypes("", (Map) obj, results);
} else if (obj instanceof Collection) {
Collection collection = (Collection) obj;
Object item = collection.stream().findFirst().get();
if (item instanceof Map) {
parseFieldTypes("", (Map) item, results);
} else if (item instanceof Collection) {
Collection subCollection = (Collection) item;
Object subItem = subCollection.stream().findFirst().get();
if (subItem instanceof Map) {
parseFieldTypes("", (Map) subItem, results);
} else if (subItem instanceof Collection) {
Collection thSubCollection = (Collection) subItem;
Object thSubItem = thSubCollection.stream().findFirst().get();
if (thSubItem instanceof Map) {
parseFieldTypes("", (Map) thSubItem, results);
}
}
}
}
return results;
}
private static void parseFieldTypes(String prefix, Map<String, Object> map, Map<String, ParamTypeEnum> results) {
for (String name : map.keySet()) {
Object value = map.get(name);
results.put(name, parseValueType(value));
String subPrefix = StringUtils.isBlank(prefix) ? name : prefix + "." + name;
if (value instanceof Map) {
parseFieldTypes(subPrefix, (Map) value, results);
} else if (value instanceof Collection) {
Collection collection = (Collection) value;
Object item = collection.stream().findFirst().get();
parseFieldTypes(subPrefix, (Map) item, results);
}
}
}
private static ParamTypeEnum parseValueType(Object value) {
if (value instanceof Boolean || value instanceof Byte) {
return ParamTypeEnum.BOOLEAN;
} else if (value instanceof Integer || value instanceof Long || value instanceof BigInteger) {
return ParamTypeEnum.LONG;
} else if (value instanceof Number) {
return ParamTypeEnum.DOUBLE;
} else if (value instanceof Time) {
return ParamTypeEnum.TIME;
} else if (value instanceof Date) {
return ParamTypeEnum.DATE;
} else {
return ParamTypeEnum.STRING;
}
}
} }
...@@ -77,14 +77,16 @@ ...@@ -77,14 +77,16 @@
</el-row> </el-row>
<el-row v-if="createParam.engine==='SQL'"> <el-row v-if="createParam.engine==='SQL'">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="语句" <el-form-item label-width="65px">
label-width="65px"> <span slot="label"
<el-tooltip placement="top"> style="display:inline-block;">
<i class="el-icon-question"></i> 语句
<div slot="content"> <el-tooltip effect="dark"
每个SQL窗口中至多写一条SQL语句,支持Mybatis的动态SQL语法 content="每个SQL窗口中至多写一条SQL语句,支持Mybatis的动态SQL语法"
</div> placement="bottom">
</el-tooltip> <i class='el-icon-question' />
</el-tooltip>
</span>
<multi-sql-editer ref="sqlEditors" <multi-sql-editer ref="sqlEditors"
:tableHints="tableHints" :tableHints="tableHints"
:tabSqls="createParam.sqls" :tabSqls="createParam.sqls"
...@@ -94,148 +96,203 @@ ...@@ -94,148 +96,203 @@
</el-row> </el-row>
<el-row v-if="createParam.engine==='SCRIPT'"> <el-row v-if="createParam.engine==='SCRIPT'">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="脚本" <el-form-item label-width="65px">
label-width="65px"> <span slot="label"
<el-tooltip placement="top"> style="display:inline-block;">
<i class="el-icon-question"></i> 脚本
<div slot="content"> <el-tooltip effect="dark"
可以编写符合groovy语法格式的脚本内容 content="可以编写符合groovy语法格式的脚本内容"
</div> placement="bottom">
</el-tooltip> <i class='el-icon-question' />
</el-tooltip>
</span>
<script-editer ref="scriptEditer" <script-editer ref="scriptEditer"
:content="createParam.script"></script-editer> :content="createParam.script"></script-editer>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-col :span="3" <el-tabs type="border-card" tab-position="left">
v-if="createParam.engine==='SQL'"> <el-tab-pane label="入参">
<el-button type="primary" <el-row>
size="mini" <el-col :span="3"
icon="el-icon-arrow-down" v-if="createParam.engine==='SQL'">
v-if="!isOnlyShowDetail" <el-button type="primary"
@click="handleParseInputParams"> size="mini"
入参解析 icon="el-icon-arrow-down"
</el-button> v-if="!isOnlyShowDetail"
</el-col> @click="handleParseInputParams">
<el-col :span="3"> 入参解析
<el-button type="primary" </el-button>
size="mini" </el-col>
icon="el-icon-arrow-down" <el-col :span="3">
v-if="!isOnlyShowDetail" <el-button type="primary"
@click="handleAddInputParams"> size="mini"
添加入参 icon="el-icon-arrow-down"
</el-button> v-if="!isOnlyShowDetail"
</el-col> @click="handleAddInputParams">
<el-col :span="3"> 添加入参
</el-button>
</el-col>
<el-col :span="3">
<el-button type="primary"
size="mini"
icon="el-icon-arrow-down"
v-if="!isOnlyShowDetail"
@click="handleAddPagableParams">
分页参数
</el-button>
</el-col>
<el-col :span="15">
</el-col>
</el-row>
<el-table :data="inputParams"
:header-cell-style="{background:'#eef1f6',color:'#606266'}"
size="mini"
border>
<template slot="empty">
<span>请输入sql后点击"入参解析"按钮后解析出这里的入参</span>
</template>
<el-table-column label="参数名"
min-width="25%">
<template slot-scope="scope">
<el-input v-model="scope.row.name"
type="string"
:disabled="isOnlyShowDetail"> </el-input>
</template>
</el-table-column>
<el-table-column label="参数位置"
min-width="25%">
<template slot-scope="scope">
<el-select v-model="scope.row.location"
:disabled="isOnlyShowDetail">
<el-option label='header'
value='REQUEST_HEADER'></el-option>
<el-option label='body'
value='REQUEST_BODY'></el-option>
<el-option label='query'
value='REQUEST_FORM'></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="参数类型"
min-width="25%">
<template slot-scope="scope">
<el-select v-model="scope.row.type"
:disabled="isOnlyShowDetail">
<el-option v-for="(item,index) in paramTypeList"
:key="index"
:label="item.name"
:value="item.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="为数组"
min-width="25%">
<template slot-scope="scope">
<el-select v-model="scope.row.isArray"
:disabled="isOnlyShowDetail">
<el-option label='是'
:value=true></el-option>
<el-option label='否'
:value=false></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="必填"
min-width="25%">
<template slot-scope="scope">
<el-select v-model="scope.row.required"
:disabled="isOnlyShowDetail">
<el-option label='是'
:value=true></el-option>
<el-option label='否'
:value=false></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="默认值"
min-width="25%">
<template slot-scope="scope">
<el-input v-model="scope.row.defaultValue"
type="string"
:disabled="isOnlyShowDetail"></el-input>
</template>
</el-table-column>
<el-table-column label="描述"
min-width="25%">
<template slot-scope="scope">
<el-input v-model="scope.row.remark"
type="string"
:disabled="isOnlyShowDetail"></el-input>
</template>
</el-table-column>
<el-table-column label="操作"
v-if="!isOnlyShowDetail"
min-width="25%">
<template slot-scope="scope">
<el-button size="mini"
type="danger"
@click="deleteInputParamsItem(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="出参">
<el-button type="primary" <el-button type="primary"
size="mini" size="mini"
icon="el-icon-arrow-down" icon="el-icon-arrow-down"
v-if="!isOnlyShowDetail" v-if="!isOnlyShowDetail"
@click="handleAddPagableParams"> @click="handleAddOutputParams">
分页参数 添加出参
</el-button> </el-button>
</el-col> <el-table :data="outputParams"
<el-col :span="15"> :header-cell-style="{background:'#eef1f6',color:'#606266'}"
</el-col> size="mini"
</el-row> border>
<el-table :data="inputParams" <template slot="empty">
:header-cell-style="{background:'#eef1f6',color:'#606266'}" <span>请输入sql后成功执行"调试"按钮后解析出这里的出参</span>
size="mini" </template>
border> <el-table-column label="参数名"
<template slot="empty"> min-width="25%">
<span>请输入sql后点击"入参解析"按钮后解析出这里的入参</span> <template slot-scope="scope">
</template> <el-input v-model="scope.row.name"
<el-table-column label="参数名" type="string"
min-width="25%"> :disabled="isOnlyShowDetail"> </el-input>
<template slot-scope="scope"> </template>
<el-input v-model="scope.row.name" </el-table-column>
type="string" <el-table-column label="参数类型"
:disabled="isOnlyShowDetail"> </el-input> min-width="25%">
</template> <template slot-scope="scope">
</el-table-column> <el-select v-model="scope.row.type"
<el-table-column label="参数位置" :disabled="isOnlyShowDetail">
min-width="25%"> <el-option v-for="(item,index) in paramTypeList"
<template slot-scope="scope"> :key="index"
<el-select v-model="scope.row.location" :label="item.name"
:disabled="isOnlyShowDetail"> :value="item.value"></el-option>
<el-option label='header' </el-select>
value='REQUEST_HEADER'></el-option> </template>
<el-option label='body' </el-table-column>
value='REQUEST_BODY'></el-option> <el-table-column label="描述"
<el-option label='query' min-width="25%">
value='REQUEST_FORM'></el-option> <template slot-scope="scope">
</el-select> <el-input v-model="scope.row.remark"
</template> type="string"
</el-table-column> :disabled="isOnlyShowDetail"></el-input>
<el-table-column label="参数类型" </template>
min-width="25%"> </el-table-column>
<template slot-scope="scope"> <el-table-column label="操作"
<el-select v-model="scope.row.type" v-if="!isOnlyShowDetail"
:disabled="isOnlyShowDetail"> min-width="25%">
<el-option label='整型' <template slot-scope="scope">
value='LONG'></el-option> <el-button size="mini"
<el-option label='浮点型' type="danger"
value='DOUBLE'></el-option> @click="deleteOutputParamsItem(scope.$index)">删除</el-button>
<el-option label='字符串' </template>
value='STRING'></el-option> </el-table-column>
<el-option label='日期' </el-table>
value='DATE'></el-option> </el-tab-pane>
<el-option label='时间' </el-tabs>
value='TIME'></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="为数组"
min-width="25%">
<template slot-scope="scope">
<el-select v-model="scope.row.isArray"
:disabled="isOnlyShowDetail">
<el-option label='是'
:value=true></el-option>
<el-option label='否'
:value=false></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="必填"
min-width="25%">
<template slot-scope="scope">
<el-select v-model="scope.row.required"
:disabled="isOnlyShowDetail">
<el-option label='是'
:value=true></el-option>
<el-option label='否'
:value=false></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="默认值"
min-width="25%">
<template slot-scope="scope">
<el-input v-model="scope.row.defaultValue"
type="string"
:disabled="isOnlyShowDetail"></el-input>
</template>
</el-table-column>
<el-table-column label="描述"
min-width="25%">
<template slot-scope="scope">
<el-input v-model="scope.row.remark"
type="string"
:disabled="isOnlyShowDetail"></el-input>
</template>
</el-table-column>
<el-table-column label="操作"
v-if="!isOnlyShowDetail"
min-width="25%">
<template slot-scope="scope">
<el-button size="mini"
type="danger"
@click="deleteInputParamsItem(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="接口配置>>" <el-tab-pane label="接口配置>>"
name="detail"> name="detail">
...@@ -352,10 +409,18 @@ ...@@ -352,10 +409,18 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<div> <div>
<el-form-item label="命名策略" <el-form-item label-width="120px"
label-width="80px" prop="namingStrategy"
prop="description" style="width:60%">
style="width:100%"> <span slot="label"
style="display:inline-block;">
命名策略
<el-tooltip effect="dark"
content="修改命名策略后,需再次执行“调试”操作以纠正出参列表"
placement="top">
<i class='el-icon-question' />
</el-tooltip>
</span>
<el-select v-model="createParam.namingStrategy" <el-select v-model="createParam.namingStrategy"
placeholder="请选择" placeholder="请选择"
:disabled="isOnlyShowDetail"> :disabled="isOnlyShowDetail">
...@@ -371,9 +436,9 @@ ...@@ -371,9 +436,9 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="数据格式" <el-form-item label="数据格式"
label-width="80px" label-width="120px"
prop="formatMap" prop="formatMap"
style="width:100%"> style="width:60%">
<div v-for="item in createParam.formatMap" <div v-for="item in createParam.formatMap"
:key="item.key" :key="item.key"
v-bind="item"> v-bind="item">
...@@ -582,6 +647,13 @@ export default { ...@@ -582,6 +647,13 @@ export default {
groupList: [], groupList: [],
moduleList: [], moduleList: [],
connectionList: [], connectionList: [],
paramTypeList: [
{ name: "整型", value: "LONG" },
{ name: "浮点型", value: "DOUBLE" },
{ name: "字符串", value: "STRING" },
{ name: "日期", value: "DATE" },
{ name: "时间", value: "TIME" }
],
contentTypes: ['application/x-www-form-urlencoded', 'application/json'], contentTypes: ['application/x-www-form-urlencoded', 'application/json'],
showTree: true, showTree: true,
createParam: { createParam: {
...@@ -620,6 +692,7 @@ export default { ...@@ -620,6 +692,7 @@ export default {
inputParams: [], inputParams: [],
debugParams: [], debugParams: [],
debugResponse: "", debugResponse: "",
outputParams: [],
responseNamingStrategy: [], responseNamingStrategy: [],
responseTypeFormat: [], responseTypeFormat: [],
rules: { rules: {
...@@ -724,6 +797,10 @@ export default { ...@@ -724,6 +797,10 @@ export default {
if (detail.params) { if (detail.params) {
this.inputParams = detail.params this.inputParams = detail.params
} }
this.outputParams = []
if (detail.outputs) {
this.outputParams = detail.outputs;
}
if (detail.sqlList && detail.sqlList.length > 0) { if (detail.sqlList && detail.sqlList.length > 0) {
if (this.createParam.engine === 'SQL') { if (this.createParam.engine === 'SQL') {
this.createParam.sqls = detail.sqlList.map(obj => obj['sqlText']) this.createParam.sqls = detail.sqlList.map(obj => obj['sqlText'])
...@@ -1130,6 +1207,9 @@ export default { ...@@ -1130,6 +1207,9 @@ export default {
deleteInputParamsItem: function (index) { deleteInputParamsItem: function (index) {
this.inputParams.splice(index, 1); this.inputParams.splice(index, 1);
}, },
deleteInputParamsItem: function (index) {
this.outputParams.slice(index, 1);
},
checkSqlsOrScriptEmpty: function (sqls) { checkSqlsOrScriptEmpty: function (sqls) {
if (sqls === null || sqls === undefined || !Array.isArray(sqls) || sqls.length === 0 || sqls.includes('')) { if (sqls === null || sqls === undefined || !Array.isArray(sqls) || sqls.length === 0 || sqls.includes('')) {
return true return true
...@@ -1192,7 +1272,8 @@ export default { ...@@ -1192,7 +1272,8 @@ export default {
flowCount: this.createParam.flowCount, flowCount: this.createParam.flowCount,
engine: this.createParam.engine, engine: this.createParam.engine,
contextList: sqls, contextList: sqls,
params: this.inputParams params: this.inputParams,
outputs: this.outputParams
}) })
}).then( }).then(
res => { res => {
...@@ -1232,7 +1313,8 @@ export default { ...@@ -1232,7 +1313,8 @@ export default {
flowCount: this.createParam.flowCount, flowCount: this.createParam.flowCount,
engine: this.createParam.engine, engine: this.createParam.engine,
contextList: sqls, contextList: sqls,
params: this.inputParams params: this.inputParams,
outputs: this.outputParams
}) })
}).then( }).then(
res => { res => {
...@@ -1320,7 +1402,18 @@ export default { ...@@ -1320,7 +1402,18 @@ export default {
}).then( }).then(
res => { res => {
if (0 === res.data.code) { if (0 === res.data.code) {
this.debugResponse = JSON.stringify(res.data.data, null, 2); this.debugResponse = JSON.stringify(res.data.data.answer, null, 2);
this.outputParams = [];
let map = res.data.data.types;
for (let key in map) {
this.outputParams.push(
{
name: key,
type: map[key],
remark: null
}
)
}
} else { } else {
if (res.data.message) { if (res.data.message) {
alert("调试操作失败:" + res.data.message); alert("调试操作失败:" + res.data.message);
...@@ -1328,6 +1421,18 @@ export default { ...@@ -1328,6 +1421,18 @@ export default {
} }
} }
); );
},
handleAddOutputParams: function () {
this.outputParams.push(
{
name: '',
type: 'STRING',
remark: null
},
)
},
deleteOutputParamsItem: function (index) {
this.outputParams.splice(index, 1);
} }
}, },
created () { created () {
...@@ -1393,4 +1498,4 @@ export default { ...@@ -1393,4 +1498,4 @@ export default {
overflow: hidden; overflow: hidden;
margin: 0; margin: 0;
} }
</style> </style>
\ No newline at end of file
...@@ -108,12 +108,6 @@ public class ApiAssignmentController { ...@@ -108,12 +108,6 @@ public class ApiAssignmentController {
return ResultEntity.success(apiAssignmentService.detailAssignment(id)); return ResultEntity.success(apiAssignmentService.detailAssignment(id));
} }
@ApiOperation(value = "测试API执行")
@PostMapping(value = "/test/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public void test(@PathVariable("id") Long id, HttpServletRequest request, HttpServletResponse response) {
apiAssignmentService.testAssignment(id, request, response);
}
@ApiOperation(value = "删除API配置") @ApiOperation(value = "删除API配置")
@DeleteMapping(value = "/delete/{id}", produces = MediaType.APPLICATION_JSON_VALUE) @DeleteMapping(value = "/delete/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ResultEntity delete(@PathVariable("id") Long id) { public ResultEntity delete(@PathVariable("id") Long id) {
......
ALTER TABLE `SQLREST_API_ASSIGNMENT` ADD COLUMN `outputs` text NULL COMMENT '出参JSON列表' AFTER `params`;
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>SQLREST工具</title><link href=/static/css/app.fe7f344bb1980454cbe37f37645f94e6.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.373873d38594fb61f409.js></script><script type=text/javascript src=/static/js/vendor.b8089f9fd73f8896df25.js></script><script type=text/javascript src=/static/js/app.f528b7ee91d3c4683835.js></script></body></html> <!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>SQLREST工具</title><link href=/static/css/app.5f31ee68e0b980f9181f389dfcacaf32.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.4a0ab5fbb9b32cb65fc3.js></script><script type=text/javascript src=/static/js/vendor.b8089f9fd73f8896df25.js></script><script type=text/javascript src=/static/js/app.f528b7ee91d3c4683835.js></script></body></html>
\ No newline at end of file \ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,o,a){for(var d,f,i,u=0,s=[];u<r.length;u++)f=r[u],t[f]&&s.push(t[f][0]),t[f]=0;for(d in o)Object.prototype.hasOwnProperty.call(o,d)&&(e[d]=o[d]);for(n&&n(r,o,a);s.length;)s.shift()();if(a)for(u=0;u<a.length;u++)i=c(c.s=a[u]);return i};var r={},t={22:0};function c(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,c),t.l=!0,t.exports}c.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,c){n=t[e]=[r,c]});n[2]=r;var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.timeout=12e4,c.nc&&a.setAttribute("nonce",c.nc),a.src=c.p+"static/js/"+e+"."+{0:"c6b968f702956d23cafc",1:"b17200cccd46e216dcb3",2:"140338f6a5528feea1a3",3:"ef31773dbc0e4bd73d87",4:"f8494b8dd039413f79c8",5:"6a80c59d0b7ae08a93a1",6:"8f85de06573e2a5f9562",7:"7ea6008d16a44e79a428",8:"7483ee6d3a25506eb489",9:"1f165c58c9933d0da8a7",10:"cdd03027e5c73f31170c",11:"cdde61370dec5108c322",12:"57d1188c7336fe654844",13:"cdc0bd22251263ac4669",14:"42cdbd66a7803b30c641",15:"3b3f0c03ff4fed9903cc",16:"4de955682c1f7710c7ea",17:"819547b2361d544d3b8b",18:"5e7f065a8d031847e833",19:"3936346cb7e30aa279e2"}[e]+".js";var d=setTimeout(f,12e4);function f(){a.onerror=a.onload=null,clearTimeout(d);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return a.onerror=a.onload=f,o.appendChild(a),r},c.m=e,c.c=r,c.d=function(e,n,r){c.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},c.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(n,"a",n),n},c.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},c.p="/",c.oe=function(e){throw console.error(e),e}}([]); !function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,o,a){for(var d,f,i,u=0,s=[];u<r.length;u++)f=r[u],t[f]&&s.push(t[f][0]),t[f]=0;for(d in o)Object.prototype.hasOwnProperty.call(o,d)&&(e[d]=o[d]);for(n&&n(r,o,a);s.length;)s.shift()();if(a)for(u=0;u<a.length;u++)i=c(c.s=a[u]);return i};var r={},t={22:0};function c(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,c),t.l=!0,t.exports}c.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,c){n=t[e]=[r,c]});n[2]=r;var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.timeout=12e4,c.nc&&a.setAttribute("nonce",c.nc),a.src=c.p+"static/js/"+e+"."+{0:"f4513daf7e2679187d35",1:"b17200cccd46e216dcb3",2:"140338f6a5528feea1a3",3:"ef31773dbc0e4bd73d87",4:"f8494b8dd039413f79c8",5:"6a80c59d0b7ae08a93a1",6:"8f85de06573e2a5f9562",7:"7ea6008d16a44e79a428",8:"7483ee6d3a25506eb489",9:"1f165c58c9933d0da8a7",10:"cdd03027e5c73f31170c",11:"cdde61370dec5108c322",12:"57d1188c7336fe654844",13:"cdc0bd22251263ac4669",14:"42cdbd66a7803b30c641",15:"3b3f0c03ff4fed9903cc",16:"4de955682c1f7710c7ea",17:"819547b2361d544d3b8b",18:"5e7f065a8d031847e833",19:"3936346cb7e30aa279e2"}[e]+".js";var d=setTimeout(f,12e4);function f(){a.onerror=a.onload=null,clearTimeout(d);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return a.onerror=a.onload=f,o.appendChild(a),r},c.m=e,c.c=r,c.d=function(e,n,r){c.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},c.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(n,"a",n),n},c.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},c.p="/",c.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=manifest.373873d38594fb61f409.js.map //# sourceMappingURL=manifest.4a0ab5fbb9b32cb65fc3.js.map
\ No newline at end of file \ No newline at end of file
{"version":3,"sources":["webpack:///webpack/bootstrap ffa91d1a5284254f1ef2"],"names":["parentJsonpFunction","window","chunkIds","moreModules","executeModules","moduleId","chunkId","result","i","resolves","length","installedChunks","push","Object","prototype","hasOwnProperty","call","modules","shift","__webpack_require__","s","installedModules","22","exports","module","l","e","installedChunkData","Promise","resolve","promise","reject","head","document","getElementsByTagName","script","createElement","type","charset","async","timeout","nc","setAttribute","src","p","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","setTimeout","onScriptComplete","onerror","onload","clearTimeout","chunk","Error","undefined","appendChild","m","c","d","name","getter","o","defineProperty","configurable","enumerable","get","n","__esModule","object","property","oe","err","console","error"],"mappings":"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","file":"static/js/manifest.373873d38594fb61f409.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [], result;\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n \t\tif(executeModules) {\n \t\t\tfor(i=0; i < executeModules.length; i++) {\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = executeModules[i]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// objects to store loaded and loading chunks\n \tvar installedChunks = {\n \t\t22: 0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tvar installedChunkData = installedChunks[chunkId];\n \t\tif(installedChunkData === 0) {\n \t\t\treturn new Promise(function(resolve) { resolve(); });\n \t\t}\n\n \t\t// a Promise means \"currently loading\".\n \t\tif(installedChunkData) {\n \t\t\treturn installedChunkData[2];\n \t\t}\n\n \t\t// setup Promise in chunk cache\n \t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\tinstalledChunkData = installedChunks[chunkId] = [resolve, reject];\n \t\t});\n \t\tinstalledChunkData[2] = promise;\n\n \t\t// start chunk loading\n \t\tvar head = document.getElementsByTagName('head')[0];\n \t\tvar script = document.createElement('script');\n \t\tscript.type = \"text/javascript\";\n \t\tscript.charset = 'utf-8';\n \t\tscript.async = true;\n \t\tscript.timeout = 120000;\n\n \t\tif (__webpack_require__.nc) {\n \t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t}\n \t\tscript.src = __webpack_require__.p + \"static/js/\" + chunkId + \".\" + {\"0\":\"c6b968f702956d23cafc\",\"1\":\"b17200cccd46e216dcb3\",\"2\":\"140338f6a5528feea1a3\",\"3\":\"ef31773dbc0e4bd73d87\",\"4\":\"f8494b8dd039413f79c8\",\"5\":\"6a80c59d0b7ae08a93a1\",\"6\":\"8f85de06573e2a5f9562\",\"7\":\"7ea6008d16a44e79a428\",\"8\":\"7483ee6d3a25506eb489\",\"9\":\"1f165c58c9933d0da8a7\",\"10\":\"cdd03027e5c73f31170c\",\"11\":\"cdde61370dec5108c322\",\"12\":\"57d1188c7336fe654844\",\"13\":\"cdc0bd22251263ac4669\",\"14\":\"42cdbd66a7803b30c641\",\"15\":\"3b3f0c03ff4fed9903cc\",\"16\":\"4de955682c1f7710c7ea\",\"17\":\"819547b2361d544d3b8b\",\"18\":\"5e7f065a8d031847e833\",\"19\":\"3936346cb7e30aa279e2\"}[chunkId] + \".js\";\n \t\tvar timeout = setTimeout(onScriptComplete, 120000);\n \t\tscript.onerror = script.onload = onScriptComplete;\n \t\tfunction onScriptComplete() {\n \t\t\t// avoid mem leaks in IE.\n \t\t\tscript.onerror = script.onload = null;\n \t\t\tclearTimeout(timeout);\n \t\t\tvar chunk = installedChunks[chunkId];\n \t\t\tif(chunk !== 0) {\n \t\t\t\tif(chunk) {\n \t\t\t\t\tchunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));\n \t\t\t\t}\n \t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t}\n \t\t};\n \t\thead.appendChild(script);\n\n \t\treturn promise;\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap ffa91d1a5284254f1ef2"],"sourceRoot":""} {"version":3,"sources":["webpack:///webpack/bootstrap d7d37cee2719969a11f2"],"names":["parentJsonpFunction","window","chunkIds","moreModules","executeModules","moduleId","chunkId","result","i","resolves","length","installedChunks","push","Object","prototype","hasOwnProperty","call","modules","shift","__webpack_require__","s","installedModules","22","exports","module","l","e","installedChunkData","Promise","resolve","promise","reject","head","document","getElementsByTagName","script","createElement","type","charset","async","timeout","nc","setAttribute","src","p","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","setTimeout","onScriptComplete","onerror","onload","clearTimeout","chunk","Error","undefined","appendChild","m","c","d","name","getter","o","defineProperty","configurable","enumerable","get","n","__esModule","object","property","oe","err","console","error"],"mappings":"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","file":"static/js/manifest.4a0ab5fbb9b32cb65fc3.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, resolves = [], result;\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId]) {\n \t\t\t\tresolves.push(installedChunks[chunkId][0]);\n \t\t\t}\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tif(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {\n \t\t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t\t}\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);\n \t\twhile(resolves.length) {\n \t\t\tresolves.shift()();\n \t\t}\n \t\tif(executeModules) {\n \t\t\tfor(i=0; i < executeModules.length; i++) {\n \t\t\t\tresult = __webpack_require__(__webpack_require__.s = executeModules[i]);\n \t\t\t}\n \t\t}\n \t\treturn result;\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// objects to store loaded and loading chunks\n \tvar installedChunks = {\n \t\t22: 0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId) {\n \t\tvar installedChunkData = installedChunks[chunkId];\n \t\tif(installedChunkData === 0) {\n \t\t\treturn new Promise(function(resolve) { resolve(); });\n \t\t}\n\n \t\t// a Promise means \"currently loading\".\n \t\tif(installedChunkData) {\n \t\t\treturn installedChunkData[2];\n \t\t}\n\n \t\t// setup Promise in chunk cache\n \t\tvar promise = new Promise(function(resolve, reject) {\n \t\t\tinstalledChunkData = installedChunks[chunkId] = [resolve, reject];\n \t\t});\n \t\tinstalledChunkData[2] = promise;\n\n \t\t// start chunk loading\n \t\tvar head = document.getElementsByTagName('head')[0];\n \t\tvar script = document.createElement('script');\n \t\tscript.type = \"text/javascript\";\n \t\tscript.charset = 'utf-8';\n \t\tscript.async = true;\n \t\tscript.timeout = 120000;\n\n \t\tif (__webpack_require__.nc) {\n \t\t\tscript.setAttribute(\"nonce\", __webpack_require__.nc);\n \t\t}\n \t\tscript.src = __webpack_require__.p + \"static/js/\" + chunkId + \".\" + {\"0\":\"f4513daf7e2679187d35\",\"1\":\"b17200cccd46e216dcb3\",\"2\":\"140338f6a5528feea1a3\",\"3\":\"ef31773dbc0e4bd73d87\",\"4\":\"f8494b8dd039413f79c8\",\"5\":\"6a80c59d0b7ae08a93a1\",\"6\":\"8f85de06573e2a5f9562\",\"7\":\"7ea6008d16a44e79a428\",\"8\":\"7483ee6d3a25506eb489\",\"9\":\"1f165c58c9933d0da8a7\",\"10\":\"cdd03027e5c73f31170c\",\"11\":\"cdde61370dec5108c322\",\"12\":\"57d1188c7336fe654844\",\"13\":\"cdc0bd22251263ac4669\",\"14\":\"42cdbd66a7803b30c641\",\"15\":\"3b3f0c03ff4fed9903cc\",\"16\":\"4de955682c1f7710c7ea\",\"17\":\"819547b2361d544d3b8b\",\"18\":\"5e7f065a8d031847e833\",\"19\":\"3936346cb7e30aa279e2\"}[chunkId] + \".js\";\n \t\tvar timeout = setTimeout(onScriptComplete, 120000);\n \t\tscript.onerror = script.onload = onScriptComplete;\n \t\tfunction onScriptComplete() {\n \t\t\t// avoid mem leaks in IE.\n \t\t\tscript.onerror = script.onload = null;\n \t\t\tclearTimeout(timeout);\n \t\t\tvar chunk = installedChunks[chunkId];\n \t\t\tif(chunk !== 0) {\n \t\t\t\tif(chunk) {\n \t\t\t\t\tchunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));\n \t\t\t\t}\n \t\t\t\tinstalledChunks[chunkId] = undefined;\n \t\t\t}\n \t\t};\n \t\thead.appendChild(script);\n\n \t\treturn promise;\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \t// on error function for async loading\n \t__webpack_require__.oe = function(err) { console.error(err); throw err; };\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap d7d37cee2719969a11f2"],"sourceRoot":""}
\ No newline at end of file \ No newline at end of file
...@@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.annotation.TableField; ...@@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sqlrest.common.dto.ItemParam; import com.gitee.sqlrest.common.dto.ItemParam;
import com.gitee.sqlrest.common.dto.OutParam;
import com.gitee.sqlrest.common.enums.DataTypeFormatEnum; import com.gitee.sqlrest.common.enums.DataTypeFormatEnum;
import com.gitee.sqlrest.common.enums.ExecuteEngineEnum; import com.gitee.sqlrest.common.enums.ExecuteEngineEnum;
import com.gitee.sqlrest.common.enums.HttpMethodEnum; import com.gitee.sqlrest.common.enums.HttpMethodEnum;
import com.gitee.sqlrest.common.enums.NamingStrategyEnum; import com.gitee.sqlrest.common.enums.NamingStrategyEnum;
import com.gitee.sqlrest.persistence.handler.FormatMapHandler; import com.gitee.sqlrest.persistence.handler.FormatMapHandler;
import com.gitee.sqlrest.persistence.handler.ListOutputHandler;
import com.gitee.sqlrest.persistence.handler.ListParamHandler; import com.gitee.sqlrest.persistence.handler.ListParamHandler;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
...@@ -55,6 +57,9 @@ public class ApiAssignmentEntity { ...@@ -55,6 +57,9 @@ public class ApiAssignmentEntity {
@TableField(value = "params", typeHandler = ListParamHandler.class) @TableField(value = "params", typeHandler = ListParamHandler.class)
private List<ItemParam> params; private List<ItemParam> params;
@TableField(value = "outputs", typeHandler = ListOutputHandler.class)
private List<OutParam> outputs;
@TableField("status") @TableField("status")
private Boolean status; private Boolean status;
......
package com.gitee.sqlrest.persistence.handler;
import com.gitee.sqlrest.common.dto.OutParam;
import com.gitee.sqlrest.persistence.util.JsonUtils;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
public class ListOutputHandler extends BaseTypeHandler<List<OutParam>> {
@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<OutParam> list, JdbcType jdbcType)
throws SQLException {
ps.setString(i, list2string(list));
}
@Override
public List<OutParam> getNullableResult(ResultSet rs, String columnName)
throws SQLException {
String r = rs.getString(columnName);
if (rs.wasNull()) {
return null;
}
return string2list(r);
}
@Override
public List<OutParam> getNullableResult(ResultSet rs, int columnIndex)
throws SQLException {
String r = rs.getString(columnIndex);
if (rs.wasNull()) {
return null;
}
return string2list(r);
}
@Override
public List<OutParam> getNullableResult(CallableStatement cs, int columnIndex)
throws SQLException {
String r = cs.getString(columnIndex);
if (cs.wasNull()) {
return null;
}
return string2list(r);
}
private String list2string(List<OutParam> list) {
if (list == null || list.isEmpty()) {
return null;
}
return JsonUtils.toJsonString(list);
}
private List<OutParam> string2list(String str) {
if (str == null || str.isEmpty()) {
return new ArrayList<>();
}
return JsonUtils.toBeanList(str, OutParam.class);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment