ruoyi对接
登录接口、用户信息接口、用户管理接口等
This commit is contained in:
@@ -44,13 +44,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpPost]
|
||||
public async Task<Result> 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("登录失败!用户名或者密码错误!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新登录的用户密码
|
||||
/// </summary>
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到树形菜单
|
||||
/// </summary>
|
||||
|
||||
@@ -30,9 +30,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList()
|
||||
public async Task<Result> 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) );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,11 +9,21 @@ namespace Yi.Framework.Common.Models
|
||||
|
||||
public class PageModel<T>
|
||||
{
|
||||
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<object>
|
||||
{
|
||||
public PageModel() { }
|
||||
public PageModel(object data, int total) : base(data, total)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
Yi.Framework.Net6/Yi.Framework.Common/Models/PageParModel.cs
Normal file
15
Yi.Framework.Net6/Yi.Framework.Common/Models/PageParModel.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,7 @@ namespace Yi.Framework.DTOModel
|
||||
public HashSet<RoleEntity> Roles { get; set; } = new();
|
||||
public HashSet<MenuEntity> Menus { get; set; }=new();
|
||||
|
||||
public List<string> RoleCodes { get; set; } =new();
|
||||
public List<string> PermissionCodes { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user