diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index eedda300..d02188a3 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -44,13 +44,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPost] public async Task Login(LoginDto loginDto) { + + //跳过 + //先效验验证码和UUID + UserEntity user = new(); if (await _iUserService.Login(loginDto.UserName, loginDto.Password, o => user = o)) { var userRoleMenu= await _iUserService.GetUserAllInfo(user.Id); return Result.Success("登录成功!").SetData(new { token = _jwtInvoker.GetAccessToken(userRoleMenu.User,userRoleMenu.Menus) }); } - return Result.SuccessError("登录失败!用户名或者密码错误!"); + return Result.Error("登录失败!用户名或者密码错误!"); } /// @@ -90,11 +94,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers { //通过鉴权jwt获取到用户的id var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id; - - return Result.Success().SetData(await _iUserService.GetUserAllInfo(userId)); + var data = await _iUserService.GetUserAllInfo(userId); + data.Menus.Clear(); + return Result.Success().SetData(data); } + /// /// 更新登录的用户密码 /// diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs index 0b63c7d1..dd32986a 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs @@ -35,7 +35,6 @@ namespace Yi.Framework.ApiMicroservice.Controllers } - /// /// 得到树形菜单 /// diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs index 8642a4ff..0a4b4055 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -30,9 +30,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers } [HttpGet] - public async Task PageList() + public async Task PageList([FromQuery]UserEntity user, [FromQuery] PageParModel page) { - return Result.Success().SetData(await _iUserService._repository.GetListAsync()); + return Result.Success().SetData(new PageModel(await _iUserService._repository.GetListAsync(),100) ); } /// diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/PageModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/PageModel.cs index 513b83c6..b1a6004c 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/Models/PageModel.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/PageModel.cs @@ -9,11 +9,21 @@ namespace Yi.Framework.Common.Models public class PageModel { + public PageModel() { } + public PageModel(T data,int total) + { + Data = data; + Total = total; + } public int Total { get; set; } public T Data { get; set; } } public class PageModel : PageModel { + public PageModel() { } + public PageModel(object data, int total) : base(data, total) + { + } } } diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/PageParModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/PageParModel.cs new file mode 100644 index 00000000..20690108 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/PageParModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Models +{ + + public class PageParModel + { + public int PageNum { get; set; } + public int PageSize { get; set; } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/LoginDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/LoginDto.cs index 7623ce70..789eaa59 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/LoginDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/LoginDto.cs @@ -10,5 +10,9 @@ namespace Yi.Framework.DTOModel { public string UserName { get; set; } public string Password { get; set; } + + public string Uuid { get; set; } + + public string Code { get; set; } } } diff --git a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserRoleMenuDto.cs b/Yi.Framework.Net6/Yi.Framework.DTOModel/UserRoleMenuDto.cs index bebab074..490a6e70 100644 --- a/Yi.Framework.Net6/Yi.Framework.DTOModel/UserRoleMenuDto.cs +++ b/Yi.Framework.Net6/Yi.Framework.DTOModel/UserRoleMenuDto.cs @@ -13,5 +13,7 @@ namespace Yi.Framework.DTOModel public HashSet Roles { get; set; } = new(); public HashSet Menus { get; set; }=new(); + public List RoleCodes { get; set; } =new(); + public List PermissionCodes { get; set; } = new(); } } diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs index 3e24bcde..84d3d9dd 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs @@ -121,9 +121,15 @@ namespace Yi.Framework.Service //得到菜单集合 foreach (var role in roleList) { + userRoleMenu.RoleCodes.Add(role.RoleCode); + foreach (var menu in role.Menus) { - userRoleMenu.Menus.Add(menu); + if (!string.IsNullOrEmpty(menu.PermissionCode)) + { + userRoleMenu.PermissionCodes.Add(menu.PermissionCode); + userRoleMenu.Menus.Add(menu); + } } //刚好可以去除一下多余的导航属性 role.Menus = null; @@ -133,6 +139,9 @@ namespace Yi.Framework.Service user.Roles = null; userRoleMenu.User = user; + + + return userRoleMenu; }