|
@@ -90,15 +90,15 @@ namespace Services
|
|
|
/// 同步api到管理平台
|
|
/// 同步api到管理平台
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="serviceId">服务id</param>
|
|
/// <param name="serviceId">服务id</param>
|
|
|
- public string sycnApiToSystem(int projectId, int serviceId, string env)
|
|
|
|
|
|
|
+ public string sycnApiToSystem(SycnApiToSystemDto param)
|
|
|
{
|
|
{
|
|
|
var apiGroupService = App.GetService<IApiGroupService>();
|
|
var apiGroupService = App.GetService<IApiGroupService>();
|
|
|
var apiInfoService = App.GetService<IApiInfoService>();
|
|
var apiInfoService = App.GetService<IApiInfoService>();
|
|
|
var tableService = App.GetService<IDatabaseTableService>();
|
|
var tableService = App.GetService<IDatabaseTableService>();
|
|
|
- var project = IProject.getProject(projectId);
|
|
|
|
|
|
|
+ var project = IProject.getProject(param.projectId);
|
|
|
string ApiListHost = "";
|
|
string ApiListHost = "";
|
|
|
string Hosts = "";
|
|
string Hosts = "";
|
|
|
- if(env == "test")
|
|
|
|
|
|
|
+ if(param.env == "test")
|
|
|
{
|
|
{
|
|
|
ApiListHost = project.apiListNoticeHostDev ?? "";
|
|
ApiListHost = project.apiListNoticeHostDev ?? "";
|
|
|
Hosts = project.gatewayHostDev ?? "";
|
|
Hosts = project.gatewayHostDev ?? "";
|
|
@@ -108,12 +108,12 @@ namespace Services
|
|
|
ApiListHost = project.apiListNoticeHost ?? "";
|
|
ApiListHost = project.apiListNoticeHost ?? "";
|
|
|
Hosts = project.gatewayHost ?? "";
|
|
Hosts = project.gatewayHost ?? "";
|
|
|
}
|
|
}
|
|
|
- var projectService = IProject.getProjectService(serviceId);
|
|
|
|
|
|
|
+ var projectService = IProject.getProjectService(param.serviceId);
|
|
|
List<string> checkStrs = new List<string>();
|
|
List<string> checkStrs = new List<string>();
|
|
|
List<Dictionary<string, object>> dic = new List<Dictionary<string, object>>();
|
|
List<Dictionary<string, object>> dic = new List<Dictionary<string, object>>();
|
|
|
string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
int Id = 0;
|
|
int Id = 0;
|
|
|
- var projectServiceList = IProject.getProjectServiceList(projectId);
|
|
|
|
|
|
|
+ var projectServiceList = IProject.getProjectServiceList(param.projectId);
|
|
|
foreach(var proService in projectServiceList)
|
|
foreach(var proService in projectServiceList)
|
|
|
{
|
|
{
|
|
|
Id += 1;
|
|
Id += 1;
|
|
@@ -130,6 +130,14 @@ namespace Services
|
|
|
}
|
|
}
|
|
|
List<Dictionary<string, object>> child = new List<Dictionary<string, object>>();
|
|
List<Dictionary<string, object>> child = new List<Dictionary<string, object>>();
|
|
|
var apiInfos = apiInfoService.GetList(m => m.serviceId == serId);
|
|
var apiInfos = apiInfoService.GetList(m => m.serviceId == serId);
|
|
|
|
|
+ if(param.serviceId > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ apiInfos = apiInfos.Where(m => m.serviceId == param.serviceId).ToList();
|
|
|
|
|
+ }
|
|
|
|
|
+ if(param.groupId > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ apiInfos = apiInfos.Where(m => m.groupId == param.groupId).ToList();
|
|
|
|
|
+ }
|
|
|
foreach(var apiInfo in apiInfos)
|
|
foreach(var apiInfo in apiInfos)
|
|
|
{
|
|
{
|
|
|
var linkTable = tableService.GetFirst(m => m.id == apiInfo.linkTableId) ?? new DatabaseTable();
|
|
var linkTable = tableService.GetFirst(m => m.id == apiInfo.linkTableId) ?? new DatabaseTable();
|
|
@@ -176,7 +184,7 @@ namespace Services
|
|
|
}
|
|
}
|
|
|
Dictionary<string, object> item = new Dictionary<string, object>();
|
|
Dictionary<string, object> item = new Dictionary<string, object>();
|
|
|
item.Add("id", Id);
|
|
item.Add("id", Id);
|
|
|
- item.Add("group_project", projectId);
|
|
|
|
|
|
|
+ item.Add("group_project", param.projectId);
|
|
|
item.Add("group_kind", 1);
|
|
item.Add("group_kind", 1);
|
|
|
item.Add("group_remark", proService.serviceTitle ?? "");
|
|
item.Add("group_remark", proService.serviceTitle ?? "");
|
|
|
item.Add("group_name", PublicFunction.transferName(proService.serviceName ?? "", 2));
|
|
item.Add("group_name", PublicFunction.transferName(proService.serviceName ?? "", 2));
|
|
@@ -186,9 +194,9 @@ namespace Services
|
|
|
|
|
|
|
|
string req = Newtonsoft.Json.JsonConvert.SerializeObject(dic);
|
|
string req = Newtonsoft.Json.JsonConvert.SerializeObject(dic);
|
|
|
string result = "";
|
|
string result = "";
|
|
|
- if(project.encryptKind == 1)
|
|
|
|
|
|
|
+ if(project.encryptKind == "AES")
|
|
|
{
|
|
{
|
|
|
- JsonData encryptParam = JsonMapper.ToObject(project.encryptParams ?? "{}");
|
|
|
|
|
|
|
+ JsonData encryptParam = JsonMapper.ToObject(project.encryptParam ?? "{}");
|
|
|
string reqData = CryptHelper.AesEncrypt(req, encryptParam["encrypt_key"].ToString(), encryptParam["encrypt_iv"].ToString(), encryptParam["encrypt_model"].ToString(), encryptParam["encrypt_padding"].ToString());
|
|
string reqData = CryptHelper.AesEncrypt(req, encryptParam["encrypt_key"].ToString(), encryptParam["encrypt_iv"].ToString(), encryptParam["encrypt_model"].ToString(), encryptParam["encrypt_padding"].ToString());
|
|
|
result = Function.PostWebRequest(ApiListHost, reqData, "application/json");
|
|
result = Function.PostWebRequest(ApiListHost, reqData, "application/json");
|
|
|
JsonData jsonObj = JsonMapper.ToObject(result);
|
|
JsonData jsonObj = JsonMapper.ToObject(result);
|