@@ -40,11 +40,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public async Task<Result> Login(user _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)
|
||||
{
|
||||
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.Error();
|
||||
@@ -149,16 +148,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
user_data.nick = pwdDto.user.nick;
|
||||
|
||||
await _userService.UpdateAsync(user_data);
|
||||
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,22 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public async Task<Result> GetRole()
|
||||
{
|
||||
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>
|
||||
@@ -92,13 +107,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <summary>
|
||||
/// 用于给角色设置菜单的时候,点击一个角色,显示这个角色拥有的并列的菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <param name="role"></param>
|
||||
/// <returns></returns>
|
||||
[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 IUserService _userService;
|
||||
private IMenuService _menuService;
|
||||
public UserController(ILogger<UserController> logger, IUserService userService, IMenuService menuService)
|
||||
public UserController(ILogger<UserController> logger, IUserService userService)
|
||||
{
|
||||
_logger = logger;
|
||||
_userService = userService;
|
||||
_menuService = menuService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,19 +120,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpGet]
|
||||
public async Task<Result> GetAxiosByRouter(string router)
|
||||
{
|
||||
var _user = HttpContext.GetCurrentUserInfo();
|
||||
var menuList = await _menuService.GetTopMenuByUserId(_user.id);
|
||||
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);
|
||||
var _user = HttpContext.GetCurrentUserInfo(out List<int> menuIds);
|
||||
var menuList= await _userService.GetAxiosByRouter(router, _user.id, menuIds);
|
||||
AxiosUrlsModel urlsModel = new();
|
||||
menuList.ForEach(u =>
|
||||
{
|
||||
|
||||
@@ -24,9 +24,4 @@
|
||||
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\imgae\" />
|
||||
<Folder Include="wwwroot\file\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Yi.Framework.Core
|
||||
public class jwtUser
|
||||
{
|
||||
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(ClaimTypes.Name, _user.user.username));
|
||||
claims.Add(new Claim(ClaimTypes.Sid, _user.user.id.ToString()));
|
||||
//foreach (var k in _user.menuIds)
|
||||
//{
|
||||
// claims.Add(new Claim("menuIds",k.id.ToString()));
|
||||
//}
|
||||
//foreach (var k in _user.user.roles)
|
||||
//{
|
||||
// claims.Add(new Claim(ClaimTypes.Role, k.role_name));
|
||||
//}
|
||||
foreach (var k in _user.menuIds)
|
||||
{
|
||||
claims.Add(new Claim("menuIds",k.id.ToString()));
|
||||
}
|
||||
foreach (var k in _user.user.roles)
|
||||
{
|
||||
claims.Add(new Claim(ClaimTypes.Role, k.role_name));
|
||||
}
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(JwtConst.SecurityKey));
|
||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@ export default {
|
||||
|
||||
isPasswordVisible: false,
|
||||
form: {
|
||||
username: "admin",
|
||||
password: "123",
|
||||
username: "",
|
||||
password: "",
|
||||
},
|
||||
}),
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user