fix: API 数据源参数校验

This commit is contained in:
taojinlong 2024-07-01 19:26:06 +08:00
parent 2c3a93dd2c
commit b3f9f01339
3 changed files with 44 additions and 9 deletions

View File

@ -453,13 +453,15 @@ public class CalciteProvider extends Provider {
if (StringUtils.isEmpty(configuration.getSchema())) {
DEException.throwException(Translator.get("i18n_schema_is_empty"));
}
sql = String.format("SELECT \n" +
" c.name ,t.name ,ep.value \n" +
"FROM \n" +
" sys.columns AS c\n" +
"LEFT JOIN sys.extended_properties AS ep ON c.object_id = ep.major_id AND c.column_id = ep.minor_id\n" +
"LEFT JOIN sys.types AS t ON c.user_type_id = t.user_type_id\n" +
"WHERE c.object_id = OBJECT_ID('%s') ", datasourceRequest.getTable());
"LEFT JOIN sys.objects AS o ON c.object_id = o.object_id\n" +
"WHERE o.name = '%s'", datasourceRequest.getTable());
break;
case pg:
configuration = JsonUtil.parseObject(datasourceRequest.getDatasource().getConfiguration(), Pg.class);

View File

@ -220,6 +220,21 @@ const saveItem = () => {
ElMessage.error(t('datasource.api_field_not_empty'))
return
}
if (apiItem.type === 'params') {
for (let i = 0; i < apiItem.fields.length; i++) {
for (let j = 0; j < paramsList.length; j++) {
for (let k = 0; k < paramsList[j].fields.length; k++) {
if (
apiItem.fields[i].name === paramsList[j].fields[k].name &&
apiItem.serialNumber !== paramsList[j].serialNumber
) {
ElMessage.error('已经存在同名参数:' + apiItem.fields[i].name)
return
}
}
}
}
}
for (let i = 0; i < apiItem.fields.length - 1; i++) {
for (let j = i + 1; j < apiItem.fields.length; j++) {
if (apiItem.fields[i].name === apiItem.fields[j].name) {
@ -241,6 +256,17 @@ const next = () => {
ElMessage.error(t('datasource.please_input_dataPath'))
return
}
if (apiItem.type === 'params') {
for (let i = 0; i < paramsList.length; i++) {
if (
paramsList[i].name === apiItem.name &&
apiItem.serialNumber !== paramsList[i].serialNumber
) {
ElMessage.error('已经存在同名的参数表')
return
}
}
} else {
for (let i = 0; i < apiItemList.length; i++) {
if (
apiItemList[i].name === apiItem.name &&
@ -250,6 +276,8 @@ const next = () => {
return
}
}
}
cancelMap['/datasource/checkApiDatasource']?.()
const params = Base64.encode(JSON.stringify(paramsList))

View File

@ -379,6 +379,9 @@ const returnItem = apiItem => {
if (form.value.paramsConfiguration[i].serialNumber === apiItem.serialNumber) {
find = true
form.value.paramsConfiguration[i] = apiItem
if (apiItem.serialNumber === activeParamsID.value) {
setActiveName(apiItem)
}
}
}
if (!find) {
@ -498,6 +501,7 @@ const apiRule = {
const dialogEditParams = ref(false)
const dialogRenameApi = ref(false)
const activeParamsName = ref('')
const activeParamsID = ref(0)
const paramsObj = ref({
name: '',
id: 1,
@ -542,6 +546,7 @@ const apiObjRules = {
const setActiveName = val => {
gridData.value = val.fields
activeParamsName.value = val.name
activeParamsName.value = val.serialNumber
}
const paramsObjRef = ref()