@@ -40,11 +40,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
public async Task<Result> Login(user _user)
|
public async Task<Result> Login(user _user)
|
||||||
{
|
{
|
||||||
var user_data = await _userService.Login(_user);
|
var user_data = await _userService.Login(_user);
|
||||||
//var menuList = await _menuService.GetTopMenuByUserId(user_data.id);
|
var menuList = await _menuService.GetTopMenuByUserId(user_data.id);
|
||||||
|
|
||||||
if ( user_data!=null)
|
if ( user_data!=null)
|
||||||
{
|
{
|
||||||
var token = MakeJwt.app(new jwtUser() {user=user_data});
|
var token = MakeJwt.app(new jwtUser() {user=user_data,menuIds= menuList});
|
||||||
return Result.Success().SetData(new { user = new { _user.id, _user.username, _user.introduction, _user.icon, _user.nick }, token });
|
return Result.Success().SetData(new { user = new { _user.id, _user.username, _user.introduction, _user.icon, _user.nick }, token });
|
||||||
}
|
}
|
||||||
return Result.Error();
|
return Result.Error();
|
||||||
@@ -154,11 +153,5 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
return Result.Success(msg);
|
return Result.Success(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public async Task<Result> UpdataIcon()
|
|
||||||
{
|
|
||||||
return Result.Success();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Yi.Framework.Common.Models;
|
|
||||||
using Yi.Framework.Interface;
|
|
||||||
using Yi.Framework.WebCore;
|
|
||||||
|
|
||||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
|
||||||
{
|
|
||||||
|
|
||||||
[Route("api/[controller]/[action]")]
|
|
||||||
public class FileController : Controller
|
|
||||||
{
|
|
||||||
private IUserService _userService;
|
|
||||||
public FileController(IUserService userService)
|
|
||||||
{
|
|
||||||
_userService = userService;
|
|
||||||
}
|
|
||||||
//[HttpGet]
|
|
||||||
//[Route("{type}/{imageNmae}")]
|
|
||||||
//public IActionResult Get(string type, string imageNmae)
|
|
||||||
//{
|
|
||||||
// return new FileStreamResult();
|
|
||||||
//}
|
|
||||||
|
|
||||||
//[HttpPost]
|
|
||||||
//[Route("{type}/{imageNmae}")]
|
|
||||||
//public IActionResult Upload(string type,List<IFormFile> files )
|
|
||||||
//{
|
|
||||||
// HttpContext.Request[""];
|
|
||||||
// return new FileStreamResult();
|
|
||||||
//}
|
|
||||||
[HttpGet]
|
|
||||||
public async Task<IActionResult> GetFile()
|
|
||||||
{
|
|
||||||
var userdata = await _userService.GetAllEntitiesTrueAsync();
|
|
||||||
var userList = userdata.ToList();
|
|
||||||
Dictionary<string, string> dt = new ();
|
|
||||||
dt.Add("sc", "user");
|
|
||||||
var bt = Excel.ExportExcel(userList, dt);
|
|
||||||
MemoryStream ms = new(bt);
|
|
||||||
return new FileStreamResult(ms, "application/vnd.ms-excel");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -29,6 +29,21 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
{
|
{
|
||||||
return Result.Success().SetData(await _roleService.GetAllEntitiesTrueAsync());
|
return Result.Success().SetData(await _roleService.GetAllEntitiesTrueAsync());
|
||||||
}
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> GetRoleFlie()
|
||||||
|
{
|
||||||
|
var roleList = await _roleService.GetAllEntitiesTrueAsync();
|
||||||
|
Dictionary<string, string> dt = new();
|
||||||
|
dt.Add("输出", "文件");
|
||||||
|
var byteStream = Excel.ExportExcel(roleList.ToList(), dt).ToString();
|
||||||
|
MemoryStream s = new MemoryStream();
|
||||||
|
StreamWriter writer = new StreamWriter(s);
|
||||||
|
writer.Write(byteStream);
|
||||||
|
writer.Flush();
|
||||||
|
//stream.Read(byteStream, 0, byteStream.Length);
|
||||||
|
return new FileStreamResult(s, "application/vnd.ms-excel");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更
|
/// 更
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -92,13 +107,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用于给角色设置菜单的时候,点击一个角色,显示这个角色拥有的并列的菜单
|
/// 用于给角色设置菜单的时候,点击一个角色,显示这个角色拥有的并列的菜单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId"></param>
|
/// <param name="role"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<Result> GetTopMenusByRoleId(int roleId)
|
public async Task<Result> GetTopMenusByRoleId(role role)
|
||||||
{
|
{
|
||||||
|
|
||||||
return Result.Success().SetData(await _roleService.GetTopMenusByRoleId(roleId) ); ;
|
return Result.Success().SetData(await _roleService.GetTopMenusByRoleId(role.id) ); ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
private readonly ILogger<UserController> _logger;
|
private readonly ILogger<UserController> _logger;
|
||||||
|
|
||||||
private IUserService _userService;
|
private IUserService _userService;
|
||||||
private IMenuService _menuService;
|
public UserController(ILogger<UserController> logger, IUserService userService)
|
||||||
public UserController(ILogger<UserController> logger, IUserService userService, IMenuService menuService)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
_menuService = menuService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -122,19 +120,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<Result> GetAxiosByRouter(string router)
|
public async Task<Result> GetAxiosByRouter(string router)
|
||||||
{
|
{
|
||||||
var _user = HttpContext.GetCurrentUserInfo();
|
var _user = HttpContext.GetCurrentUserInfo(out List<int> menuIds);
|
||||||
var menuList = await _menuService.GetTopMenuByUserId(_user.id);
|
var menuList= await _userService.GetAxiosByRouter(router, _user.id, menuIds);
|
||||||
if (menuList == null)
|
|
||||||
{
|
|
||||||
return Result.Error();
|
|
||||||
}
|
|
||||||
List<int> menuIds = new();
|
|
||||||
menuList.ForEach(u =>
|
|
||||||
{
|
|
||||||
var id = u.id;
|
|
||||||
menuIds.Add(id);
|
|
||||||
});
|
|
||||||
var childrenList = await _userService.GetAxiosByRouter(router, _user.id, menuIds);
|
|
||||||
AxiosUrlsModel urlsModel = new();
|
AxiosUrlsModel urlsModel = new();
|
||||||
menuList.ForEach(u =>
|
menuList.ForEach(u =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,9 +24,4 @@
|
|||||||
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="wwwroot\imgae\" />
|
|
||||||
<Folder Include="wwwroot\file\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Yi.Framework.Core
|
|||||||
public class jwtUser
|
public class jwtUser
|
||||||
{
|
{
|
||||||
public user user { get; set; }
|
public user user { get; set; }
|
||||||
//public List<menu> menuIds { get; set; }
|
public List<menu> menuIds { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,14 +37,14 @@ namespace Yi.Framework.Core
|
|||||||
claims.Add(new Claim(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(DateTime.Now.AddMinutes(30)).ToUnixTimeSeconds()}"));
|
claims.Add(new Claim(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(DateTime.Now.AddMinutes(30)).ToUnixTimeSeconds()}"));
|
||||||
claims.Add(new Claim(ClaimTypes.Name, _user.user.username));
|
claims.Add(new Claim(ClaimTypes.Name, _user.user.username));
|
||||||
claims.Add(new Claim(ClaimTypes.Sid, _user.user.id.ToString()));
|
claims.Add(new Claim(ClaimTypes.Sid, _user.user.id.ToString()));
|
||||||
//foreach (var k in _user.menuIds)
|
foreach (var k in _user.menuIds)
|
||||||
//{
|
{
|
||||||
// claims.Add(new Claim("menuIds",k.id.ToString()));
|
claims.Add(new Claim("menuIds",k.id.ToString()));
|
||||||
//}
|
}
|
||||||
//foreach (var k in _user.user.roles)
|
foreach (var k in _user.user.roles)
|
||||||
//{
|
{
|
||||||
// claims.Add(new Claim(ClaimTypes.Role, k.role_name));
|
claims.Add(new Claim(ClaimTypes.Role, k.role_name));
|
||||||
//}
|
}
|
||||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey));
|
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey));
|
||||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||||
|
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ export default {
|
|||||||
|
|
||||||
isPasswordVisible: false,
|
isPasswordVisible: false,
|
||||||
form: {
|
form: {
|
||||||
username: "admin",
|
username: "",
|
||||||
password: "123",
|
password: "",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
Reference in New Issue
Block a user