Compare commits

..

13 Commits

Author SHA1 Message Date
橙子
ada36ebff5 Update README.md 2022-05-01 18:33:04 +08:00
橙子
d9543ca23c 添加修改密码及用户信息 2022-05-01 18:31:06 +08:00
橙子
3871eb3c84 Update README.md 2022-04-30 22:14:49 +08:00
橙子
4ba696d289 添加用户简介 2022-04-30 22:12:25 +08:00
橙子
2f69e0b96c 添加前端用户信息展示 2022-04-30 22:04:47 +08:00
橙子
d6b0c56c35 添加登录用户全部信息查询 2022-04-30 21:48:18 +08:00
橙子
d8fe983b9d Update README.md 2022-04-29 12:58:35 +08:00
橙子
76079faca0 Merge branch 'sqlsugar-dev' into sqlsugar 2022-04-29 12:55:33 +08:00
橙子
5d5c62123c 修复代理问题 2022-04-29 12:55:18 +08:00
橙子
6c7b2224b1 完善角色菜单分配管理 2022-04-29 12:38:19 +08:00
橙子
4d80ae2372 Merge branch 'sqlsugar-dev' into sqlsugar 2022-04-29 00:32:00 +08:00
橙子
c651b60c59 完善菜单管理 2022-04-29 00:31:08 +08:00
橙子
90b39d075d 添加菜单查询 2022-04-26 19:21:37 +08:00
31 changed files with 473 additions and 231 deletions

View File

@@ -12,6 +12,8 @@
### 简介: ### 简介:
**中文:意框架**(和他的名字一样“简易”) **中文:意框架**(和他的名字一样“简易”)
正在持续更进业务模块
**英文YiFramework** **英文YiFramework**
Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。 Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。
@@ -20,7 +22,7 @@ Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。
适合.Net6学习、Sqlsugar学习 、项目二次开发。 适合.Net6学习、Sqlsugar学习 、项目二次开发。
集大成者,终究轮子 集大成者,终究轮子
Yi框架最新版本标签`v1.0.5`,具体版本可以查看标签迭代 Yi框架最新版本标签`v1.1.0`,具体版本可以查看标签迭代
项目与Sqlsugar同步更新但这作者老杰哥代码天天爆肝到凌晨两点我们也尽量会跟上他的脚步。更新频繁所以可watching持续关注。 项目与Sqlsugar同步更新但这作者老杰哥代码天天爆肝到凌晨两点我们也尽量会跟上他的脚步。更新频繁所以可watching持续关注。

Binary file not shown.

View File

@@ -9,6 +9,40 @@
账户管理 账户管理
</summary> </summary>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Login(Yi.Framework.DTOModel.LoginDto)">
<summary>
没啥说,登录
</summary>
<param name="loginDto"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Register(Yi.Framework.DTOModel.RegisterDto)">
<summary>
没啥说,注册
</summary>
<param name="registerDto"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.GetUserAllInfo">
<summary>
通过已登录的用户获取用户信息及菜单
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.UpdatePassword(Yi.Framework.DTOModel.UpdatePasswordDto)">
<summary>
更新登录的用户密码
</summary>
<param name="updatePasswordDto"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.UpdateUserByHttp(Yi.Framework.Model.Models.UserEntity)">
<summary>
更新已登录用户的用户信息
</summary>
<param name="user"></param>
<returns></returns>
</member>
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1"> <member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1">
<summary> <summary>
Json To Sql 类比模式,通用模型 Json To Sql 类比模式,通用模型
@@ -91,6 +125,12 @@
<param name="giveRoleSetMenuDto"></param> <param name="giveRoleSetMenuDto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.GetInMenuByRoleId(System.Int64)">
<summary>
通过角色id来获取菜单列表
</summary>
<returns></returns>
</member>
<member name="T:Yi.Framework.ApiMicroservice.Controllers.TestController"> <member name="T:Yi.Framework.ApiMicroservice.Controllers.TestController">
<summary> <summary>
测试控制器 测试控制器

View File

@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yi.Framework.Common.Helper;
using Yi.Framework.Common.Models; using Yi.Framework.Common.Models;
using Yi.Framework.Core; using Yi.Framework.Core;
using Yi.Framework.DTOModel; using Yi.Framework.DTOModel;
@@ -22,9 +23,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// </summary> /// </summary>
[ApiController] [ApiController]
[Route("api/[controller]/[action]")] [Route("api/[controller]/[action]")]
public class AccountController :ControllerBase public class AccountController : ControllerBase
{ {
private IUserService _iUserService; private IUserService _iUserService;
private JwtInvoker _jwtInvoker; private JwtInvoker _jwtInvoker;
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker) public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker)
{ {
@@ -32,18 +33,28 @@ namespace Yi.Framework.ApiMicroservice.Controllers
_jwtInvoker = jwtInvoker; _jwtInvoker = jwtInvoker;
} }
/// <summary>
/// 没啥说,登录
/// </summary>
/// <param name="loginDto"></param>
/// <returns></returns>
[AllowAnonymous] [AllowAnonymous]
[HttpPost] [HttpPost]
public async Task<Result> Login(LoginDto loginDto) public async Task<Result> Login(LoginDto loginDto)
{ {
UserEntity user=new(); UserEntity user = new();
if (await _iUserService.Login(loginDto.UserName, loginDto.Password,o=> user=o)) if (await _iUserService.Login(loginDto.UserName, loginDto.Password, o => user = o))
{ {
return Result.Success("登录成功!").SetData(new { user, token = _jwtInvoker.GetAccessToken(user)}); return Result.Success("登录成功!").SetData(new { user, token = _jwtInvoker.GetAccessToken(user) });
} }
return Result.SuccessError("登录失败!用户名或者密码错误!"); return Result.SuccessError("登录失败!用户名或者密码错误!");
} }
/// <summary>
/// 没啥说,注册
/// </summary>
/// <param name="registerDto"></param>
/// <returns></returns>
[AllowAnonymous] [AllowAnonymous]
[HttpPost] [HttpPost]
public async Task<Result> Register(RegisterDto registerDto) public async Task<Result> Register(RegisterDto registerDto)
@@ -55,5 +66,59 @@ namespace Yi.Framework.ApiMicroservice.Controllers
} }
return Result.SuccessError("注册失败!用户名已存在!"); return Result.SuccessError("注册失败!用户名已存在!");
} }
/// <summary>
/// 通过已登录的用户获取用户信息及菜单
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<Result> GetUserAllInfo()
{
//通过鉴权jwt获取到用户的id
var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id;
return Result.Success().SetData(await _iUserService.GetUserAllInfo(userId));
}
/// <summary>
/// 更新登录的用户密码
/// </summary>
/// <param name="updatePasswordDto"></param>
/// <returns></returns>
[HttpPut]
public async Task<Result> UpdatePassword(UpdatePasswordDto updatePasswordDto)
{
var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id;
var userEntiy = await _iUserService._repository.GetByIdAsync(userId);
//判断输入的老密码是否和原密码相同
if (_iUserService.JudgePassword(userEntiy, updatePasswordDto.OldPassword))
{
userEntiy.Password = updatePasswordDto.NewPassword;
userEntiy.BuildPassword();
return Result.Success().SetStatus(await _iUserService._repository.UpdateAsync(userEntiy));
}
return Result.SuccessError("原密码错误!");
}
/// <summary>
/// 更新已登录用户的用户信息
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
[HttpPut]
public async Task<Result> UpdateUserByHttp(UserEntity user)
{
//当然,密码是不能给他修改的
user.Password = null;
user.Salt = null;
//修改需要赋值上主键哦
user.Id = HttpContext.GetCurrentUserEntityInfo(out _).Id;
return Result.Success().SetStatus(await _iUserService._repository.UpdateIgnoreNullAsync(user));
}
} }
} }

View File

@@ -28,15 +28,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers
_iMenuService = iMenuService; _iMenuService = iMenuService;
} }
/// <summary> /// <summary>
/// 得到树形菜单 /// 得到树形菜单
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
//暂未制作逻辑删除与多租户的过滤 //暂未制作逻辑删除与多租户的过滤
public async Task<List<MenuEntity>> GetMenuTree() public async Task<Result> GetMenuTree()
{ {
return await _iMenuService.GetMenuTreeAsync(); return Result.Success().SetData(await _iMenuService. GetMenuTreeAsync());
} }
} }
} }

View File

@@ -40,6 +40,14 @@ namespace Yi.Framework.ApiMicroservice.Controllers
return Result.Success().SetStatus(await _iRoleService.GiveRoleSetMenu(giveRoleSetMenuDto.RoleIds, giveRoleSetMenuDto.MenuIds)); return Result.Success().SetStatus(await _iRoleService.GiveRoleSetMenu(giveRoleSetMenuDto.RoleIds, giveRoleSetMenuDto.MenuIds));
} }
/// <summary>
/// 通过角色id来获取菜单列表
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<Result> GetInMenuByRoleId(long RoleId)
{
return Result.Success().SetData(await _iRoleService.GetInMenuByRoleId(RoleId));
}
} }
} }

View File

@@ -63,7 +63,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
//不建议操作,直接切换其他仓储 //不建议操作,直接切换其他仓储
await _iUserService._repository.ChangeRepository<Repository<RoleEntity>>().GetListAsync(); await _iUserService._repository.ChangeRepository<Repository<RoleEntity>>().GetListAsync();
//直接操作Db对象???恭喜你已经毕业了!此后将有一天,接手到这个的软件的程序员将破口大骂。 //最好不要直接操作Db对象
await _iUserService._repository._Db.Queryable<UserEntity>().ToListAsync(); await _iUserService._repository._Db.Queryable<UserEntity>().ToListAsync();
return Result.Success().SetData(await _iUserService.DbTest()); return Result.Success().SetData(await _iUserService.DbTest());

View File

@@ -41,7 +41,7 @@
"PolicyName": "permission", "PolicyName": "permission",
"DefaultScheme": "Bearer", "DefaultScheme": "Bearer",
"IsHttps": false, "IsHttps": false,
"Expiration": 30, "Expiration": 300,
"ReExpiration": 3000 "ReExpiration": 3000
}, },
"RedisConnOptions": { "RedisConnOptions": {

View File

@@ -36,6 +36,14 @@ namespace Yi.Framework.Common.Models
} }
public Result SetStatus(bool _status) public Result SetStatus(bool _status)
{ {
if (_status)
{
this.message = "操作成功";
}
else
{
this.message = "操作失败";
}
this.status = _status; this.status = _status;
return this; return this;
} }

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DTOModel
{
public class UpdatePasswordDto
{
public string NewPassword { get; set; }
public string OldPassword { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Model.Models;
namespace Yi.Framework.DTOModel
{
public class UserRoleMenuDto
{
public UserEntity User { get; set; }=new ();
public HashSet<RoleEntity> Roles { get; set; } = new();
public HashSet<MenuEntity> Menus { get; set; }=new();
}
}

View File

@@ -13,6 +13,13 @@ namespace Yi.Framework.Interface
/// <returns></returns> /// <returns></returns>
Task<List<RoleEntity>> DbTest(); Task<List<RoleEntity>> DbTest();
/// <summary>
/// 通过角色id获取角色实体包含菜单
/// </summary>
/// <param name="roleId"></param>
/// <returns></returns>
Task<RoleEntity> GetInMenuByRoleId(long roleId);
/// <summary> /// <summary>
/// 给角色设置菜单,多角色,多菜单 /// 给角色设置菜单,多角色,多菜单
/// </summary> /// </summary>

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yi.Framework.DTOModel;
using Yi.Framework.Model.Models; using Yi.Framework.Model.Models;
using Yi.Framework.Repository; using Yi.Framework.Repository;
@@ -59,5 +60,20 @@ namespace Yi.Framework.Interface
/// <param name="userId"></param> /// <param name="userId"></param>
/// <returns></returns> /// <returns></returns>
Task<List<RoleEntity>> GetRoleListByUserId(long userId); Task<List<RoleEntity>> GetRoleListByUserId(long userId);
/// <summary>
/// 获取当前登录用户的所有信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
Task<UserRoleMenuDto> GetUserAllInfo(long userId);
/// <summary>
/// 判断用户密码是否和原密码相同
/// </summary>
/// <param name="user"></param>
/// <param name="password"></param>
/// <returns></returns>
bool JudgePassword(UserEntity user, string password);
} }
} }

View File

@@ -32,7 +32,7 @@ namespace Yi.Framework.Model.Models
/// <summary> /// <summary>
/// ///
///</summary> ///</summary>
[SugarColumn(ColumnName="MenuCode" )] [SugarColumn(ColumnName= "PermissionCode")]
public string PermissionCode { get; set; } public string PermissionCode { get; set; }
/// <summary> /// <summary>
/// ///

View File

@@ -16,9 +16,7 @@ namespace Yi.Framework.Model.Models
this.IsDeleted = false; this.IsDeleted = false;
this.CreateTime = DateTime.Now; this.CreateTime = DateTime.Now;
} }
[JsonConverter(typeof(ValueToStringConverter))]
[Newtonsoft.Json.JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )] [SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
public long Id { get; set; } public long Id { get; set; }
/// <summary> /// <summary>
@@ -106,5 +104,10 @@ namespace Yi.Framework.Model.Models
///</summary> ///</summary>
[SugarColumn(ColumnName="Phone" )] [SugarColumn(ColumnName="Phone" )]
public string Phone { get; set; } public string Phone { get; set; }
/// <summary>
///
///</summary>
[SugarColumn(ColumnName="Introduction" )]
public string Introduction { get; set; }
} }
} }

View File

@@ -10,5 +10,7 @@ namespace Yi.Framework.Model.Models
{ {
//[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.RoleId), nameof(UserRoleEntity.UserId))] //[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.RoleId), nameof(UserRoleEntity.UserId))]
//public List<UserEntity> Users { get; set; } //public List<UserEntity> Users { get; set; }
[Navigate(typeof(RoleMenuEntity),nameof(RoleMenuEntity.RoleId),nameof(RoleMenuEntity.MenuId))]
public List<MenuEntity> Menus { get; set; }
} }
} }

View File

@@ -1,16 +1,15 @@
using SqlSugar; //using SqlSugar;
using Yi.Framework.Common.Models; //using Yi.Framework.Common.Models;
using Yi.Framework.Model.Models; //using Yi.Framework.Model.Models;
namespace Yi.Framework.Repository //namespace Yi.Framework.Repository
{ //{
public class DataContext<T> : SimpleClient<T> where T : class, IBaseModelEntity, new() // public class DataContext<T> : SimpleClient<T> where T : class, IBaseModelEntity, new()
{ // {
public DataContext(ISqlSugarClient context) : base(context) // public DataContext(ISqlSugarClient context) : base(context)
{ // {
Db =base.Context; // }
}
public ISqlSugarClient Db; // }
} //}
} //简化已被弃用

View File

@@ -23,6 +23,6 @@ namespace Yi.Framework.Repository
public Task<bool> UpdateIgnoreNullAsync(T entity); public Task<bool> UpdateIgnoreNullAsync(T entity);
public Task<List<S>> UseSqlAsync<S>(string sql); public Task<List<S>> UseSqlAsync<S>(string sql);
public Task<bool> UseSqlAsync(string sql); public Task<bool> UseSqlAsync(string sql);
ISugarQueryable<T> QueryConditionHandler(QueryCondition pars);
} }
} }

View File

@@ -12,16 +12,15 @@ namespace Yi.Framework.Repository
/// 仓储模式 /// 仓储模式
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public class Repository<T> : DataContext<T>, IRepository<T> where T : class, IBaseModelEntity, new() public class Repository<T> : SimpleClient<T>, IRepository<T> where T : class, IBaseModelEntity, new()
{ {
public ISqlSugarClient _Db { get; set; } public ISqlSugarClient _Db { get { return base.Context; } set { } }
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
/// <param name="context"></param> /// <param name="context"></param>
public Repository(ISqlSugarClient context) : base(context)//注意这里要有默认值等于null public Repository(ISqlSugarClient context) : base(context)//注意这里要有默认值等于null
{ {
_Db = context;
} }
/// <summary> /// <summary>
@@ -31,7 +30,8 @@ namespace Yi.Framework.Repository
/// <returns></returns> /// <returns></returns>
public async Task<bool> UseTranAsync(Func<Task> func) public async Task<bool> UseTranAsync(Func<Task> func)
{ {
var res = await Db.AsTenant().UseTranAsync(func); var con = Context;
var res = await _Db.AsTenant().UseTranAsync(func);
return res.IsSuccess; return res.IsSuccess;
} }
@@ -44,7 +44,7 @@ namespace Yi.Framework.Repository
/// <returns></returns> /// <returns></returns>
public async Task<List<S>> UseSqlAsync<S>(string sql) public async Task<List<S>> UseSqlAsync<S>(string sql)
{ {
return await Db.Ado.SqlQueryAsync<S>(sql); return await _Db.Ado.SqlQueryAsync<S>(sql);
} }
@@ -55,7 +55,7 @@ namespace Yi.Framework.Repository
/// <returns></returns> /// <returns></returns>
public async Task<bool> UseSqlAsync(string sql) public async Task<bool> UseSqlAsync(string sql)
{ {
return await Db.Ado.ExecuteCommandAsync(sql)>0; return await _Db.Ado.ExecuteCommandAsync(sql)>0;
} }
@@ -68,7 +68,7 @@ namespace Yi.Framework.Repository
public async Task<T> InsertReturnEntityAsync(T entity) public async Task<T> InsertReturnEntityAsync(T entity)
{ {
entity.Id =SnowFlakeSingle.instance.getID(); entity.Id =SnowFlakeSingle.instance.getID();
return await Db.Insertable(entity).ExecuteReturnEntityAsync(); return await _Db.Insertable(entity).ExecuteReturnEntityAsync();
} }
/// <summary> /// <summary>
@@ -78,7 +78,7 @@ namespace Yi.Framework.Repository
/// <returns></returns> /// <returns></returns>
public async Task<bool> UpdateIgnoreNullAsync(T entity) public async Task<bool> UpdateIgnoreNullAsync(T entity)
{ {
return await Db.Updateable(entity).IgnoreColumns(true).ExecuteCommandAsync()>0; return await _Db.Updateable(entity).IgnoreColumns(true).ExecuteCommandAsync()>0;
} }
@@ -88,9 +88,9 @@ namespace Yi.Framework.Repository
/// <returns></returns> /// <returns></returns>
public async Task<bool> DeleteByLogicAsync(List<long> ids) public async Task<bool> DeleteByLogicAsync(List<long> ids)
{ {
var entitys = await Db.Queryable<T>().Where(u => ids.Contains(u.Id)).ToListAsync(); var entitys = await _Db.Queryable<T>().Where(u => ids.Contains(u.Id)).ToListAsync();
entitys.ForEach(u=>u.IsDeleted=true); entitys.ForEach(u=>u.IsDeleted=true);
return await Db.Updateable(entitys).ExecuteCommandAsync()>0; return await _Db.Updateable(entitys).ExecuteCommandAsync()>0;
} }
@@ -103,7 +103,7 @@ namespace Yi.Framework.Repository
/// <returns></returns> /// <returns></returns>
public async Task<List<S>> StoreAsync<S>(string storeName, object para) public async Task<List<S>> StoreAsync<S>(string storeName, object para)
{ {
return await Db.Ado.UseStoredProcedure().SqlQueryAsync<S>(storeName, para); return await _Db.Ado.UseStoredProcedure().SqlQueryAsync<S>(storeName, para);
} }
@@ -134,7 +134,7 @@ namespace Yi.Framework.Repository
private ISugarQueryable<T> QueryConditionHandler(QueryCondition pars) public ISugarQueryable<T> QueryConditionHandler(QueryCondition pars)
{ {
var sugarParamters = pars.Parameters.Select(it => (IConditionalModel)new ConditionalModel() var sugarParamters = pars.Parameters.Select(it => (IConditionalModel)new ConditionalModel()
{ {
@@ -142,7 +142,7 @@ namespace Yi.Framework.Repository
FieldName = it.Key, FieldName = it.Key,
FieldValue = it.Value FieldValue = it.Value
}).ToList(); }).ToList();
var query = Db.Queryable<T>(); var query = _Db.Queryable<T>();
if (pars.OrderBys != null) if (pars.OrderBys != null)
{ {
foreach (var item in pars.OrderBys) foreach (var item in pars.OrderBys)

View File

@@ -13,7 +13,7 @@ namespace Yi.Framework.Service
{ {
//ParentId 0,代表为根目录,只能存在一个 //ParentId 0,代表为根目录,只能存在一个
//复杂查询直接使用db代理 //复杂查询直接使用db代理
return await _repository._Db.Queryable<MenuEntity>().ToTreeAsync(it=>it.Children,it=>it.ParentId,0); return await _repository._Db.Queryable<MenuEntity>().Where(u=>u.IsDeleted==false).ToTreeAsync(it=>it.Children,it=>it.ParentId,0);
} }
} }
} }

View File

@@ -15,8 +15,7 @@ namespace Yi.Framework.Service
} }
public async Task<bool> GiveRoleSetMenu(List<long> roleIds, List<long> menuIds) public async Task<bool> GiveRoleSetMenu(List<long> roleIds, List<long> menuIds)
{ {
var _repositoryRoleMenu = _repository.ChangeRepository<Repository<RoleMenuEntity>>(); var _repositoryRoleMenu= _repository.ChangeRepository<Repository<RoleMenuEntity>>();
//多次操作,需要事务确保原子性 //多次操作,需要事务确保原子性
return await _repositoryRoleMenu.UseTranAsync(async () => return await _repositoryRoleMenu.UseTranAsync(async () =>
{ {
@@ -35,12 +34,17 @@ namespace Yi.Framework.Service
} }
//一次性批量添加 //一次性批量添加
await _repositoryRoleMenu.InsertRangeAsync(roleMenuEntity); await _repositoryRoleMenu.InsertReturnSnowflakeIdAsync(roleMenuEntity);
} }
}); });
} }
public async Task<RoleEntity> GetInMenuByRoleId(long roleId)
{
return await _repository._Db.Queryable<RoleEntity>().Includes(u => u.Menus).InSingleAsync(roleId);
}
} }
} }

View File

@@ -3,6 +3,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yi.Framework.Common.Helper;
using Yi.Framework.DTOModel;
using Yi.Framework.Interface; using Yi.Framework.Interface;
using Yi.Framework.Model.Models; using Yi.Framework.Model.Models;
using Yi.Framework.Repository; using Yi.Framework.Repository;
@@ -92,7 +94,7 @@ namespace Yi.Framework.Service
} }
//一次性批量添加 //一次性批量添加
await _repositoryUserRole.InsertRangeAsync(userRoleEntities); await _repositoryUserRole.InsertReturnSnowflakeIdAsync(userRoleEntities);
} }
}); });
} }
@@ -102,5 +104,44 @@ namespace Yi.Framework.Service
{ {
return (await _repository._Db.Queryable<UserEntity>().Includes(u => u.Roles).InSingleAsync(userId)).Roles; return (await _repository._Db.Queryable<UserEntity>().Includes(u => u.Roles).InSingleAsync(userId)).Roles;
} }
public async Task<UserRoleMenuDto> GetUserAllInfo(long userId)
{
var userRoleMenu = new UserRoleMenuDto();
//首先获取到该用户全部信息,导航到角色、菜单,(菜单需要去重,完全交给Set来处理即可)
//得到用户
var user = await _repository._Db.Queryable<UserEntity>().Includes(u => u.Roles, r => r.Menus).InSingleAsync(userId);
//得到角色集合
var roleList = user.Roles;
//得到菜单集合
foreach (var role in roleList)
{
foreach (var menu in role.Menus)
{
userRoleMenu.Menus.Add(menu);
}
//刚好可以去除一下多余的导航属性
role.Menus = null;
userRoleMenu.Roles.Add(role);
}
user.Roles = null;
userRoleMenu.User = user;
return userRoleMenu;
}
public bool JudgePassword(UserEntity user,string password)
{
if (user.Password == MD5Helper.SHA2Encode(password, user.Salt))
{
return true;
}
return false;
}
} }
} }

View File

@@ -8,6 +8,7 @@ using System.Security.Claims;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Yi.Framework.Model.Models; using Yi.Framework.Model.Models;
using System.IdentityModel.Tokens.Jwt;
namespace Yi.Framework.WebCore namespace Yi.Framework.WebCore
{ {
@@ -32,17 +33,22 @@ namespace Yi.Framework.WebCore
/// <returns></returns> /// <returns></returns>
public static UserEntity GetCurrentUserEntityInfo(this HttpContext httpContext, out List<Guid> menuIds) public static UserEntity GetCurrentUserEntityInfo(this HttpContext httpContext, out List<Guid> menuIds)
{ {
IEnumerable<Claim> claimlist = httpContext.AuthenticateAsync().Result.Principal.Claims; IEnumerable<Claim> claimlist = null;
long resId = 0;
long.TryParse(claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Sid).Value,out var resId) ; try
{
claimlist = httpContext.AuthenticateAsync().Result.Principal.Claims;
resId = Convert.ToInt64(claimlist.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Sid).Value);
}
catch
{
throw new Exception("未授权Token鉴权失败");
}
menuIds = claimlist.Where(u => u.Type == "menuIds").ToList().Select(u => new Guid(u.Value)).ToList(); menuIds = claimlist.Where(u => u.Type == "menuIds").ToList().Select(u => new Guid(u.Value)).ToList();
return new UserEntity() return new UserEntity()
{ {
Id = resId, Id = resId,
Name = claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Name).Value //Name = claimlist.FirstOrDefault(u => u.Type == JwtRegisteredClaimNames.Name).Value
}; };
} }
} }

View File

@@ -35,12 +35,28 @@ export default {
method: 'post', method: 'post',
}) })
}, },
changePassword(user, newPassword) { updatePassword(oldPassword, newPassword) {
return myaxios({ return myaxios({
url: `/Account/changePassword`, url: `/Account/updatePassword`,
method: 'put', method: 'put',
data: { user, newPassword } data: { oldPassword, newPassword }
}) })
},
getUserAllInfo()
{
return myaxios({
url: `/Account/getUserAllInfo`,
method: 'get'
})
},
updateUserByHttp(user)
{
return myaxios({
url: `/Account/updateUserByHttp`,
method: 'put',
data:user
})
} }
} }

View File

@@ -1,50 +1,30 @@
import myaxios from '@/util/myaxios' import myaxios from '@/util/myaxios'
export default { export default {
GetMenuInMould() { getMenuTree() {
return myaxios({ return myaxios({
url: '/Menu/GetMenuInMould', url: '/Menu/getMenuTree',
method: 'get' method: 'get'
}) })
}, },
addChildrenMenu(id, data) { Update(data) {
return myaxios({ return myaxios({
url: '/Menu/addChildrenMenu', url: '/Menu/Update',
method: 'post',
data: { parentId: id, data }
})
},
UpdateMenu(data) {
return myaxios({
url: '/Menu/UpdateMenu',
method: 'put', method: 'put',
data: data data: data
}) })
}, },
DelListMenu(ids) { DeleteList(ids) {
return myaxios({ return myaxios({
url: '/Menu/DelListMenu', url: '/Menu/DeleteList',
method: 'delete', method: 'delete',
data: ids data: ids
}) })
}, },
AddTopMenu(data) { Add(data) {
return myaxios({ return myaxios({
url: '/Menu/AddTopMenu', url: '/Menu/Add',
method: 'post', method: 'post',
data: data data: data
}) })
},
SetMouldByMenu(menuId, mouldId) {
return myaxios({
url: '/Menu/SetMouldByMenu',
method: 'post',
data: { id1: menuId, id2: mouldId }
})
},
GetTopMenusByHttpUser() {
return myaxios({
url: '/Menu/GetTopMenusByHttpUser',
method: 'get'
})
} }
} }

View File

@@ -1,23 +1,36 @@
import myaxios from '@/util/myaxios' import myaxios from '@/util/myaxios'
export default { export default {
getRole() { getList() {
return myaxios({ return myaxios({
url: '/Role/getRole', url: '/Role/GetList',
method: 'get'
})
},
setMenuByRole(roleList, menuList) {
return myaxios({
url: '/Role/setMenuByRole',
method: 'post', method: 'post',
data: { ids1: roleList, ids2: menuList } data: {
parameters: [
{
key: "isDeleted",
value: "0",
type: 0
}
],
orderBys: [
"id"
]
}
}) })
}, },
GetTopMenusByRoleId(roleId) { giveRoleSetMenu(roleList, menuList) {
return myaxios({ return myaxios({
url: `/Role/GetTopMenusByRoleId?roleId=${roleId}`, url: '/Role/GiveRoleSetMenu',
method: 'get' method: 'put',
data: { RoleIds: roleList, menuIds: menuList }
})
},
getInMenuByRoleId(roleId) {
return myaxios({
url: `/Role/GetInMenuByRoleId?roleId=${roleId}`,
method: 'get'
}) })
} }

View File

@@ -1,14 +1,11 @@
<template> <template>
<div> <div>
<v-divider></v-divider> <v-divider></v-divider>
<app-btn dark class="ma-4" @click="showAll"> 展开全部</app-btn> <app-btn dark class="ma-4" @click="showAll"> 展开全部</app-btn>
<app-btn dark class="my-4 mr-4" @click="dialog = true"> 添加新项 </app-btn> <app-btn dark class="my-4 mr-4" @click="dialog = true"> 添加新项 </app-btn>
<app-btn dark class="my-4" color="secondary" @click="deleteItem(null)"> <app-btn dark class="my-4" color="secondary" @click="deleteItem(null)">
删除所选 删除所选
</app-btn> </app-btn>
<v-dialog v-model="dialog" max-width="500px"> <v-dialog v-model="dialog" max-width="500px">
<v-card> <v-card>
@@ -53,15 +50,16 @@
return-object return-object
open-all open-all
hoverable hoverable
item-text="menu_name" item-text="menuName"
> >
<template v-slot:append="{ item }"> <template v-slot:append="{ item }">
<v-btn class="mr-2">编号:{{ item.id }}</v-btn> <v-btn class="mr-2">编号:{{ item.id }}</v-btn>
<v-btn class="mr-2">图标:{{ item.icon }}</v-btn> <v-btn class="mr-2">权限:{{ item.permissionCode }}</v-btn>
<v-btn class="mr-2">路由:{{ item.router }}</v-btn> <!-- <v-btn class="mr-2">图标:{{ item.icon }}</v-btn> -->
<v-btn v-if="item.mould" class="mr-2">接口名:{{ item.mould.mould_name }}</v-btn> <!-- <v-btn class="mr-2">路由:{{ item.router }}</v-btn> -->
<v-btn v-if="item.mould" class="mr-2" color="secondary">接口地址:{{ item.mould.url }}</v-btn> <!-- <v-btn v-if="item.mould" class="mr-2">接口:{{ item.mould.mould_name }}</v-btn>
<ccCombobox <v-btn v-if="item.mould" class="mr-2" color="secondary">接口地址:{{ item.mould.url }}</v-btn> -->
<!-- <ccCombobox
headers="设置接口权限" headers="设置接口权限"
itemText="url" itemText="url"
:items="mouldList" :items="mouldList"
@@ -72,24 +70,24 @@
保存</v-btn 保存</v-btn
> >
</template> </template>
</ccCombobox> </ccCombobox> -->
<app-btn <app-btn
@click=" @click="
parentId = item.id; editedItem.parentId = item.id;
dialog = true; dialog = true;
" "
>添加子菜单</app-btn >添加子菜单</app-btn
> >
<app-btn class="mx-2" @click="editItem(item)">编辑</app-btn> <app-btn class="mx-2" @click="editItem(item)">编辑</app-btn>
<app-btn color="secondary" class="mr-2" @click="deleteItem(item)">删除</app-btn> <app-btn color="secondary" class="mr-2" @click="deleteItem(item)"
>删除</app-btn
>
</template> </template>
</v-treeview> </v-treeview>
</div> </div>
</template> </template>
<script> <script>
import mouldApi from "../api/mouldApi";
import menuApi from "../api/menuApi"; import menuApi from "../api/menuApi";
export default { export default {
name: "ccTreeview", name: "ccTreeview",
@@ -103,12 +101,12 @@ export default {
dialog: false, dialog: false,
editedItem: {}, editedItem: {},
editedIndex: -1, editedIndex: -1,
parentId: 0,
defaultItem: { defaultItem: {
icon: "mdi-start", // icon: "mdi-start",
router: "test", permissionCode: "test",
menu_name: "测试", menuName: "管理",
is_show:1 parentId: 0,
MenuType:0
}, },
}), }),
computed: { computed: {
@@ -120,25 +118,25 @@ export default {
this.init(); this.init();
}, },
methods: { methods: {
showAll(){ showAll() {
this.$refs.tree.updateAll(true); this.$refs.tree.updateAll(true);
},
setMould(item) {
menuApi.SetMouldByMenu(item.id, this.mouldSelect[0].id).then((resp) => {
this.$dialog.notify.info(resp.msg, {
position: "top-right",
timeout: 5000,
});
this.init();
});
}, },
// setMould(item) {
// menuApi.SetMouldByMenu(item.id, this.mouldSelect[0].id).then((resp) => {
// this.$dialog.notify.info(resp.msg, {
// position: "top-right",
// timeout: 5000,
// });
// this.init();
// });
// },
getSelect(data) { getSelect(data) {
this.mouldSelect = data; this.mouldSelect = data;
}, },
async deleteItem(item) { async deleteItem(item) {
this.editedIndex = this.desserts.indexOf(item); this.editedIndex = 1;
this.editedItem = Object.assign({}, item); this.editedItem = Object.assign({}, item);
var p = await this.$dialog.warning({ var p = await this.$dialog.warning({
text: "你确定要删除此条记录吗??", text: "你确定要删除此条记录吗??",
@@ -161,7 +159,7 @@ showAll(){
Ids.push(item.id); Ids.push(item.id);
}); });
} }
menuApi.DelListMenu(Ids).then(() => this.init()); menuApi.DeleteList(Ids).then(() => this.init());
}, },
close() { close() {
@@ -173,20 +171,14 @@ showAll(){
}, },
init() { init() {
this.parentId = 0; this.parentId = 0;
mouldApi.getMould().then((resp) => {
this.mouldList = resp.data;
});
menuApi.GetMenuInMould().then((resp) => { menuApi.getMenuTree().then((resp) => {
this.desserts =[ resp.data]; this.desserts = resp.data;
}); });
this.$nextTick(() => { this.$nextTick(() => {
this.editedItem = Object.assign({}, this.defaultItem); this.editedItem = Object.assign({}, this.defaultItem);
this.editedIndex = -1; this.editedIndex = -1;
}); });
}, },
editItem(item) { editItem(item) {
this.editedIndex = item.id; this.editedIndex = item.id;
@@ -196,17 +188,11 @@ showAll(){
save() { save() {
if (this.editedIndex > -1) { if (this.editedIndex > -1) {
menuApi.UpdateMenu(this.editedItem).then(() => this.init()); menuApi.Update(this.editedItem).then(() => this.init());
} else { } else {
if (this.parentId == 0) { menuApi.Add(this.editedItem).then(() => {
menuApi.AddTopMenu(this.editedItem).then(() => {
this.init(); this.init();
}); });
} else {
menuApi.addChildrenMenu(this.parentId, this.editedItem).then(() => {
this.init();
});
}
} }
this.close(); this.close();
}, },

View File

@@ -16,7 +16,7 @@
<v-list :tile="false" flat nav> <v-list :tile="false" flat nav>
<app-bar-item to="/" <app-bar-item to="/"
><v-list-item-title v-text="'用户名:'+$store.state.user.user.username" ><v-list-item-title v-text="'用户名:'+$store.state.user.user.userName"
/></app-bar-item> /></app-bar-item>
<app-bar-item to="/" <app-bar-item to="/"
><v-list-item-title v-text="'称号:'+$store.state.user.user.nick" ><v-list-item-title v-text="'称号:'+$store.state.user.user.nick"
@@ -27,7 +27,7 @@
<template v-for="(p, i) in profile"> <template v-for="(p, i) in profile">
<v-divider v-if="p.divider" :key="`divider-${i}`" class="mb-2 mt-2" /> <v-divider v-if="p.divider" :key="`divider-${i}`" class="mb-2 mt-2" />
<app-bar-item v-else :key="`item-${i}`" to="/"> <app-bar-item v-else :key="`item-${i}`" :to="p.router">
<v-list-item-title v-text="p.title" /> <v-list-item-title v-text="p.title" />
</app-bar-item> </app-bar-item>
</template> </template>
@@ -40,10 +40,10 @@ export default {
name: "DefaultAccount", name: "DefaultAccount",
data: () => ({ data: () => ({
profile: [ profile: [
{ title: "用户信息" }, { title: "用户信息",router:"/userInfo" },
{ title: "设置" }, { title: "设置" },
{ divider: true }, { divider: true },
{ title: "登出" }, { title: "登出",router:"/login" },
], ],
}), }),
}; };

View File

@@ -6,30 +6,28 @@
角色菜单分配管理 角色菜单分配管理
<small class="text-body-1" <small class="text-body-1"
>你可以在这里多角色分配多菜单/选中一个可查看</small >你可以在这里多角色分配多菜单/选中一个可查看</small
> </template >
> </template>
<v-divider></v-divider> <v-divider></v-divider>
<app-btn dark class="ma-4" @click="showAll"> 展开全部</app-btn> <app-btn dark class="ma-4" @click="showAll"> 展开全部</app-btn>
<app-btn class="my-4 mr-4" @click="setMenu">确定分配</app-btn <app-btn class="my-4 mr-4" @click="setMenu">确定分配</app-btn>
>
<app-btn class="my-4" color="secondary" @click="clear"
<app-btn class="my-4" color="secondary" @click="clear">清空选择</app-btn></material-card >清空选择</app-btn
></material-card
> >
</v-col> </v-col>
<v-col cols="12" md="4" lg="4"> <v-col cols="12" md="4" lg="4">
<v-card class="mx-auto" width="100%"> <v-card class="mx-auto" width="100%">
<v-treeview <v-treeview
selectable selectable
:items="RoleItems" :items="RoleItems"
v-model="selectionRole" v-model="selectionRole"
return-object return-object
open-all open-all
hoverable hoverable
item-text="role_name" item-text="roleName"
> >
</v-treeview> </v-treeview>
</v-card> </v-card>
@@ -38,7 +36,7 @@
<v-col cols="12" md="8" lg="8"> <v-col cols="12" md="8" lg="8">
<v-card class="mx-auto" width="100%"> <v-card class="mx-auto" width="100%">
<v-treeview <v-treeview
ref="tree" ref="tree"
open-on-click open-on-click
selectable selectable
:items="Menuitems" :items="Menuitems"
@@ -47,10 +45,10 @@
return-object return-object
open-all open-all
hoverable hoverable
item-text="menu_name" item-text="menuName"
> >
<template v-slot:append="{ item }"> <template v-slot:append="{ item }">
<v-btn>id:{{ item.id }}</v-btn> <v-btn>权限:{{ item.permissionCode }}</v-btn>
</template> </template>
</v-treeview> </v-treeview>
</v-card></v-col </v-card></v-col
@@ -68,8 +66,12 @@ export default {
selectionRole: { selectionRole: {
handler(val, oldVal) { handler(val, oldVal) {
if (val.length == 1) { if (val.length == 1) {
roleApi.GetTopMenusByRoleId(val[0].id).then((resp) => { roleApi.getInMenuByRoleId(val[0].id).then((resp) => {
this.selectionMenu = resp.data; if (resp.data.menus == null) {
this.selectionMenu = [];
} else {
this.selectionMenu = resp.data.menus;
}
}); });
} }
}, },
@@ -77,9 +79,9 @@ export default {
}, },
}, },
methods: { methods: {
showAll(){ showAll() {
this.$refs.tree.updateAll(true); this.$refs.tree.updateAll(true);
}, },
clear() { clear() {
this.selectionMenu = []; this.selectionMenu = [];
this.selectionRole = []; this.selectionRole = [];
@@ -93,20 +95,20 @@ export default {
this.selectionMenu.forEach((ele) => { this.selectionMenu.forEach((ele) => {
menuIds.push(ele.id); menuIds.push(ele.id);
}); });
roleApi.setMenuByRole(roleIds, menuIds).then((resp) => { roleApi.giveRoleSetMenu(roleIds, menuIds).then((resp) => {
this.$dialog.notify.info(resp.msg, { this.$dialog.notify.info(resp.message, {
position: "top-right", position: "top-right",
timeout: 5000, timeout: 5000,
}); });
}); });
}, },
init() { init() {
roleApi.getRole().then((resp) => { roleApi.getList().then((resp) => {
this.RoleItems = resp.data; this.RoleItems = resp.data;
}); });
menuApi.GetMenuInMould().then((resp) => { menuApi.getMenuTree().then((resp) => {
this.Menuitems = [resp.data]; this.Menuitems = resp.data;
}); });
}, },
}, },

View File

@@ -3,23 +3,32 @@
<v-row justify="center"> <v-row justify="center">
<v-col cols="12" md="4"> <v-col cols="12" md="4">
<app-card class="mt-4 text-center"> <app-card class="mt-4 text-center">
<ccAvatar :size="128" class="rounded-circle elevation-6 mt-n12 d-inline-block"></ccAvatar> <ccAvatar
:size="128"
class="rounded-circle elevation-6 mt-n12 d-inline-block"
></ccAvatar>
<v-card-text class="text-center"> <v-card-text class="text-center">
<h6 class="text-h6 mb-2 text--secondary"> <h6 class="text-h6 mb-2 text--secondary">
{{ userInfo.username }} {{ userInfo.userName }}
</h6> </h6>
<h4 class="text-h4 mb-3 text--primary">{{ userInfo.nick }}</h4> <h4 class="text-h4 mb-3 text--primary">{{ userInfo.nick }}</h4>
<p class="text--secondary">{{ userInfo.introduction }}</p> <p class="text--secondary">{{ userInfo.introduction }}</p>
<input <input
type="file" type="file"
ref="imgFile" ref="imgFile"
@change="uploadImage()" @change="uploadImage()"
class="d-none" class="d-none"
/> />
<v-btn class="mr-4" @click="choiceImg" color="primary" min-width="100" rounded> <v-btn
class="mr-4"
@click="choiceImg"
color="primary"
min-width="100"
rounded
>
编辑头像 编辑头像
</v-btn> </v-btn>
<v-btn color="primary" min-width="100" rounded> 绑定QQ </v-btn> <v-btn color="primary" min-width="100" rounded> 绑定QQ </v-btn>
@@ -61,7 +70,7 @@
<v-text-field <v-text-field
color="purple" color="purple"
label="用户名" label="用户名"
v-model="editInfo.username" v-model="editInfo.userName"
disabled disabled
/> />
</v-col> </v-col>
@@ -154,12 +163,12 @@
<v-list-item-subtitle> <v-list-item-subtitle>
<v-row> <v-row>
<v-col <v-col
v-for="item in editInfo.roles" v-for="item in roleInfo"
:key="item.id" :key="item.id"
cols="6" cols="6"
sm="3" sm="3"
md="1" md="1"
>{{ item.role_name }}</v-col >{{ item.roleName }}</v-col
> >
</v-row> </v-row>
</v-list-item-subtitle> </v-list-item-subtitle>
@@ -178,7 +187,7 @@
cols="6" cols="6"
sm="3" sm="3"
md="1" md="1"
>{{ item.menu_name }}</v-col >{{ item.menuName }}</v-col
> >
</v-row> </v-row>
</v-list-item-subtitle> </v-list-item-subtitle>
@@ -230,7 +239,7 @@
<v-text-field <v-text-field
style="width: 80%" style="width: 80%"
label="原密码" label="原密码"
v-model="editInfo.password" v-model="oldPassword"
outlined outlined
clearable clearable
></v-text-field> ></v-text-field>
@@ -264,7 +273,6 @@
<script> <script>
import fileApi from "../api/fileApi"; import fileApi from "../api/fileApi";
import userApi from "../api/userApi"; import userApi from "../api/userApi";
import menuApi from "../api/menuApi";
import accountApi from "../api/accountApi"; import accountApi from "../api/accountApi";
export default { export default {
name: "UserProfileView", name: "UserProfileView",
@@ -273,16 +281,18 @@ export default {
userInfo: {}, userInfo: {},
editInfo: {}, editInfo: {},
newPassword: "", newPassword: "",
oldPassword: "",
dis_newPassword: true, dis_newPassword: true,
roleInfo: [],
menuInfo: [], menuInfo: [],
}), }),
created() { created() {
this.init(); this.init();
}, },
watch: { watch: {
editInfo: { oldPassword: {
handler(val, oldVal) { handler(val, oldVal) {
if (val.password.length > 0) { if (val != "") {
this.dis_newPassword = false; this.dis_newPassword = false;
} else { } else {
this.dis_newPassword = true; this.dis_newPassword = true;
@@ -294,55 +304,56 @@ export default {
methods: { methods: {
save() { save() {
accountApi if (this.newPassword != "") {
.changePassword(this.editInfo, this.newPassword) accountApi
.then((resp) => { .updatePassword(this.oldPassword, this.newPassword)
if (resp.status) { .then((resp) => {
this.$dialog.notify.error(resp.msg, { if (resp.status) {
position: "top-right", this.$dialog.notify.success(resp.message, {
timeout: 5000, position: "top-right",
}); timeout: 5000,
} else { });
this.$dialog.notify.success(resp.msg, { } else {
position: "top-right", this.$dialog.notify.error(resp.message, {
timeout: 5000, position: "top-right",
}); timeout: 5000,
} });
}
this.init();
});
} else {
accountApi.updateUserByHttp(this.editInfo).then((resp) => {
this.init(); this.init();
}); });
}
}, },
init() { init() {
this.newPassword = ""; this.newPassword = "";
userApi.GetUserInRolesByHttpUser().then((resp) => { this.oldPassword = "";
this.userInfo = resp.data; accountApi.getUserAllInfo().then((resp) => {
this.userInfo = resp.data.user;
this.userInfo.password = ""; this.userInfo.password = "";
this.editInfo = Object.assign({}, this.userInfo); this.editInfo = Object.assign({}, this.userInfo);
this.$store.commit('SET_USER',this.userInfo) this.roleInfo = resp.data.roles;
}); this.menuInfo = resp.data.menus;
this.$store.commit("SET_USER", this.userInfo);
menuApi.GetTopMenusByHttpUser().then((resp) => {
this.menuInfo = resp.data;
}); });
}, },
choiceImg() { choiceImg() {
this.$refs.imgFile.dispatchEvent(new MouseEvent("click")); this.$refs.imgFile.dispatchEvent(new MouseEvent("click"));
}, },
uploadImage() { uploadImage() {
const file = this.$refs.imgFile.files[0]; const file = this.$refs.imgFile.files[0];
let formData = new FormData(); let formData = new FormData();
formData.append("file", file); formData.append("file", file);
fileApi.EditIcon(formData).then(resp=>{ fileApi.EditIcon(formData).then((resp) => {
this.init(); this.init();
this.$dialog.notify.success(resp.msg, { this.$dialog.notify.success(resp.msg, {
position: "top-right", position: "top-right",
timeout: 5000, timeout: 5000,
}); });
}) });
}, },
}, },
}; };
</script> </script>