联调前端用户管理及角色管理
This commit is contained in:
Binary file not shown.
@@ -155,6 +155,13 @@
|
|||||||
用户管理
|
用户管理
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.Add(Yi.Framework.Model.Models.UserEntity)">
|
||||||
|
<summary>
|
||||||
|
添加用户,去重,密码加密
|
||||||
|
</summary>
|
||||||
|
<param name="entity"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GiveUserSetRole(Yi.Framework.DTOModel.GiveUserSetRoleDto)">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GiveUserSetRole(Yi.Framework.DTOModel.GiveUserSetRoleDto)">
|
||||||
<summary>
|
<summary>
|
||||||
给多用户设置多角色
|
给多用户设置多角色
|
||||||
@@ -162,5 +169,11 @@
|
|||||||
<param name="giveUserSetRoleDto"></param>
|
<param name="giveUserSetRoleDto"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GetRoleListByUserId(System.Int64)">
|
||||||
|
<summary>
|
||||||
|
通过用户id得到角色列表
|
||||||
|
</summary>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
</members>
|
</members>
|
||||||
</doc>
|
</doc>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:get:one")]
|
[Permission($"{nameof(T)}:get:one")]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<Result> GetById(long id)
|
public virtual async Task<Result> GetById(long id)
|
||||||
{
|
{
|
||||||
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:get:list")]
|
[Permission($"{nameof(T)}:get:list")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<Result> GetList(QueryCondition queryCondition)
|
public virtual async Task<Result> GetList(QueryCondition queryCondition)
|
||||||
{
|
{
|
||||||
return Result.Success().SetData(await _repository.GetListAsync(queryCondition));
|
return Result.Success().SetData(await _repository.GetListAsync(queryCondition));
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:get:page")]
|
[Permission($"{nameof(T)}:get:page")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<Result> PageList(QueryPageCondition queryCondition)
|
public virtual async Task<Result> PageList(QueryPageCondition queryCondition)
|
||||||
{
|
{
|
||||||
return Result.Success().SetData(await _repository.CommonPageAsync(queryCondition));
|
return Result.Success().SetData(await _repository.CommonPageAsync(queryCondition));
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:add")]
|
[Permission($"{nameof(T)}:add")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<Result> Add(T entity)
|
public virtual async Task<Result> Add(T entity)
|
||||||
{
|
{
|
||||||
return Result.Success().SetData(await _repository.InsertReturnSnowflakeIdAsync(entity));
|
return Result.Success().SetData(await _repository.InsertReturnSnowflakeIdAsync(entity));
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:update")]
|
[Permission($"{nameof(T)}:update")]
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public async Task<Result> Update(T entity)
|
public virtual async Task<Result> Update(T entity)
|
||||||
{
|
{
|
||||||
return Result.Success().SetStatus(await _repository.UpdateIgnoreNullAsync(entity));
|
return Result.Success().SetStatus(await _repository.UpdateIgnoreNullAsync(entity));
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Permission($"{nameof(T)}:delete:list")]
|
[Permission($"{nameof(T)}:delete:list")]
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public async Task<Result> DeleteList(List<long> ids)
|
public virtual async Task<Result> DeleteList(List<long> ids)
|
||||||
{
|
{
|
||||||
return Result.Success().SetStatus(await _repository.DeleteByLogicAsync(ids));
|
return Result.Success().SetStatus(await _repository.DeleteByLogicAsync(ids));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,5 +39,7 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,23 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
_iUserService = iUserService;
|
_iUserService = iUserService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加用户,去重,密码加密
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Permission($"{nameof(UserEntity)}:add")]
|
||||||
|
[HttpPost]
|
||||||
|
public override async Task<Result> Add(UserEntity entity)
|
||||||
|
{
|
||||||
|
if (!await _iUserService.Exist(entity.UserName))
|
||||||
|
{
|
||||||
|
entity.BuildPassword();
|
||||||
|
return Result.Success().SetData(await _iUserService._repository.InsertReturnSnowflakeIdAsync(entity));
|
||||||
|
}
|
||||||
|
return Result.SuccessError("用户已存在");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 给多用户设置多角色
|
/// 给多用户设置多角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -37,7 +54,18 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
[HttpPut]
|
[HttpPut]
|
||||||
public async Task<Result> GiveUserSetRole(GiveUserSetRoleDto giveUserSetRoleDto)
|
public async Task<Result> GiveUserSetRole(GiveUserSetRoleDto giveUserSetRoleDto)
|
||||||
{
|
{
|
||||||
return Result.Success().SetStatus(await _iUserService.GiveUserSetRole(giveUserSetRoleDto.UserIds,giveUserSetRoleDto.RoleIds));
|
return Result.Success().SetStatus(await _iUserService.GiveUserSetRole(giveUserSetRoleDto.UserIds, giveUserSetRoleDto.RoleIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过用户id得到角色列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<Result> GetRoleListByUserId(long userId)
|
||||||
|
{
|
||||||
|
return Result.Success().SetData(await _iUserService.GetRoleListByUserId(userId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -44,5 +44,20 @@ namespace Yi.Framework.Interface
|
|||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> GiveUserSetRole(List<long> userIds, List<long> roleIds);
|
Task<bool> GiveUserSetRole(List<long> userIds, List<long> roleIds);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断用户名是否存在,如果存在可返回该用户
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <param name="userAction"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<bool> Exist(string userName, Action<UserEntity> userAction = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过用户id得到角色列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<RoleEntity>> GetRoleListByUserId(long userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ namespace Yi.Framework.Model.Models
|
|||||||
public partial class MenuEntity
|
public partial class MenuEntity
|
||||||
{
|
{
|
||||||
[SqlSugar.SugarColumn(IsIgnore = true)]
|
[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||||
public List<MenuEntity> Childs { get; set; }
|
public List<MenuEntity> Children { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
namespace Yi.Framework.Model.Models
|
namespace Yi.Framework.Model.Models
|
||||||
{
|
{
|
||||||
@@ -15,10 +16,8 @@ namespace Yi.Framework.Model.Models
|
|||||||
this.IsDeleted = false;
|
this.IsDeleted = false;
|
||||||
this.CreateTime = DateTime.Now;
|
this.CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
/// <summary>
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
/// 1
|
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
||||||
///</summary>
|
|
||||||
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
namespace Yi.Framework.Model.Models
|
namespace Yi.Framework.Model.Models
|
||||||
{
|
{
|
||||||
@@ -15,10 +16,8 @@ namespace Yi.Framework.Model.Models
|
|||||||
this.IsDeleted = false;
|
this.IsDeleted = false;
|
||||||
this.CreateTime = DateTime.Now;
|
this.CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
/// <summary>
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
/// 1
|
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
||||||
///</summary>
|
|
||||||
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
namespace Yi.Framework.Model.Models
|
namespace Yi.Framework.Model.Models
|
||||||
{
|
{
|
||||||
@@ -15,10 +16,8 @@ namespace Yi.Framework.Model.Models
|
|||||||
this.IsDeleted = false;
|
this.IsDeleted = false;
|
||||||
this.CreateTime = DateTime.Now;
|
this.CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
/// <summary>
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
/// 1
|
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
||||||
///</summary>
|
|
||||||
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
namespace Yi.Framework.Model.Models
|
namespace Yi.Framework.Model.Models
|
||||||
{
|
{
|
||||||
@@ -15,10 +16,8 @@ namespace Yi.Framework.Model.Models
|
|||||||
this.IsDeleted = false;
|
this.IsDeleted = false;
|
||||||
this.CreateTime = DateTime.Now;
|
this.CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
/// <summary>
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
/// 1
|
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
||||||
///</summary>
|
|
||||||
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
namespace Yi.Framework.Model.Models
|
namespace Yi.Framework.Model.Models
|
||||||
{
|
{
|
||||||
@@ -15,10 +16,10 @@ namespace Yi.Framework.Model.Models
|
|||||||
this.IsDeleted = false;
|
this.IsDeleted = false;
|
||||||
this.CreateTime = DateTime.Now;
|
this.CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
///</summary>
|
[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>
|
||||||
///
|
///
|
||||||
@@ -75,5 +76,35 @@ namespace Yi.Framework.Model.Models
|
|||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName="Salt" )]
|
[SugarColumn(ColumnName="Salt" )]
|
||||||
public string Salt { get; set; }
|
public string Salt { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="Icon" )]
|
||||||
|
public long? Icon { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="Nick" )]
|
||||||
|
public string Nick { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="Email" )]
|
||||||
|
public string Email { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="Ip" )]
|
||||||
|
public string Ip { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="Address" )]
|
||||||
|
public string Address { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
[SugarColumn(ColumnName="Phone" )]
|
||||||
|
public string Phone { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
namespace Yi.Framework.Model.Models
|
namespace Yi.Framework.Model.Models
|
||||||
{
|
{
|
||||||
@@ -15,10 +16,8 @@ namespace Yi.Framework.Model.Models
|
|||||||
this.IsDeleted = false;
|
this.IsDeleted = false;
|
||||||
this.CreateTime = DateTime.Now;
|
this.CreateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
/// <summary>
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
/// 1
|
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
||||||
///</summary>
|
|
||||||
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
14
Yi.Framework.Net6/Yi.Framework.Model/RoleEntity.cs
Normal file
14
Yi.Framework.Net6/Yi.Framework.Model/RoleEntity.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using SqlSugar;
|
||||||
|
namespace Yi.Framework.Model.Models
|
||||||
|
{
|
||||||
|
|
||||||
|
public partial class RoleEntity
|
||||||
|
{
|
||||||
|
//[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.RoleId), nameof(UserRoleEntity.UserId))]
|
||||||
|
//public List<UserEntity> Users { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,21 @@ namespace Yi.Framework.Model.Models
|
|||||||
/// 看好啦!ORM精髓,导航属性
|
/// 看好啦!ORM精髓,导航属性
|
||||||
///</summary>
|
///</summary>
|
||||||
[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.UserId), nameof(UserRoleEntity.RoleId))]
|
[Navigate(typeof(UserRoleEntity), nameof(UserRoleEntity.UserId), nameof(UserRoleEntity.RoleId))]
|
||||||
public List<RoleEntity> Roles { get; set; }
|
public List<RoleEntity> Roles { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建密码,MD5盐值加密
|
||||||
|
/// </summary>
|
||||||
|
public void BuildPassword(string password = null)
|
||||||
|
{
|
||||||
|
//如果不传值,那就把自己的password当作传进来的password
|
||||||
|
if (password == null)
|
||||||
|
{
|
||||||
|
password = this.Password;
|
||||||
|
}
|
||||||
|
this.Salt = Common.Helper.MD5Helper.GenerateSalt();
|
||||||
|
this.Password = Common.Helper.MD5Helper.SHA2Encode(password, this.Salt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Yi.Framework.Service
|
|||||||
{
|
{
|
||||||
//ParentId 0,代表为根目录,只能存在一个
|
//ParentId 0,代表为根目录,只能存在一个
|
||||||
//复杂查询直接使用db代理
|
//复杂查询直接使用db代理
|
||||||
return await _repository._Db.Queryable<MenuEntity>().ToTreeAsync(it=>it.Childs,it=>it.ParentId,0);
|
return await _repository._Db.Queryable<MenuEntity>().ToTreeAsync(it=>it.Children,it=>it.ParentId,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,5 +41,6 @@ namespace Yi.Framework.Service
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Yi.Framework.Service
|
|||||||
{
|
{
|
||||||
return await _repository._Db.Queryable<UserEntity>().ToListAsync();
|
return await _repository._Db.Queryable<UserEntity>().ToListAsync();
|
||||||
}
|
}
|
||||||
public async Task<bool> Exist(Guid id, Action<UserEntity> userAction = null)
|
public async Task<bool> Exist(long id, Action<UserEntity> userAction = null)
|
||||||
{
|
{
|
||||||
var user = await _repository.GetByIdAsync(id);
|
var user = await _repository.GetByIdAsync(id);
|
||||||
userAction.Invoke(user);
|
userAction.Invoke(user);
|
||||||
@@ -58,8 +58,7 @@ namespace Yi.Framework.Service
|
|||||||
if (!await Exist(userEntity.UserName))
|
if (!await Exist(userEntity.UserName))
|
||||||
{
|
{
|
||||||
user.UserName = userEntity.UserName;
|
user.UserName = userEntity.UserName;
|
||||||
user.Salt = Common.Helper.MD5Helper.GenerateSalt();
|
user.BuildPassword();
|
||||||
user.Password = Common.Helper.MD5Helper.SHA2Encode(userEntity.Password, user.Salt);
|
|
||||||
userAction.Invoke(await _repository.InsertReturnEntityAsync(user));
|
userAction.Invoke(await _repository.InsertReturnEntityAsync(user));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -79,23 +78,29 @@ namespace Yi.Framework.Service
|
|||||||
return await _repositoryUserRole.UseTranAsync(async () =>
|
return await _repositoryUserRole.UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
|
|
||||||
//遍历用户
|
//遍历用户
|
||||||
foreach (var userId in userIds)
|
foreach (var userId in userIds)
|
||||||
{
|
{
|
||||||
//删除用户之前所有的用户角色关系(物理删除,没有恢复的必要)
|
//删除用户之前所有的用户角色关系(物理删除,没有恢复的必要)
|
||||||
await _repositoryUserRole.DeleteAsync(u => u.UserId == userId);
|
await _repositoryUserRole.DeleteAsync(u => u.UserId == userId);
|
||||||
|
|
||||||
//添加新的关系
|
//添加新的关系
|
||||||
List<UserRoleEntity> userRoleEntities = new();
|
List<UserRoleEntity> userRoleEntities = new();
|
||||||
foreach (var roleId in roleIds)
|
foreach (var roleId in roleIds)
|
||||||
{
|
{
|
||||||
userRoleEntities.Add(new UserRoleEntity() { UserId = userId, RoleId = roleId });
|
userRoleEntities.Add(new UserRoleEntity() { UserId = userId, RoleId = roleId });
|
||||||
}
|
}
|
||||||
|
|
||||||
//一次性批量添加
|
//一次性批量添加
|
||||||
await _repositoryUserRole.InsertRangeAsync(userRoleEntities);
|
await _repositoryUserRole.InsertRangeAsync(userRoleEntities);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<RoleEntity>> GetRoleListByUserId(long userId)
|
||||||
|
{
|
||||||
|
return (await _repository._Db.Queryable<UserEntity>().Includes(u => u.Roles).InSingleAsync(userId)).Roles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -15,6 +17,8 @@ namespace Yi.Framework.WebCore.BuilderExtend
|
|||||||
{
|
{
|
||||||
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
|
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
|
||||||
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm";
|
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm";
|
||||||
|
|
||||||
|
//options.SerializerSettings.Converters.Add(new ValueToStringConverter());
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
Yi.Vue2.x/package-lock.json
generated
13
Yi.Vue2.x/package-lock.json
generated
@@ -1080,6 +1080,11 @@
|
|||||||
"integrity": "sha1-ZfCvOC9Xi83HQr2cKB6cstd2gyg=",
|
"integrity": "sha1-ZfCvOC9Xi83HQr2cKB6cstd2gyg=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"bignumber.js": {
|
||||||
|
"version": "9.0.2",
|
||||||
|
"resolved": "https://registry.npmmirror.com/bignumber.js/-/bignumber.js-9.0.2.tgz",
|
||||||
|
"integrity": "sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw=="
|
||||||
|
},
|
||||||
"binary-extensions": {
|
"binary-extensions": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npm.taobao.org/binary-extensions/download/binary-extensions-2.2.0.tgz?cache=0&sync_timestamp=1610299293319&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbinary-extensions%2Fdownload%2Fbinary-extensions-2.2.0.tgz",
|
"resolved": "https://registry.npm.taobao.org/binary-extensions/download/binary-extensions-2.2.0.tgz?cache=0&sync_timestamp=1610299293319&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbinary-extensions%2Fdownload%2Fbinary-extensions-2.2.0.tgz",
|
||||||
@@ -4931,6 +4936,14 @@
|
|||||||
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
|
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"json-bigint": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/json-bigint/-/json-bigint-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==",
|
||||||
|
"requires": {
|
||||||
|
"bignumber.js": "^9.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"json-parse-better-errors": {
|
"json-parse-better-errors": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npm.taobao.org/json-parse-better-errors/download/json-parse-better-errors-1.0.2.tgz",
|
"resolved": "https://registry.npm.taobao.org/json-parse-better-errors/download/json-parse-better-errors-1.0.2.tgz",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mdi/font": "^6.6.96",
|
"@mdi/font": "^6.6.96",
|
||||||
"axios": "^0.22.0",
|
"axios": "^0.22.0",
|
||||||
|
"json-bigint": "^1.0.0",
|
||||||
"typeface-roboto": "^1.1.13",
|
"typeface-roboto": "^1.1.13",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-chartist": "^2.3.1",
|
"vue-chartist": "^2.3.1",
|
||||||
|
|||||||
@@ -19,11 +19,6 @@ export default {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
|
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
GetRolesByUserId(userId) {
|
|
||||||
return myaxios({
|
|
||||||
url: `/Role/GetRolesByUserId?userId=${userId}`,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
@@ -22,10 +22,10 @@ export default {
|
|||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
GetAxiosByRouter(router) {
|
GetRoleListByUserId(userId) {
|
||||||
return myaxios({
|
return myaxios({
|
||||||
url: `/User/GetAxiosByRouter?router=${router}`,
|
url: `/User/GetRoleListByUserId?userId=${userId}`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,20 @@ export default {
|
|||||||
getItem(url) {
|
getItem(url) {
|
||||||
return myaxios({
|
return myaxios({
|
||||||
url: url,
|
url: url,
|
||||||
method: 'get'
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
key: "isDeleted",
|
||||||
|
value: "0",
|
||||||
|
type: 0
|
||||||
|
|
||||||
|
}
|
||||||
|
],
|
||||||
|
orderBys: [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addItem(url, data) {
|
addItem(url, data) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import store from '../store/index'
|
import store from '../store/index'
|
||||||
import vm from '../main'
|
import vm from '../main'
|
||||||
|
import JsonBig from 'json-bigint'
|
||||||
// import VuetifyDialogPlugin from 'vuetify-dialog/nuxt/index';
|
// import VuetifyDialogPlugin from 'vuetify-dialog/nuxt/index';
|
||||||
const myaxios = axios.create({
|
const myaxios = axios.create({
|
||||||
// baseURL:'/'//
|
// baseURL:'/'//
|
||||||
@@ -9,6 +10,13 @@ const myaxios = axios.create({
|
|||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + ""
|
'Authorization': 'Bearer ' + ""
|
||||||
},
|
},
|
||||||
|
//雪花id精度问题
|
||||||
|
transformResponse: [ data => {
|
||||||
|
const json = JsonBig({
|
||||||
|
storeAsString: true
|
||||||
|
})
|
||||||
|
return json.parse(data)
|
||||||
|
}],
|
||||||
})
|
})
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
myaxios.interceptors.request.use(function(config) {
|
myaxios.interceptors.request.use(function(config) {
|
||||||
|
|||||||
@@ -12,17 +12,18 @@
|
|||||||
</material-card>
|
</material-card>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import userApi from "../api/userApi"
|
|
||||||
export default {
|
export default {
|
||||||
created() {
|
created() {
|
||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
userApi.GetAxiosByRouter(this.$route.path).then(resp=>{
|
this.axiosUrls = {
|
||||||
this.axiosUrls=resp.data;
|
get: "/role/GetList",
|
||||||
})
|
update: "/role/Update",
|
||||||
|
del: "/role/DeleteList",
|
||||||
|
add: "/role/Add",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
@@ -31,9 +32,9 @@ export default {
|
|||||||
},
|
},
|
||||||
headers: [
|
headers: [
|
||||||
{ text: "编号", align: "start", value: "id" },
|
{ text: "编号", align: "start", value: "id" },
|
||||||
{ text: "角色名", value: "role_name", sortable: false },
|
{ text: "角色名", value: "roleName", sortable: false },
|
||||||
{ text: "云盘地址", value: "file_path", sortable: false },
|
// { text: "云盘地址", value: "file_path", sortable: false },
|
||||||
{ text: "简介", value: "introduce", sortable: false },
|
// { text: "简介", value: "introduce", sortable: false },
|
||||||
{ text: "操作", value: "actions", sortable: false },
|
{ text: "操作", value: "actions", sortable: false },
|
||||||
],
|
],
|
||||||
defaultItem: {
|
defaultItem: {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import userApi from "../api/userApi";
|
import userApi from "../api/userApi";
|
||||||
import roleApi from "../api/roleApi";
|
|
||||||
export default {
|
export default {
|
||||||
created() {
|
created() {
|
||||||
this.init();
|
this.init();
|
||||||
@@ -36,12 +35,14 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async showItem(item) {
|
async showItem(item) {
|
||||||
var strInfo = "";
|
var strInfo = "";
|
||||||
roleApi.GetRolesByUserId(item.id).then(async (resp) => {
|
userApi.GetRoleListByUserId(item.id).then(async (resp) => {
|
||||||
const roleData = resp.data;
|
var roleData = resp.data;
|
||||||
strInfo += "拥有的角色:<br>";
|
strInfo += "拥有的角色:<br>";
|
||||||
roleData.forEach((u) => {
|
if (roleData != null) {
|
||||||
strInfo += u.role_name + "<br>";
|
roleData.forEach((u) => {
|
||||||
});
|
strInfo += u.roleName + "<br>";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
strInfo += "<hr>";
|
strInfo += "<hr>";
|
||||||
Object.keys(item).forEach(async function (key) {
|
Object.keys(item).forEach(async function (key) {
|
||||||
@@ -58,12 +59,16 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
userApi.GetAxiosByRouter(this.$route.path).then((resp) => {
|
this.axiosUrls = {
|
||||||
this.axiosUrls = resp.data;
|
get: "/user/GetList",
|
||||||
});
|
update: "/user/Update",
|
||||||
roleApi.getRole().then((resp) => {
|
del: "/user/DeleteList",
|
||||||
this.roleItems = resp.data;
|
add: "/user/Add",
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// roleApi.getRole().then((resp) => {
|
||||||
|
// this.roleItems = resp.data;
|
||||||
|
// });
|
||||||
},
|
},
|
||||||
setRole() {
|
setRole() {
|
||||||
var userIds = [];
|
var userIds = [];
|
||||||
@@ -95,8 +100,7 @@ export default {
|
|||||||
roleItems: [],
|
roleItems: [],
|
||||||
axiosUrls: {},
|
axiosUrls: {},
|
||||||
headers: [
|
headers: [
|
||||||
{ text: "编号", align: "start", value: "id" },
|
{ text: "用户名", value: "userName", sortable: false },
|
||||||
{ text: "用户名", value: "username", sortable: false },
|
|
||||||
{ text: "密码", value: "password", sortable: false },
|
{ text: "密码", value: "password", sortable: false },
|
||||||
{ text: "图标", value: "icon", sortable: false },
|
{ text: "图标", value: "icon", sortable: false },
|
||||||
{ text: "昵称", value: "nick", sortable: true },
|
{ text: "昵称", value: "nick", sortable: true },
|
||||||
@@ -110,11 +114,11 @@ export default {
|
|||||||
defaultItem: {
|
defaultItem: {
|
||||||
username: "test",
|
username: "test",
|
||||||
password: "123",
|
password: "123",
|
||||||
icon: "mdi-lock",
|
icon: "",
|
||||||
nick: "橙子",
|
nick: "橙子",
|
||||||
age: 18,
|
age: 18,
|
||||||
address: "中国",
|
address: "中国",
|
||||||
phone: "",
|
phone: "123456789",
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user