lcl 9 meses atrás
pai
commit
85c8e0e37c

+ 65 - 1
Controllers/ApiInfoController.cs

@@ -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>

+ 5 - 5
Controllers/Base/SysDeptController.cs

@@ -47,7 +47,7 @@ namespace Controllers
         /// 获取所有部门列表
         /// </summary>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/dept/list")]
+        [HttpGet("/v1/kxs/sysServer/dept/list")]
         public IActionResult AllList()
         {
             return SUCCESS(DeptService.GetList(), TIME_FORMAT_FULL);
@@ -88,7 +88,7 @@ namespace Controllers
         /// </summary>
         /// <param name="dept"></param>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/dept/tree")]
+        [HttpGet("/v1/kxs/sysServer/dept/tree")]
         public IActionResult TreeSelect(SysDeptQueryDto dept)
         {
             var depts = DeptService.GetSysDepts(dept);
@@ -131,7 +131,7 @@ namespace Controllers
         /// </summary>
         /// <param name="dept"></param>
         /// <returns></returns>
-        [HttpPost("/v1/skb/sysServer/dept/add")]
+        [HttpPost("/v1/kxs/sysServer/dept/add")]
         public IActionResult Add([FromBody] SysDept dept)
         {
             if (UserConstants.NOT_UNIQUE.Equals(DeptService.CheckDeptNameUnique(dept)))
@@ -150,7 +150,7 @@ namespace Controllers
         /// </summary>
         /// <param name="dept"></param>
         /// <returns></returns>
-        [HttpPut("/v1/skb/sysServer/dept/update")]
+        [HttpPut("/v1/kxs/sysServer/dept/update")]
         public IActionResult Update([FromBody] SysDept dept)
         {
             if (UserConstants.NOT_UNIQUE.Equals(DeptService.CheckDeptNameUnique(dept)))
@@ -170,7 +170,7 @@ namespace Controllers
         /// 删除部门
         /// </summary>
         /// <returns></returns>
-        [HttpDelete("/v1/skb/sysServer/dept/removeById/{id}")]
+        [HttpDelete("/v1/kxs/sysServer/dept/removeById/{id}")]
         public IActionResult Remove(int id)
         {
             if (DeptService.Queryable().Count(it => it.parentId == id && it.DelFlag == "0") > 0)

+ 1 - 1
Controllers/Base/SysLoginController.cs

@@ -47,7 +47,7 @@ namespace Controllers
         /// </summary>
         /// <param name="loginBody">登录对象</param>
         /// <returns></returns>
-        [Route("/v1/skb/sysServer/oauth2/token")]
+        [Route("/v1/kxs/sysServer/oauth2/token")]
         [HttpPost]
         [Log(Title = "登录")]
         public IActionResult Login([FromBody] LoginBodyDto loginBody)

+ 6 - 6
Controllers/Base/SysMenuController.cs

@@ -39,7 +39,7 @@ namespace Controllers
         /// 获取菜单树列表
         /// </summary>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/menu/tree")]
+        [HttpGet("/v1/kxs/sysServer/menu/tree")]
         public IActionResult TreeMenuList([FromQuery] MenuQueryDto menu)
         {
             TokenModel loginUser = JwtUtil.GetLoginUser(HttpContext);
@@ -90,7 +90,7 @@ namespace Controllers
         /// </summary>
         /// <param name="roleId"></param>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/menu/getRoleTree")]
+        [HttpGet("/v1/kxs/sysServer/menu/getRoleTree")]
         public IActionResult RoleMenuTreeselect([FromQuery] RoleMenuQueryDto menu)
         {
             TokenModel loginUser = JwtUtil.GetLoginUser(HttpContext);
@@ -104,7 +104,7 @@ namespace Controllers
         }
 
         [Verify]
-        [HttpGet("/v1/skb/sysServer/menu/getUserMenu")]
+        [HttpGet("/v1/kxs/sysServer/menu/getUserMenu")]
         public IActionResult GetMenus()
         {
             long userId = HttpContext.GetUId();
@@ -117,7 +117,7 @@ namespace Controllers
         /// </summary>
         /// <param name="menuDto"></param>
         /// <returns></returns>
-        [HttpPut("/v1/skb/sysServer/menu/update")]
+        [HttpPut("/v1/kxs/sysServer/menu/update")]
         public IActionResult MenuEdit([FromBody] MenuDto menuDto)
         {
             if (menuDto == null) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
@@ -151,7 +151,7 @@ namespace Controllers
         /// </summary>
         /// <param name="menuDto"></param>
         /// <returns></returns>
-        [HttpPost("/v1/skb/sysServer/menu/add")]
+        [HttpPost("/v1/kxs/sysServer/menu/add")]
         public IActionResult MenuAdd([FromBody] MenuDto menuDto)
         {
             var config = new TypeAdapterConfig();
@@ -183,7 +183,7 @@ namespace Controllers
         /// </summary>
         /// <param name="menuId"></param>
         /// <returns></returns>
-        [HttpDelete("/v1/skb/sysServer/menu/removeById/{id}")]
+        [HttpDelete("/v1/kxs/sysServer/menu/removeById/{id}")]
         public IActionResult Remove(int id)
         {
             if (sysMenuService.HasChildByMenuId(id))

+ 5 - 5
Controllers/Base/SysPostController.cs

@@ -29,7 +29,7 @@ namespace Controllers
         /// 岗位列表查询
         /// </summary>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/post/page")]
+        [HttpGet("/v1/kxs/sysServer/post/page")]
         public IActionResult List([FromQuery] SysPost post, [FromQuery] PagerInfo pagerInfo)
         {
             var predicate = Expressionable.Create<SysPost>();
@@ -43,7 +43,7 @@ namespace Controllers
         /// 获取所有岗位列表
         /// </summary>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/post/list")]
+        [HttpGet("/v1/kxs/sysServer/post/list")]
         public IActionResult AllList()
         {
             return SUCCESS(PostService.GetList(), TIME_FORMAT_FULL);
@@ -66,7 +66,7 @@ namespace Controllers
         /// </summary>
         /// <param name="post"></param>
         /// <returns></returns>
-        [HttpPost("/v1/skb/sysServer/post/add")]
+        [HttpPost("/v1/kxs/sysServer/post/add")]
         public IActionResult Add([FromBody] SysPost post)
         {
             if (UserConstants.NOT_UNIQUE.Equals(PostService.CheckPostNameUnique(post)))
@@ -91,7 +91,7 @@ namespace Controllers
         /// </summary>
         /// <param name="post"></param>
         /// <returns></returns>
-        [HttpPut("/v1/skb/sysServer/post/update")]
+        [HttpPut("/v1/kxs/sysServer/post/update")]
         public IActionResult Update([FromBody] SysPost post)
         {
             if (UserConstants.NOT_UNIQUE.Equals(PostService.CheckPostNameUnique(post)))
@@ -113,7 +113,7 @@ namespace Controllers
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        [HttpDelete("/v1/skb/sysServer/post/removeById/{id}")]
+        [HttpDelete("/v1/kxs/sysServer/post/removeById/{id}")]
         public IActionResult Delete(int id)
         {
             return SUCCESS(PostService.Delete(id));

+ 6 - 6
Controllers/Base/SysRoleController.cs

@@ -37,7 +37,7 @@ namespace Controllers
         /// 获取系统角色管理
         /// </summary>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/role/page")]
+        [HttpGet("/v1/kxs/sysServer/role/page")]
         public IActionResult List([FromQuery] SysRole role, [FromQuery] PagerInfo pager)
         {
             var list = sysRoleService.SelectRoleList(role, pager);
@@ -49,7 +49,7 @@ namespace Controllers
         /// 获取所有角色列表
         /// </summary>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/role/list")]
+        [HttpGet("/v1/kxs/sysServer/role/list")]
         public IActionResult AllList()
         {
             return SUCCESS(sysRoleService.GetList(), TIME_FORMAT_FULL);
@@ -73,7 +73,7 @@ namespace Controllers
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
-        [HttpPost("/v1/skb/sysServer/role/add")]
+        [HttpPost("/v1/kxs/sysServer/role/add")]
         public IActionResult RoleAdd([FromBody] SysRoleDto dto)
         {
             SysRole sysRoleDto = dto.Adapt<SysRole>();
@@ -95,7 +95,7 @@ namespace Controllers
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
-        [HttpPut("/v1/skb/sysServer/role/update")]
+        [HttpPut("/v1/kxs/sysServer/role/update")]
         public IActionResult RoleEdit([FromBody] SysRoleDto dto)
         {
             if (dto == null || dto.roleId <= 0)
@@ -127,7 +127,7 @@ namespace Controllers
         /// </summary>
         /// <param name="sysRoleDto"></param>
         /// <returns></returns>
-        [HttpPut("/v1/skb/sysServer/role/menu")]
+        [HttpPut("/v1/kxs/sysServer/role/menu")]
         public IActionResult DataScope([FromBody] SysRoleDto sysRoleDto)
         {
             if (sysRoleDto == null || sysRoleDto.roleId <= 0) return ToResponse(ApiResult.Error(101, "请求参数错误"));
@@ -145,7 +145,7 @@ namespace Controllers
         /// </summary>
         /// <param name="roleId"></param>
         /// <returns></returns>
-        [HttpDelete("/v1/skb/sysServer/role/removeById/{id}")]
+        [HttpDelete("/v1/kxs/sysServer/role/removeById/{id}")]
         public IActionResult Remove(int id)
         {
             long[] roleIds = { id };

+ 4 - 4
Controllers/Base/SysUserController.cs

@@ -51,7 +51,7 @@ namespace Controllers
         /// /system/user/list
         /// </summary>
         /// <returns></returns>
-        [HttpGet("/v1/skb/sysServer/user/page")]
+        [HttpGet("/v1/kxs/sysServer/user/page")]
         public IActionResult List([FromQuery] SysUserQueryDto user, PagerInfo pager)
         {
             var list = UserService.SelectUserList(user, pager);
@@ -113,7 +113,7 @@ namespace Controllers
         /// </summary>
         /// <param name="parm"></param>
         /// <returns></returns>
-        [HttpPost("/v1/skb/sysServer/user/add")]
+        [HttpPost("/v1/kxs/sysServer/user/add")]
         public IActionResult AddUser([FromBody] SysUserDto parm)
         {
             var user = parm.Adapt<SysUser>().ToCreate(HttpContext);
@@ -141,7 +141,7 @@ namespace Controllers
         /// </summary>
         /// <param name="parm"></param>
         /// <returns></returns>
-        [HttpPut("/v1/skb/sysServer/user/update")]
+        [HttpPut("/v1/kxs/sysServer/user/update")]
         public IActionResult UpdateUser([FromBody] SysUserDto parm)
         {
             var user = parm.Adapt<SysUser>().ToUpdate(HttpContext);
@@ -183,7 +183,7 @@ namespace Controllers
         /// </summary>
         /// <param name="userid"></param>
         /// <returns></returns>
-        [HttpDelete("/v1/skb/sysServer/user/removeById/{id}")]
+        [HttpDelete("/v1/kxs/sysServer/user/removeById/{id}")]
         public IActionResult Remove(int id = 0)
         {
             if (id <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }

+ 1 - 1
Filters/AuthorizationFilter.cs

@@ -29,7 +29,7 @@ namespace Filters
         public void OnAuthorization(AuthorizationFilterContext context)
         {
             var request = context.HttpContext.Request;
-            if(!request.Path.Value.ToLower().Contains("feign/"))
+            if(!request.Path.Value.ToLower().Contains("noauth/"))
             {
                 string content = "";
                 if(context.HttpContext.Request.Method.ToLower() == "get")

+ 1 - 1
Filters/GlobalActionMonitor.cs

@@ -32,7 +32,7 @@ namespace Middleware
         /// <returns></returns>
         public override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
         {
-            if(!context.HttpContext.Request.Path.Value.ToLower().Contains("feign/"))
+            if(!context.HttpContext.Request.Path.Value.ToLower().Contains("noauth/"))
             {
                 string content = "";
                 if(context.HttpContext.Request.Method.ToLower() == "get")

+ 1 - 0
Model/Vo/ApiGroupQueryVo.cs

@@ -17,6 +17,7 @@ namespace Vo
         /// 版本号
         /// </summary>
         public string groupVersion { get; set; }
+        public string groupRemark { get; set; }
 
 
         /// <summary>

+ 18 - 0
Services/ApiGroupService.cs

@@ -7,6 +7,7 @@ using Model.Base;
 using Repository;
 using Service;
 using Microsoft.AspNetCore.Mvc;
+using Common;
 
 namespace Services
 {
@@ -33,6 +34,23 @@ namespace Services
             return response;
         }
 
+        public List<string> GroupsForAdmin(string value)
+        {
+            string jsonString = Dbconn.DesDecrypt(value, "&L^kg4N9");
+            Dictionary<string, string> data = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonString);
+            string key = data["key"];
+            if(key != "kxs#2024")
+            {
+                return new List<string>();
+            }
+            var response = Queryable()
+                .Where(m => m.groupKind == 1)
+                .ToList()
+                .Select(m => m.groupName)
+                .ToList();
+            return response;
+        }
+
 
 
 

+ 2 - 14
Services/ApiInfoService.cs

@@ -7,6 +7,7 @@ using Model.Base;
 using Repository;
 using Service;
 using Microsoft.AspNetCore.Mvc;
+using Common;
 
 namespace Services
 {
@@ -25,7 +26,7 @@ namespace Services
         {
             //开始拼装查询条件
             var predicate = Expressionable.Create<ApiInfo>();
-            predicate = predicate.AndIF(parm.groupId != null, m => m.groupId == parm.groupId);
+            predicate = predicate.AndIF(parm.groupId > 0, m => m.groupId == parm.groupId);
             predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.apiName), m => m.apiName.Contains(parm.apiName));
             var response = Queryable()
                 .Where(predicate.ToExpression())
@@ -34,18 +35,5 @@ namespace Services
                 .ToPage<ApiInfo, ApiInfoListVo>(new PagerInfo());
             return response;
         }
-
-
-
-
-
-
-
-
-
-
-
-
-
     }
 }

+ 7 - 7
Services/Base/SysUserService.cs

@@ -56,14 +56,14 @@ namespace Services
                 .OrderByDescending(m => m.userId);
 
             PagedInfo<SysUser> result = query.ToPage(pager);
-            // foreach(SysUser sub in result.Records)
-            // {
-            //     List<long> userRoles = UserRoleService.GetList(m => m.UserId == sub.userId).Select(m => m.RoleId).ToList();
-            //     sub.RoleList = RoleService.GetList(m => userRoles.Contains(m.roleId));
+            foreach(SysUser sub in result.Records)
+            {
+                List<long> userRoles = UserRoleService.GetList(m => m.UserId == sub.userId).Select(m => m.RoleId).ToList();
+                sub.RoleList = RoleService.GetList(m => userRoles.Contains(m.roleId));
 
-            //     List<long> userPost = UserPostService.GetList(m => m.UserId == sub.userId).Select(m => m.PostId).ToList();
-            //     sub.PostList = PostService.GetList(m => userPost.Contains(m.postId));
-            // }
+                List<long> userPost = UserPostService.GetList(m => m.UserId == sub.userId).Select(m => m.PostId).ToList();
+                sub.PostList = PostService.GetList(m => userPost.Contains(m.postId));
+            }
 
             return result;
         }

+ 1 - 0
Services/IService/IApiGroupService.cs

@@ -14,6 +14,7 @@ namespace Services
         /// <param name="parm">请求参数</param>
         /// <returns>api接口分组列表</returns>
         PagedInfo<ApiGroupListVo> List([FromQuery] ApiGroupListDto parm);
+        List<string> GroupsForAdmin(string value);
 
 
 

+ 0 - 10
Services/IService/IApiInfoService.cs

@@ -15,15 +15,5 @@ namespace Services
         /// <returns>api接口列表</returns>
         PagedInfo<ApiInfoListVo> List([FromQuery] ApiInfoListDto parm);
 
-
-
-
-
-
-
-
-
-
-
     }
 }

+ 1 - 1
appsettings.Development.json

@@ -14,7 +14,7 @@
   },
   "dbConfigs": [
     {
-      "Conn": "server=47.109.31.237;port=3306;user=KxsConfigServer;password=brVSLE47Y32WUy3R;database=KxsConfigServer;charset=utf8;",
+      "Conn": "server=47.108.62.166;port=3306;user=root;password=HDlNs1ZpG5iR9D9I;database=KxsConfigServer;charset=utf8;",
       "DbType": 0,
       "ConfigId": "0",
       "IsAutoCloseConnection": true