|
@@ -10,13 +10,17 @@ namespace DocTools
|
|
|
public class CreateDocHtml
|
|
|
{
|
|
|
private static Dictionary<string, string> PublicEnumDic = new Dictionary<string, string>();
|
|
|
-
|
|
|
+ private static string FileName = "demoHtml.html";
|
|
|
/// <summary>
|
|
|
/// 创建最基础json信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public ResultEntity CreateDocProjectString(string version = "")
|
|
|
+ public ResultEntity CreateDocProjectString(string version = "", string fileName = "")
|
|
|
{
|
|
|
+ if (!string.IsNullOrEmpty(fileName))
|
|
|
+ {
|
|
|
+ FileName = fileName;
|
|
|
+ }
|
|
|
var result = new ResultEntity()
|
|
|
{
|
|
|
create_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
@@ -134,6 +138,10 @@ namespace DocTools
|
|
|
for (int i = 0; i < enumList.Count; i++)
|
|
|
{
|
|
|
var item = enumList[i];
|
|
|
+ if (item.ParamName.Contains("WingInterfaceLibrary.Enum.RpcExceptionEnum."))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
var enumEntity = GetSpecialEnum(item.ParamName.Replace("T:", ""), enumFolderEntity.local_target_id, item.Remarks, i);
|
|
|
enumFolderEntity.children.Add(enumEntity);
|
|
|
}
|
|
@@ -398,8 +406,18 @@ namespace DocTools
|
|
|
field_type = "Number",
|
|
|
value = "1"
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ error_result = new List<ExceptionResultEntity>()
|
|
|
};
|
|
|
+ //计算响应列表枚举
|
|
|
+ if (methodEntity.ParaList?.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in methodEntity.ParaList)
|
|
|
+ {
|
|
|
+ var gere = GetExceptionResultEnum(item);
|
|
|
+ successParameter.error_result.Add(gere);
|
|
|
+ }
|
|
|
+ }
|
|
|
var rawResultStr = "";
|
|
|
if (methodEntity.ResponseList?.Count > 0)
|
|
|
{
|
|
@@ -571,6 +589,7 @@ namespace DocTools
|
|
|
var generalTypeStr = CommonHelper.GetJsonDataTypeByString(responseItem.GenericityType);
|
|
|
var childObject = new ResponseParameterEntity()
|
|
|
{
|
|
|
+ file_name = FileName,
|
|
|
description = responseItem.Desc,
|
|
|
is_checked = 0,
|
|
|
type = "Text",
|
|
@@ -583,9 +602,12 @@ namespace DocTools
|
|
|
//}
|
|
|
if (childTypeStr.Contains("Enum"))
|
|
|
{
|
|
|
- childObject.field_type_value = 1;
|
|
|
var key = "WingInterfaceLibrary.Enum." + childTypeStr;
|
|
|
- childObject.field_type_target_id = PublicEnumDic[key];
|
|
|
+ if (PublicEnumDic.Keys.Contains(key))
|
|
|
+ {
|
|
|
+ childObject.field_type_value = 1;
|
|
|
+ childObject.field_type_target_id = PublicEnumDic[key];
|
|
|
+ }
|
|
|
}
|
|
|
if (childTypeStr == "Array" && generalTypeStr != "Object")
|
|
|
{
|
|
@@ -625,6 +647,7 @@ namespace DocTools
|
|
|
var generalTypeStr = CommonHelper.GetJsonDataTypeByString(responseItem.GenericityType);
|
|
|
var childObject = new ResponseParameterEntity()
|
|
|
{
|
|
|
+ file_name = FileName,
|
|
|
description = responseItem.Desc,
|
|
|
is_checked = 0,
|
|
|
type = "Text",
|
|
@@ -637,9 +660,12 @@ namespace DocTools
|
|
|
//}
|
|
|
if (childTypeStr.Contains("Enum"))
|
|
|
{
|
|
|
- childObject.field_type_value = 1;
|
|
|
var key = "WingInterfaceLibrary.Enum." + childTypeStr;
|
|
|
- childObject.field_type_target_id = PublicEnumDic[key];
|
|
|
+ if (PublicEnumDic.Keys.Contains(key))
|
|
|
+ {
|
|
|
+ childObject.field_type_value = 1;
|
|
|
+ childObject.field_type_target_id = PublicEnumDic[key];
|
|
|
+ }
|
|
|
}
|
|
|
if (childTypeStr == "Array" && generalTypeStr != "Object")
|
|
|
{
|
|
@@ -844,6 +870,39 @@ namespace DocTools
|
|
|
return resultStr;
|
|
|
}
|
|
|
|
|
|
+ public ExceptionResultEntity GetExceptionResultEnum(string enumNamespace)
|
|
|
+ {
|
|
|
+ var resultEntity = new ExceptionResultEntity();
|
|
|
+ List<MemberEntity> memberList = LoadData.GetInterfaceConfigToCache();
|
|
|
+ var enumInfo = memberList.Find(c => c.ParamName.Contains("T:WingInterfaceLibrary.Enum.RpcExceptionEnum." + enumNamespace) && !string.IsNullOrEmpty(c.Remarks));
|
|
|
+ if (enumInfo != null)
|
|
|
+ {
|
|
|
+ //获取错误枚举、上传文件类型枚举
|
|
|
+ var enumList = memberList.FindAll(c => c.ParamName.Contains(enumInfo.ParamName.Replace("T:", "")));
|
|
|
+ if (enumList?.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in enumList)
|
|
|
+ {
|
|
|
+ if (item.ParamName.Equals(enumInfo.ParamName))
|
|
|
+ {
|
|
|
+ //title,name,和header
|
|
|
+ resultEntity.title = item.Summary;
|
|
|
+ resultEntity.name = enumNamespace;
|
|
|
+ resultEntity.header = item.Remarks.Split('|').ToArray().Select(c => c.Trim()).ToList();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var ece = new ExceptionContentEntity();
|
|
|
+ ece.content_data = item.Remarks.Split('|').ToArray().Select(c => c.Trim()).ToList();
|
|
|
+ //content
|
|
|
+ resultEntity.content.Add(ece);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resultEntity;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 加载指定枚举注释到文档中
|
|
|
/// </summary>
|