|
@@ -10,30 +10,51 @@ public class CopyData
|
|
|
{
|
|
{
|
|
|
var apiService = App.GetService<IApiInfoService>();
|
|
var apiService = App.GetService<IApiInfoService>();
|
|
|
var db = initDb();
|
|
var db = initDb();
|
|
|
- string sql = "select * from MyAppApi2 where DatabaseId in (select Id from MyDatabase where ProjectId=203) and SingleReqParam='new_mode2'";
|
|
|
|
|
- var items = db.Ado.GetDataTable(sql);
|
|
|
|
|
- if(items.Rows.Count > 0)
|
|
|
|
|
|
|
+ List<int> ids = new List<int>();
|
|
|
|
|
+ ids.Add(203);
|
|
|
|
|
+ ids.Add(208);
|
|
|
|
|
+ ids.Add(209);
|
|
|
|
|
+ ids.Add(211);
|
|
|
|
|
+ ids.Add(217);
|
|
|
|
|
+ List<string> tableNames = new List<string>();
|
|
|
|
|
+ tableNames.Add("MyAppApi2|ApiParam");
|
|
|
|
|
+ tableNames.Add("AdminApi|AdminApiParam");
|
|
|
|
|
+ foreach (int projectId in ids)
|
|
|
{
|
|
{
|
|
|
- foreach(DataRow item in items.Rows)
|
|
|
|
|
|
|
+ foreach (var tableName in tableNames)
|
|
|
{
|
|
{
|
|
|
- int id = item.Field<int>("Id");
|
|
|
|
|
- var apiInfo = apiService.GetById(id);
|
|
|
|
|
- string paramSql = "select * from ApiParam where ApiId=" + id + " and ParentId=0";
|
|
|
|
|
- var paramItems = db.Ado.GetDataTable(paramSql);
|
|
|
|
|
- if(paramItems.Rows.Count > 0)
|
|
|
|
|
|
|
+ string[] arr = tableName.Split('|');
|
|
|
|
|
+ string sql = "select * from " + arr[0] + " where DatabaseId in (select Id from MyDatabase where ProjectId=" + projectId + ") and SingleReqParam='new_mode2'";
|
|
|
|
|
+ var items = db.Ado.GetDataTable(sql);
|
|
|
|
|
+ if(items.Rows.Count > 0)
|
|
|
{
|
|
{
|
|
|
- apiInfo.apiParam = new List<ApiParamObject>();
|
|
|
|
|
- foreach(DataRow paramItem in paramItems.Rows)
|
|
|
|
|
|
|
+ foreach(DataRow item in items.Rows)
|
|
|
{
|
|
{
|
|
|
- ApiParamObjectData(db, paramItem, id, apiInfo.apiParam);
|
|
|
|
|
|
|
+ int id = item.Field<int>("Id");
|
|
|
|
|
+ int idNum = id;
|
|
|
|
|
+ if(arr[0] == "AdminApi")
|
|
|
|
|
+ {
|
|
|
|
|
+ idNum += 2000;
|
|
|
|
|
+ }
|
|
|
|
|
+ var apiInfo = apiService.GetById(idNum);
|
|
|
|
|
+ string paramSql = "select * from " + arr[1] + " where ApiId=" + id + " and ParentId=0";
|
|
|
|
|
+ var paramItems = db.Ado.GetDataTable(paramSql);
|
|
|
|
|
+ if(paramItems.Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ apiInfo.apiParam = new List<ApiParamObject>();
|
|
|
|
|
+ foreach(DataRow paramItem in paramItems.Rows)
|
|
|
|
|
+ {
|
|
|
|
|
+ ApiParamObjectData(db, paramItem, id, apiInfo.apiParam, arr[1]);
|
|
|
|
|
+ }
|
|
|
|
|
+ apiService.Update(apiInfo);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- apiService.Update(apiInfo);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public static void ApiParamObjectData(SqlSugarClient db, DataRow paramItem, int apiId, List<ApiParamObject> apiParam)
|
|
|
|
|
|
|
+ public static void ApiParamObjectData(SqlSugarClient db, DataRow paramItem, int apiId, List<ApiParamObject> apiParam, string tableName = "ApiParam")
|
|
|
{
|
|
{
|
|
|
ApiParamObject param = new ApiParamObject();
|
|
ApiParamObject param = new ApiParamObject();
|
|
|
param.id = paramItem.Field<int>("Id");
|
|
param.id = paramItem.Field<int>("Id");
|
|
@@ -49,7 +70,7 @@ public class CopyData
|
|
|
param.fieldDetail = paramItem.Field<string>("ColumnDetail");
|
|
param.fieldDetail = paramItem.Field<string>("ColumnDetail");
|
|
|
param.linkTableId = paramItem.Field<int>("LinkTableId");
|
|
param.linkTableId = paramItem.Field<int>("LinkTableId");
|
|
|
param.resType = "字段值";
|
|
param.resType = "字段值";
|
|
|
- string paramSql = "select * from ApiParam where ApiId=" + apiId + " and ParentId=" + paramItem.Field<int>("IdNum");
|
|
|
|
|
|
|
+ string paramSql = "select * from " + tableName + " where ApiId=" + apiId + " and ParentId=" + paramItem.Field<int>("IdNum");
|
|
|
var subParamItems = db.Ado.GetDataTable(paramSql);
|
|
var subParamItems = db.Ado.GetDataTable(paramSql);
|
|
|
if(subParamItems.Rows.Count > 0)
|
|
if(subParamItems.Rows.Count > 0)
|
|
|
{
|
|
{
|