|
@@ -12,6 +12,7 @@ using Middleware;
|
|
|
using Model;
|
|
|
using Services;
|
|
|
using Model.Base;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
namespace Controllers
|
|
|
{
|
|
@@ -26,14 +27,77 @@ namespace Controllers
|
|
|
/// api分组接口
|
|
|
/// </summary>
|
|
|
private readonly IApiInfoService _ApiInfoService;
|
|
|
+ private readonly IApiGroupService _ApiGroupService;
|
|
|
|
|
|
|
|
|
- public ApiInfoController(IApiInfoService ApiInfoService)
|
|
|
+ public ApiInfoController(IApiInfoService ApiInfoService, IApiGroupService ApiGroupService)
|
|
|
{
|
|
|
_ApiInfoService = ApiInfoService;
|
|
|
+ _ApiGroupService = ApiGroupService;
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpPost]
|
|
|
+ [Route("/noauth/apiinfo/groupsforadmin")]
|
|
|
+ public IActionResult GroupsForAdmin(string value)
|
|
|
+ {
|
|
|
+ var response = _ApiGroupService.GroupsForAdmin(value);
|
|
|
+ return SUCCESS(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpPost]
|
|
|
+ [Route("/noauth/apiinfo/listforadmin")]
|
|
|
+ public IActionResult ListForAdmin(string value)
|
|
|
+ {
|
|
|
+ string jsonString = Dbconn.DesDecrypt(value, "&L^kg4N9");
|
|
|
+ Dictionary<string, object> data = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);
|
|
|
+ Dictionary<string, int> groupobj = new Dictionary<string, int>();
|
|
|
+ Dictionary<string, object> obj = new Dictionary<string, object>();
|
|
|
+ if(jsonString.Contains("\"groups\""))
|
|
|
+ {
|
|
|
+ List<Dictionary<string, object>> groupJson = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(data["groups"].ToString());
|
|
|
+ for(int i = 0; i < groupJson.Count; i ++)
|
|
|
+ {
|
|
|
+ string name = groupJson[i]["name"].ToString();
|
|
|
+ int version = int.Parse(groupJson[i]["version"].ToString());
|
|
|
+ groupobj.Add(name, version);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var groups = _ApiGroupService.GetList(m => m.groupKind == 1);
|
|
|
+ foreach(var group in groups)
|
|
|
+ {
|
|
|
+ int curVersion = int.Parse(Function.CheckInt(group.groupVersion));
|
|
|
+ if(groupobj.Any(m => m.Key == group.groupName && m.Value < curVersion))
|
|
|
+ {
|
|
|
+ Dictionary<string, object> groupData = new Dictionary<string, object>();
|
|
|
+ var apis = _ApiInfoService.GetList(m => m.groupId == group.id).ToList();
|
|
|
+ foreach(var api in apis)
|
|
|
+ {
|
|
|
+ Dictionary<string, object> apiData = new Dictionary<string, object>();
|
|
|
+ string url = api.apiHost;
|
|
|
+ if(api.apiPort != 80 && api.apiPort != 443)
|
|
|
+ {
|
|
|
+ url += ":" + api.apiPort;
|
|
|
+ }
|
|
|
+ url += api.apiRouter;
|
|
|
+ apiData.Add("name", api.apiName);
|
|
|
+ apiData.Add("url", url);
|
|
|
+ apiData.Add("method", api.apiMethod);
|
|
|
+ groupData.Add(api.apiKey, apiData);
|
|
|
+ }
|
|
|
+ groupData.Add("groupVersion", group.groupVersion);
|
|
|
+ groupData.Add("groupInfo", group.groupRemark);
|
|
|
+ obj.Add(group.groupName, groupData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return SUCCESS(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// api接口列表
|
|
|
/// </summary>
|