|
@@ -5,6 +5,8 @@ using Repository;
|
|
|
using Service;
|
|
using Service;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Vo.Admin;
|
|
using Vo.Admin;
|
|
|
|
|
+using Common;
|
|
|
|
|
+using Custom;
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Services
|
|
namespace Services
|
|
@@ -15,6 +17,13 @@ namespace Services
|
|
|
[AppService(ServiceType = typeof(IApiGroupService), ServiceLifetime = LifeTime.Transient)]
|
|
[AppService(ServiceType = typeof(IApiGroupService), ServiceLifetime = LifeTime.Transient)]
|
|
|
public class ApiGroupService : BaseService<ApiGroup>, IApiGroupService
|
|
public class ApiGroupService : BaseService<ApiGroup>, IApiGroupService
|
|
|
{
|
|
{
|
|
|
|
|
+ private readonly IApiInfoService _ApiInfoService;
|
|
|
|
|
+
|
|
|
|
|
+ public ApiGroupService(IApiInfoService ApiInfoService)
|
|
|
|
|
+ {
|
|
|
|
|
+ _ApiInfoService = ApiInfoService;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// 接口分组-列表
|
|
/// 接口分组-列表
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -40,13 +49,31 @@ namespace Services
|
|
|
/// 生成api文档
|
|
/// 生成api文档
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="serviceId">服务id</param>
|
|
/// <param name="serviceId">服务id</param>
|
|
|
- public void makeApiDoc(int serviceId)
|
|
|
|
|
|
|
+ public void makeApiDoc(int serviceId, TokenModel loginUser)
|
|
|
{
|
|
{
|
|
|
- var apiGroups = GetList(m => m.serviceId == serviceId);
|
|
|
|
|
- foreach (var group in apiGroups)
|
|
|
|
|
|
|
+ var service = Feign.IProject.getProject(serviceId);
|
|
|
|
|
+ var apiGroups = GetList(m => m.serviceId == serviceId);
|
|
|
|
|
+ var apiInfos = _ApiInfoService.GetList(m => m.serviceId == serviceId);
|
|
|
|
|
+ foreach(var apiInfo in apiInfos)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+ apiInfo.groupName = apiGroups.FirstOrDefault(m => m.id == apiInfo.groupId).groupTitle;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ MakeData makeData = new();
|
|
|
|
|
+ string requestId = DateTime.Now.ToString("yyyyMMddHHmmssfff") + Function.get_Random(8);
|
|
|
|
|
+ makeData.requestId = requestId;
|
|
|
|
|
+ makeData.modePath = "ApiDoc/doc.json";
|
|
|
|
|
+ Dictionary<string, string> attach = new();
|
|
|
|
|
+ attach.Add("id", serviceId.ToString());
|
|
|
|
|
+ attach.Add("kind", "apidoc");
|
|
|
|
|
+ attach.Add("operator", loginUser.username);
|
|
|
|
|
+ makeData.attach = Newtonsoft.Json.JsonConvert.SerializeObject(attach);
|
|
|
|
|
+ makeData.data = new Dictionary<string, object>();
|
|
|
|
|
+ makeData.data.Add("serviceName", service.serviceName);
|
|
|
|
|
+ makeData.data.Add("serviceTitle", service.serviceTitle);
|
|
|
|
|
+ makeData.data.Add("apiGroup", apiGroups);
|
|
|
|
|
+ makeData.data.Add("apiInfo", apiInfos);
|
|
|
|
|
+ RabbitMQClient.Instance.Push("MakeApiDocQueue", Newtonsoft.Json.JsonConvert.SerializeObject(makeData));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|