13 changed files with 1223 additions and 251 deletions
-
5src/Shentun.Peis.Application.Contracts/PeisApplicationContractsModule.cs
-
56src/Shentun.Peis.Application.Contracts/Permissions/PeisPermissionDefinitionProvider.cs
-
96src/Shentun.Peis.Application.Contracts/Permissions/PeisPermissions.cs
-
11src/Shentun.Peis.Application.Contracts/Roles/RoleIdInputDto.cs
-
12src/Shentun.Peis.Application.Contracts/Roles/UpdateRoleInputDto.cs
-
27src/Shentun.Peis.Application/Books/BookAppService.cs
-
223src/Shentun.Peis.Application/MyUser/MyUserAppService.cs
-
721src/Shentun.Peis.Application/MyUser/MyUserAppServiceBak.cs
-
144src/Shentun.Peis.Application/PermissionManagements/PermissionManagementAppService.cs
-
151src/Shentun.Peis.Application/Roles/MyRoleAppService.cs
-
14src/Shentun.Peis.Domain.Shared/Localization/Peis/en.json
-
12src/Shentun.Peis.Domain.Shared/Localization/Peis/zh-Hans.json
-
2src/Shentun.Peis.HttpApi.Host/Filter/ApplicationDescription.cs
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Shentun.Peis.Roles |
|||
{ |
|||
public class RoleIdInputDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace Shentun.Peis.Roles |
|||
{ |
|||
public class UpdateRoleInputDto: IdentityRoleUpdateDto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
} |
|||
} |
|||
@ -1,27 +0,0 @@ |
|||
using Shentun.Peis.Permissions; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace Shentun.Peis.Books |
|||
{ |
|||
public class BookAppService : CrudAppService<Book, BookDto, Guid, PagedAndSortedResultRequestDto, CreateBookDto>, IBookAppService |
|||
{ |
|||
|
|||
|
|||
public BookAppService(IRepository<Book, Guid> repository) : base(repository) |
|||
{ |
|||
GetPolicyName =PeisPermissions.Books.Default; |
|||
GetListPolicyName = PeisPermissions.Books.Default; |
|||
CreatePolicyName = PeisPermissions.Books.Create; |
|||
UpdatePolicyName = PeisPermissions.Books.Edit; |
|||
DeletePolicyName = PeisPermissions.Books.Delete; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,721 @@ |
|||
using IdentityModel.Client; |
|||
using log4net.ObjectRenderer; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.Routing; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Options; |
|||
using Newtonsoft.Json; |
|||
using NPOI.SS.Formula.Functions; |
|||
using NPOI.SS.UserModel; |
|||
using Shentun.Peis.Models; |
|||
using Shentun.Peis.MyUser; |
|||
using Shentun.Peis.OrganizationUnits; |
|||
using Shentun.Peis.Permissions; |
|||
using Shentun.Peis.RegisterCheckPictures; |
|||
using Shentun.Peis.Sexs; |
|||
using Shentun.Utilities; |
|||
using SqlSugar; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Net.Http; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Account; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.ObjectExtending; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Security.Encryption; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace Shentun.Peis.MyUser |
|||
{ |
|||
|
|||
public class MyUserAppServiceBak |
|||
{ |
|||
|
|||
} |
|||
///// <summary>
|
|||
///// 重写IdentityUser服务
|
|||
///// </summary>
|
|||
//[Dependency(ReplaceServices = true)]
|
|||
//////[RemoteService(isEnabled: false)]
|
|||
//[ExposeServices(typeof(IIdentityUserAppService))]
|
|||
|
|||
//public class MyUserAppServiceBak : IdentityUserAppService
|
|||
//{
|
|||
// private readonly IRepository<IdentityUser, Guid> _identityUserRepository;
|
|||
// private readonly IdentityUserManager _userManager;
|
|||
// private readonly IIdentityUserRepository _userRepository;
|
|||
// private readonly IOptions<IdentityOptions> _identityOptions;
|
|||
// private readonly IPasswordHasher<IdentityUser> _passwordHasher;
|
|||
// private readonly IStringEncryptionService _stringEncryptionService;
|
|||
// private readonly PeisOrganizationUnitManager _peisOrganizationUnitManager;
|
|||
// private readonly IHttpClientFactory _httpClientFactory;
|
|||
// private readonly IConfiguration _configuration;
|
|||
// private readonly IRepository<OrganizationUnit, Guid> _organizationUnitRepository;
|
|||
// private readonly IRepository<IdentityUserOrganizationUnit> _identityUserOrganizationUnitRepository;
|
|||
// private readonly CurrentUser _currentUser;
|
|||
// private readonly IDistributedCache<IdentityUser, Guid> _userCache;
|
|||
|
|||
// public MyUserAppServiceBak(
|
|||
// IRepository<IdentityUser, Guid> identityUserRepository,
|
|||
// IdentityUserManager userManager,
|
|||
// IIdentityUserRepository userRepository,
|
|||
// IIdentityRoleRepository roleRepository,
|
|||
// IOptions<IdentityOptions> identityOptions,
|
|||
// IPasswordHasher<IdentityUser> passwordHasher,
|
|||
// IStringEncryptionService stringEncryptionService,
|
|||
// IRepository<OrganizationUnit, Guid> organizationUnitRepository,
|
|||
// PeisOrganizationUnitManager peisOrganizationUnitManager,
|
|||
// IHttpClientFactory httpClientFactory,
|
|||
// IConfiguration configuration,
|
|||
// IRepository<IdentityUserOrganizationUnit> identityUserOrganizationUnitRepository,
|
|||
// CurrentUser currentUser,
|
|||
// IDistributedCache<IdentityUser, Guid> userCache) :
|
|||
// base(userManager,
|
|||
// userRepository,
|
|||
// roleRepository,
|
|||
// identityOptions)
|
|||
// {
|
|||
// this._identityUserRepository = identityUserRepository;
|
|||
// this._userManager = userManager;
|
|||
// this._userRepository = userRepository;
|
|||
// this._identityOptions = identityOptions;
|
|||
// this._passwordHasher = passwordHasher;
|
|||
// this._stringEncryptionService = stringEncryptionService;
|
|||
// this._peisOrganizationUnitManager = peisOrganizationUnitManager;
|
|||
// this._httpClientFactory = httpClientFactory;
|
|||
// this._configuration = configuration;
|
|||
// this._organizationUnitRepository = organizationUnitRepository;
|
|||
// this._identityUserOrganizationUnitRepository = identityUserOrganizationUnitRepository;
|
|||
// this._currentUser = currentUser;
|
|||
// _userCache = userCache;
|
|||
// }
|
|||
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// /// 根据角色查询用户列表
|
|||
// /// </summary>
|
|||
// /// <param name="RoleName"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpGet("api/identity/users/userlistbyrolename")]
|
|||
// public async Task<List<IdentityUserDto>> GetUserListByRoleName(string RoleName)
|
|||
// {
|
|||
// var userlist = await _userRepository.GetListByNormalizedRoleNameAsync(RoleName);
|
|||
// return ObjectMapper.Map<List<IdentityUser>, List<IdentityUserDto>>(userlist);
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 修改用户密码 修改自身密码
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpPost("api/identity/users/updatepassword")]
|
|||
// public async Task UpdatePassWordAsync(UpdatePasswordDto input)
|
|||
// {
|
|||
// var user = await _userManager.FindByIdAsync(_currentUser.Id.ToString());
|
|||
// if (user != null)
|
|||
// {
|
|||
// var isPassWord = await _userManager.CheckPasswordAsync(user, input.OldPassWord);
|
|||
// if (!isPassWord)
|
|||
// {
|
|||
// throw new UserFriendlyException("原密码不正确");
|
|||
// }
|
|||
|
|||
// await _userManager.RemovePasswordAsync(user);
|
|||
|
|||
// await _userManager.AddPasswordAsync(user, input.NewPassWord);
|
|||
|
|||
// }
|
|||
// }
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// /// 管理员重置用户密码
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpPost("api/identity/users/resetpassword")]
|
|||
// public async Task ResetPassWordAsync(ResetPassWordDto input)
|
|||
// {
|
|||
// var user = await _userManager.FindByIdAsync(input.UserId.ToString());
|
|||
// if (user != null)
|
|||
// {
|
|||
// var RemoveMsg = await _userManager.RemovePasswordAsync(user);
|
|||
|
|||
// if (!RemoveMsg.Succeeded)
|
|||
// throw new UserFriendlyException($"操作失败,{RemoveMsg.Errors.FirstOrDefault().Code}");
|
|||
|
|||
// var AddPasswordMsg = await _userManager.AddPasswordAsync(user, input.NewPassWord);
|
|||
|
|||
// if (!AddPasswordMsg.Succeeded)
|
|||
// throw new UserFriendlyException($"操作失败,{AddPasswordMsg.Errors.FirstOrDefault().Code}");
|
|||
|
|||
// }
|
|||
// }
|
|||
|
|||
// ///// <summary>
|
|||
// ///// 创建
|
|||
// ///// </summary>
|
|||
// ///// <param name="input"></param>
|
|||
// ///// <returns></returns>
|
|||
// //[Authorize(PeisPermissions.Users.Create)]
|
|||
// //[HttpPost("api/identity/users/create")]
|
|||
// //public override Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
|
|||
// //{
|
|||
// // return base.CreateAsync(input);
|
|||
// //}
|
|||
|
|||
// /// <summary>
|
|||
// /// 创建 可以不带邮箱 自动以用户名生成
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpPost("api/identity/users/create")]
|
|||
// public async Task<IdentityUserDto> CreateAsync(IdentityUserCreateNoEmailDto input)
|
|||
// {
|
|||
// #region 上传图片
|
|||
// string userPhoto = UploadUserPhotoAsync(new UploadUserPhotoInputDto { PictureBaseStr = input.UserPhoto });
|
|||
// string userSign = UploadUserSignAsync(new UploadUserPhotoInputDto { PictureBaseStr = input.UserSign });
|
|||
// #endregion
|
|||
|
|||
|
|||
// IdentityUserCreateDto newinput = new IdentityUserCreateDto
|
|||
// {
|
|||
// Email = string.IsNullOrWhiteSpace(input.Email) ? input.UserName + "@qq.com" : input.Email,
|
|||
// IsActive = input.IsActive,
|
|||
// LockoutEnabled = input.LockoutEnabled,
|
|||
// Name = input.Name,
|
|||
// Password = input.Password,
|
|||
// PhoneNumber = input.PhoneNumber,
|
|||
// RoleNames = input.RoleNames,
|
|||
// Surname = input.Surname,
|
|||
// UserName = input.UserName
|
|||
// };
|
|||
|
|||
|
|||
|
|||
// await IdentityOptions.SetAsync();
|
|||
|
|||
// var user = new IdentityUser(
|
|||
// GuidGenerator.Create(),
|
|||
// newinput.UserName,
|
|||
// newinput.Email,
|
|||
// CurrentTenant.Id
|
|||
// );
|
|||
|
|||
// user.SetProperty("user_photo", userPhoto);
|
|||
// user.SetProperty("user_sign", userSign);
|
|||
// user.SetProperty("operator_type", input.OperatorType);
|
|||
|
|||
// newinput.MapExtraPropertiesTo(user);
|
|||
|
|||
// (await UserManager.CreateAsync(user, input.Password)).CheckErrors();
|
|||
// await UpdateUserByInput(user, newinput);
|
|||
// (await UserManager.UpdateAsync(user)).CheckErrors();
|
|||
|
|||
// await CurrentUnitOfWork.SaveChangesAsync();
|
|||
|
|||
// var entityDto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
|
|||
|
|||
|
|||
|
|||
|
|||
// var entity = await _identityUserRepository.GetAsync(entityDto.Id);
|
|||
// _userCache.Set(entityDto.Id, entity);
|
|||
// return entityDto;
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 删除用户
|
|||
// /// </summary>
|
|||
// /// <param name="id"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpPost("api/identity/users/delete")]
|
|||
// public override async Task DeleteAsync(Guid id)
|
|||
// {
|
|||
// if (CurrentUser.Id == id)
|
|||
// {
|
|||
// throw new BusinessException(code: IdentityErrorCodes.UserSelfDeletion);
|
|||
// }
|
|||
|
|||
// var user = await UserManager.FindByIdAsync(id.ToString());
|
|||
// if (user == null)
|
|||
// {
|
|||
// return;
|
|||
// }
|
|||
|
|||
// (await UserManager.DeleteAsync(user)).CheckErrors();
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 获取列表
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpGet("api/identity/users/getlist")]
|
|||
// public override async Task<PagedResultDto<IdentityUserDto>> GetListAsync(GetIdentityUsersInput input)
|
|||
// {
|
|||
// var count = await UserRepository.GetCountAsync(input.Filter);
|
|||
// var list = await UserRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter);
|
|||
|
|||
// return new PagedResultDto<IdentityUserDto>(
|
|||
// count,
|
|||
// ObjectMapper.Map<List<IdentityUser>, List<IdentityUserDto>>(list)
|
|||
// );
|
|||
// }
|
|||
// /// <summary>
|
|||
// /// 获取列表 根据科室查询 不传科室查所有
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpPost("api/identity/users/getlistinorganizationunit")]
|
|||
// public async Task<List<IdentityUserWithExtensionDto>> GetListInOrganizationUnitAsync(OrganizationUnitIdIuputDto input)
|
|||
// {
|
|||
|
|||
// List<IdentityUser> userList = new List<IdentityUser>();
|
|||
|
|||
// var identityUserOrganizationUnitList = await _identityUserOrganizationUnitRepository.GetListAsync();
|
|||
|
|||
// if (input.OrganizationUnitId != null && input.OrganizationUnitId != Guid.Empty)
|
|||
// {
|
|||
// List<Guid> organizationUnitIds = await _peisOrganizationUnitManager.GetOrganizationUnitChildIds(input.OrganizationUnitId.Value);
|
|||
// userList = await _userRepository.GetUsersInOrganizationsListAsync(organizationUnitIds);
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// userList = await _identityUserRepository.GetListAsync(m => m.IsDeleted == false);
|
|||
// }
|
|||
// var entlistdto = userList.Select(s => new IdentityUserWithExtensionDto
|
|||
// {
|
|||
// UserSign = s.GetProperty<string>("user_sign"),
|
|||
// UserPhoto = s.GetProperty<string>("user_photo"),
|
|||
// OperatorType = s.GetProperty<char>("operator_type"),
|
|||
// ConcurrencyStamp = s.ConcurrencyStamp,
|
|||
// CreationTime = s.CreationTime,
|
|||
// CreatorId = s.CreatorId,
|
|||
// DeleterId = s.DeleterId,
|
|||
// DeletionTime = s.DeletionTime,
|
|||
// Email = s.Email,
|
|||
// EmailConfirmed = s.EmailConfirmed,
|
|||
// Id = s.Id,
|
|||
// IsActive = s.IsActive,
|
|||
// IsDeleted = s.IsDeleted,
|
|||
// LastModificationTime = s.LastModificationTime,
|
|||
// LastModifierId = s.LastModifierId,
|
|||
// LockoutEnabled = s.LockoutEnabled,
|
|||
// LockoutEnd = s.LockoutEnd,
|
|||
// Name = s.Name,
|
|||
// PhoneNumber = s.PhoneNumber,
|
|||
// PhoneNumberConfirmed = s.PhoneNumberConfirmed,
|
|||
// Surname = s.Surname,
|
|||
// TenantId = s.TenantId,
|
|||
// UserName = s.UserName,
|
|||
// //OrganizationUnitId = identityUserOrganizationUnitList.FirstOrDefault(m => m.UserId == s.Id) != null? identityUserOrganizationUnitList.FirstOrDefault(m => m.UserId == s.Id).OrganizationUnitId:Guid.Empty,
|
|||
// OrganizationUnitId = identityUserOrganizationUnitList.FirstOrDefault(m => m.UserId == s.Id)?.OrganizationUnitId,
|
|||
// SimpleCode = LanguageConverter.GetPYSimpleCode(s.Surname)
|
|||
|
|||
// }).ToList();
|
|||
// // var entlistdto = ObjectMapper.Map<List<IdentityUser>, List<IdentityUserDto>>(entlist);
|
|||
// return entlistdto;
|
|||
// }
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// /// 获取列表 根据用户类别
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpPost("api/identity/users/GetListByOperatorType")]
|
|||
// public async Task<List<ListByOperatorTypeDto>> GetListByOperatorTypeAsync(OperatorTypeIuputDto input)
|
|||
// {
|
|||
// var entlist = await _identityUserRepository.GetListAsync(m => m.IsDeleted == false);
|
|||
// var entlistDto = entlist.Where(m => input.OperatorTypes.Contains(m.GetProperty<char>("operator_type"))).Select(s => new ListByOperatorTypeDto
|
|||
// {
|
|||
// Id = s.Id,
|
|||
// SimpleCode = LanguageConverter.GetPYSimpleCode(s.Surname),
|
|||
// Surname = s.Surname,
|
|||
// UserName = s.UserName
|
|||
// }).ToList();
|
|||
|
|||
// return entlistDto;
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 修改用户信息
|
|||
// /// </summary>
|
|||
// /// <param name="id"></param>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// //[Authorize(PeisPermissions.Users.Edit)]
|
|||
// //[HttpPost("api/identity/users/update")]
|
|||
// [RemoteService(false)]
|
|||
// public override async Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input)
|
|||
// {
|
|||
// var entityDto = await base.UpdateAsync(id, input);
|
|||
|
|||
// var entity = await _identityUserRepository.GetAsync(id);
|
|||
// _userCache.Set(id, entity);
|
|||
// return entityDto;
|
|||
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 修改
|
|||
// /// </summary>
|
|||
// /// <param name="id"></param>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpPost("api/identity/users/update")]
|
|||
// public async Task<IdentityUserDto> UpdateIdentityUserAsync(Guid id, IdentityUserUpdateInputDto input)
|
|||
// {
|
|||
|
|||
// #region 上传图片
|
|||
// string userPhoto = UploadUserPhotoAsync(new UploadUserPhotoInputDto
|
|||
// {
|
|||
// PictureBaseStr = input.UserPhoto,
|
|||
// UserId = id
|
|||
// });
|
|||
// string userSign = UploadUserSignAsync(new UploadUserPhotoInputDto
|
|||
// {
|
|||
// PictureBaseStr = input.UserSign,
|
|||
// UserId = id
|
|||
// });
|
|||
// #endregion
|
|||
|
|||
// input.Email = input.UserName + "@qq.com";
|
|||
|
|||
|
|||
// await IdentityOptions.SetAsync();
|
|||
|
|||
// var user = await UserManager.GetByIdAsync(id);
|
|||
|
|||
// user.SetProperty("user_sign", userSign);
|
|||
// user.SetProperty("user_photo", userPhoto);
|
|||
// user.SetProperty("operator_type", input.OperatorType);
|
|||
// user.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);
|
|||
|
|||
// (await UserManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
|
|||
|
|||
// await UpdateUserByInput(user, input);
|
|||
// input.MapExtraPropertiesTo(user);
|
|||
|
|||
// (await UserManager.UpdateAsync(user)).CheckErrors();
|
|||
|
|||
// if (!input.Password.IsNullOrEmpty())
|
|||
// {
|
|||
// (await UserManager.RemovePasswordAsync(user)).CheckErrors();
|
|||
// (await UserManager.AddPasswordAsync(user, input.Password)).CheckErrors();
|
|||
// }
|
|||
|
|||
// await CurrentUnitOfWork.SaveChangesAsync();
|
|||
|
|||
// var entityDto = ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
|
|||
|
|||
|
|||
// var entity = await _identityUserRepository.GetAsync(id);
|
|||
// _userCache.Set(id, entity);
|
|||
// return entityDto;
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 获取用户信息 根据ID
|
|||
// /// </summary>
|
|||
// /// <param name="id"></param>
|
|||
// /// <returns></returns>
|
|||
// //[Authorize(PeisPermissions.Users.Default)]
|
|||
// //[HttpGet("api/identity/users/getinfo")]
|
|||
// [RemoteService(false)]
|
|||
// public override Task<IdentityUserDto> GetAsync(Guid id)
|
|||
// {
|
|||
// return base.GetAsync(id);
|
|||
// }
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// ///上传用户照片 图片base64
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// /// <exception cref="UserFriendlyException"></exception>
|
|||
// private string UploadUserPhotoAsync(UploadUserPhotoInputDto input)
|
|||
// {
|
|||
// string fileName = "";
|
|||
// if (input.UserId != null)
|
|||
// {
|
|||
// fileName = input.UserId.ToString();
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// fileName = Guid.NewGuid().ToString();
|
|||
// }
|
|||
|
|||
// string imgurl = $"UserPhoto/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{fileName}";
|
|||
// var isupload = ImageHelper.Base64StrToImage(input.PictureBaseStr, imgurl);
|
|||
// if (!string.IsNullOrEmpty(isupload))
|
|||
// return isupload;
|
|||
// else
|
|||
// return "";
|
|||
// }
|
|||
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// /// 上传用户签名 图片base64
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// /// <exception cref="UserFriendlyException"></exception>
|
|||
// private string UploadUserSignAsync(UploadUserPhotoInputDto input)
|
|||
// {
|
|||
// string fileName = "";
|
|||
// if (input.UserId != null)
|
|||
// {
|
|||
// fileName = input.UserId.ToString();
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// fileName = Guid.NewGuid().ToString();
|
|||
// }
|
|||
|
|||
// string imgurl = $"UserSign/{DateTime.Now.Year}/{DateTime.Now.Month}/{DateTime.Now.Day}/{fileName}";
|
|||
// var isupload = ImageHelper.Base64StrToImage(input.PictureBaseStr, imgurl);
|
|||
// if (!string.IsNullOrEmpty(isupload))
|
|||
// return isupload;
|
|||
// else
|
|||
// return "";
|
|||
// }
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// /// 获取用户信息 根据ID
|
|||
// /// </summary>
|
|||
// /// <param name="id"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpGet("api/identity/users/getinfo")]
|
|||
// public async Task<IdentityUserWithExtensionDto> GetWithExtensionAsync(Guid id)
|
|||
// {
|
|||
// var ent = await UserManager.GetByIdAsync(id);
|
|||
// var userSign = !string.IsNullOrWhiteSpace(ent.GetProperty<string>("user_sign")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty<string>("user_sign")) : "";
|
|||
// var userPhoto = !string.IsNullOrWhiteSpace(ent.GetProperty<string>("user_photo")) ? ImageHelper.GetImageBase64StringAsync(ent.GetProperty<string>("user_photo")) : "";
|
|||
// var operatorType = ent.GetProperty<char>("operator_type");
|
|||
// var entDto = ObjectMapper.Map<IdentityUser, IdentityUserWithExtensionDto>(ent);
|
|||
// entDto.UserPhoto = userPhoto;
|
|||
// entDto.UserSign = userSign;
|
|||
// entDto.OperatorType = operatorType;
|
|||
// return entDto;
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 给用户绑定角色
|
|||
// /// </summary>
|
|||
// /// <param name="id">用户ID</param>
|
|||
// /// <param name="input">角色集合</param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpPost("api/identity/users/updateroles")]
|
|||
// public override async Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input)
|
|||
// {
|
|||
// var user = await UserManager.GetByIdAsync(id);
|
|||
// (await UserManager.SetRolesAsync(user, input.RoleNames)).CheckErrors();
|
|||
// await UserRepository.UpdateAsync(user);
|
|||
// }
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// /// 获取用户的角色信息 根据用户ID
|
|||
// /// </summary>
|
|||
// /// <param name="id">用户ID</param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpGet("api/identity/users/getroles")]
|
|||
// public async Task<ListResultDto<IdentityRoleDto>> GetRolesAsync(Guid id)
|
|||
// {
|
|||
|
|||
// var roles = await UserRepository.GetRolesAsync(id);
|
|||
|
|||
// return new ListResultDto<IdentityRoleDto>(
|
|||
// ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(roles)
|
|||
// );
|
|||
// }
|
|||
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// /// 获取当前登录用户的角色信息
|
|||
// /// </summary>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [HttpGet("api/identity/users/getassignableroles")]
|
|||
// public override async Task<ListResultDto<IdentityRoleDto>> GetAssignableRolesAsync()
|
|||
// {
|
|||
// var list = await RoleRepository.GetListAsync();
|
|||
// return new ListResultDto<IdentityRoleDto>(
|
|||
// ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list));
|
|||
// }
|
|||
|
|||
|
|||
// /// <summary>
|
|||
// /// 暂未用到
|
|||
// /// </summary>
|
|||
// /// <param name="userName"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [RemoteService(false)]
|
|||
// public override Task<IdentityUserDto> FindByUsernameAsync(string userName)
|
|||
// {
|
|||
// return base.FindByUsernameAsync(userName);
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 暂未用到
|
|||
// /// </summary>
|
|||
// /// <param name="email"></param>
|
|||
// /// <returns></returns>
|
|||
// [Authorize(PeisPermissions.SystemSettings.Default)]
|
|||
// [RemoteService(false)]
|
|||
// public override Task<IdentityUserDto> FindByEmailAsync(string email)
|
|||
// {
|
|||
// return base.FindByEmailAsync(email);
|
|||
// }
|
|||
|
|||
// /// <summary>
|
|||
// /// 用户登录
|
|||
// /// </summary>
|
|||
// /// <param name="input"></param>
|
|||
// /// <returns></returns>
|
|||
// [HttpPost("api/identity/users/login")]
|
|||
// public async Task<UserLoginDto> UserLogin(UserLoginRequestDto input)
|
|||
// {
|
|||
|
|||
// UserLoginDto msg;
|
|||
|
|||
|
|||
// var user = await _userManager.FindByNameAsync(input.UserName);
|
|||
// if (user != null)
|
|||
// {
|
|||
|
|||
// var verifyResult = await _userManager.CheckPasswordAsync(user, input.PassWord);
|
|||
// if (verifyResult)
|
|||
// {
|
|||
|
|||
// var PeisId = await _peisOrganizationUnitManager.GetPeisIdAsync(user.Id);
|
|||
|
|||
// if (user.IsActive == false)
|
|||
// {
|
|||
// throw new UserFriendlyException("账号已被禁用");
|
|||
// }
|
|||
|
|||
// if (user.LockoutEnabled == true)
|
|||
// {
|
|||
// throw new UserFriendlyException("账号已被锁定");
|
|||
// }
|
|||
|
|||
// TokenResponse token = await RequestAuthServerLoginByPasswordAsync(input.UserName, input.PassWord);
|
|||
|
|||
// if (token.HttpResponse != null && token.HttpResponse.StatusCode == HttpStatusCode.OK)
|
|||
// {
|
|||
// msg = new UserLoginDto
|
|||
// {
|
|||
// //code = 1,
|
|||
// //msg = "登录成功",
|
|||
// peisid = PeisId,
|
|||
// UserId = user.Id,
|
|||
// OperatorType = user.GetProperty<char>("operator_type"),
|
|||
// access_token = token.AccessToken,
|
|||
// expires_in = token.ExpiresIn,
|
|||
// refresh_token = token.RefreshToken,
|
|||
// token_type = token.TokenType
|
|||
// };
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// //msg = new UserLoginDto { code = 1, msg = "登录成功", peisid = PeisId };
|
|||
// throw new UserFriendlyException("获取token失败");
|
|||
// }
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// //msg = new UserLoginDto { code = -1, msg = "密码不正确" };
|
|||
// throw new UserFriendlyException("密码不正确");
|
|||
// }
|
|||
|
|||
|
|||
|
|||
// #region MyRegion
|
|||
// //var verifyResult = _passwordHasher.VerifyHashedPassword(user, user.PasswordHash, PassWord);
|
|||
|
|||
// //if (verifyResult == PasswordVerificationResult.Success)
|
|||
// //{
|
|||
// // return "1";
|
|||
// //}
|
|||
// //else
|
|||
// //{
|
|||
// // throw new UserFriendlyException("密码错误");
|
|||
// //}
|
|||
// #endregion
|
|||
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// //msg = new UserLoginDto { code = -1, msg = "用户不存在" };
|
|||
// throw new UserFriendlyException("用户不存在");
|
|||
// }
|
|||
|
|||
// return msg;
|
|||
|
|||
// }
|
|||
|
|||
|
|||
// protected virtual async Task<TokenResponse> RequestAuthServerLoginByPasswordAsync(string username, string password)
|
|||
// {
|
|||
// var client = _httpClientFactory.CreateClient();
|
|||
|
|||
// var request = new PasswordTokenRequest
|
|||
// {
|
|||
// Address = _configuration["AuthServer:Authority"] + "/connect/token",
|
|||
// //GrantType = "password",
|
|||
// //UserName = username,
|
|||
// //Password = password,
|
|||
// //Scope = "Peis offline_access",
|
|||
// //ClientId = "Peis_App",
|
|||
// Parameters =
|
|||
// {
|
|||
// {"username",username},
|
|||
// {"password",password },
|
|||
// {"scope","Peis offline_access" },
|
|||
// {"client_id","Peis_App" },
|
|||
// {"grant_type","password" }
|
|||
// }
|
|||
// };
|
|||
|
|||
// //request.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
|||
|
|||
// return await client.RequestTokenAsync(request);
|
|||
// }
|
|||
|
|||
//}
|
|||
} |
|||
@ -0,0 +1,151 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Shentun.Peis.Permissions; |
|||
using Shentun.Peis.Rooms; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.ObjectExtending; |
|||
|
|||
namespace Shentun.Peis.Roles |
|||
{ |
|||
/// <summary>
|
|||
/// 角色管理
|
|||
/// </summary>
|
|||
[Authorize] |
|||
public class MyRoleAppService : ApplicationService |
|||
{ |
|||
|
|||
private readonly IdentityRoleManager _roleManager; |
|||
private readonly IIdentityRoleRepository _roleRepository; |
|||
|
|||
public MyRoleAppService( |
|||
IdentityRoleManager roleManager, |
|||
IIdentityRoleRepository roleRepository) |
|||
{ |
|||
_roleManager = roleManager; |
|||
_roleRepository = roleRepository; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 查询
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
[Authorize(PeisPermissions.SystemSettings.Default)] |
|||
[HttpPost("api/app/MyRole/GetAllList")] |
|||
public async Task<ListResultDto<IdentityRoleDto>> GetAllListAsync() |
|||
{ |
|||
var list = await _roleRepository.GetListAsync(); |
|||
return new ListResultDto<IdentityRoleDto>( |
|||
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list) |
|||
); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 创建
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[Authorize(PeisPermissions.SystemSettings.Default)] |
|||
[HttpPost("api/app/MyRole/Create")] |
|||
public async Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input) |
|||
{ |
|||
var role = new IdentityRole( |
|||
GuidGenerator.Create(), |
|||
input.Name, |
|||
CurrentTenant.Id |
|||
) |
|||
{ |
|||
IsDefault = input.IsDefault, |
|||
IsPublic = input.IsPublic |
|||
}; |
|||
input.MapExtraPropertiesTo(role); |
|||
|
|||
(await _roleManager.CreateAsync(role)).CheckErrors(); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 修改
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[Authorize(PeisPermissions.SystemSettings.Default)] |
|||
[HttpPost("api/app/MyRole/Update")] |
|||
public async Task<IdentityRoleDto> UpdateAsync(UpdateRoleInputDto input) |
|||
{ |
|||
var role = await _roleManager.GetByIdAsync(input.Id); |
|||
|
|||
role.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); |
|||
|
|||
(await _roleManager.SetRoleNameAsync(role, input.Name)).CheckErrors(); |
|||
|
|||
role.IsDefault = input.IsDefault; |
|||
role.IsPublic = input.IsPublic; |
|||
|
|||
input.MapExtraPropertiesTo(role); |
|||
|
|||
(await _roleManager.UpdateAsync(role)).CheckErrors(); |
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
|
|||
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 删除
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[Authorize(PeisPermissions.SystemSettings.Default)] |
|||
[HttpPost("api/app/MyRole/Delete")] |
|||
public async Task DeleteAsync(RoleIdInputDto input) |
|||
{ |
|||
var role = await _roleManager.FindByIdAsync(input.Id.ToString()); |
|||
if (role == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
(await _roleManager.DeleteAsync(role)).CheckErrors(); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
[Authorize(PeisPermissions.SystemSettings.Default)] |
|||
[RemoteService(false)] |
|||
public async Task<IdentityRoleDto> GetAsync(Guid id) |
|||
{ |
|||
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>( |
|||
await _roleManager.GetByIdAsync(id) |
|||
); |
|||
} |
|||
[Authorize(PeisPermissions.SystemSettings.Default)] |
|||
[RemoteService(false)] |
|||
public async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(GetIdentityRolesInput input) |
|||
{ |
|||
var list = await _roleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter); |
|||
var totalCount = await _roleRepository.GetCountAsync(input.Filter); |
|||
|
|||
return new PagedResultDto<IdentityRoleDto>( |
|||
totalCount, |
|||
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list) |
|||
); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue