Skip to content

Commit 3943b56

Browse files
committed
feat: Add table field update functionality
1 parent 77f2b4d commit 3943b56

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

backend/apps/datasource/api/datasource.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ async def get_fields(session: SessionDep,
158158

159159

160160
@router.post("/syncFields/{id}", response_model=None, summary=f"{PLACEHOLDER_PREFIX}ds_sync_fields")
161-
async def sync_fields(session: SessionDep, id: int = Path(..., description=f"{PLACEHOLDER_PREFIX}ds_table_id")):
162-
return sync_single_fields(session, id)
161+
async def sync_fields(session: SessionDep, trans: Trans,
162+
id: int = Path(..., description=f"{PLACEHOLDER_PREFIX}ds_table_id")):
163+
return sync_single_fields(session, trans, id)
163164

164165

165166
from pydantic import BaseModel

backend/apps/datasource/crud/datasource.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,18 @@ def execSql(session: SessionDep, id: int, sql: str):
165165
return exec_sql(ds, sql, True)
166166

167167

168-
def sync_single_fields(session: SessionDep, id: int):
168+
def sync_single_fields(session: SessionDep, trans: Trans, id: int):
169169
table = session.query(CoreTable).filter(CoreTable.id == id).first()
170170
ds = session.query(CoreDatasource).filter(CoreDatasource.id == table.ds_id).first()
171171

172+
tables = getTablesByDs(session, ds)
173+
t_name = []
174+
for _t in tables:
175+
t_name.append(_t.tableName)
176+
177+
if not table.table_name in t_name:
178+
raise HTTPException(status_code=500, detail=trans('i18n_table_not_exist'))
179+
172180
# sync field
173181
fields = getFieldsByDs(session, ds, table.table_name)
174182
sync_fields(session, ds, table, fields)

backend/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,6 @@
174174
"params_setting": "Parameters Setting",
175175
"rules": "Permission Rules",
176176
"log_setting": "Login Authentication"
177-
}
177+
},
178+
"i18n_table_not_exist": "Table not exist"
178179
}

backend/locales/ko-KR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,6 @@
174174
"params_setting": "매개변수 설정",
175175
"rules": "권한 규칙",
176176
"log_setting": "로그인 인증"
177-
}
177+
},
178+
"i18n_table_not_exist": "현재 테이블이 존재하지 않습니다"
178179
}

backend/locales/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,6 @@
174174
"params_setting": "参数设置",
175175
"rules": "权限规则",
176176
"log_setting": "登录认证"
177-
}
177+
},
178+
"i18n_table_not_exist": "当前表不存在"
178179
}

0 commit comments

Comments
 (0)