21 changed files with 3284 additions and 22 deletions
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
|
|||
namespace Win_in.Sfs.Auth.Application.Contracts; |
|||
|
|||
public class PageLockDto : SfsAuthDtoBase |
|||
{ |
|||
/// <summary>
|
|||
/// 菜单代码
|
|||
/// </summary>
|
|||
public string MenuCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户账户
|
|||
/// </summary>
|
|||
public string UserAccount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 登录时间
|
|||
/// </summary>
|
|||
public string LoginTime { get; set; } |
|||
|
|||
} |
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Win_in.Sfs.Auth.Application.Contracts; |
|||
|
|||
public interface IPageLockAppService : ISfsAuthCrudAppService<PageLockDto, SfsAuthRequestInputBase, PageLockCreateInput> |
|||
{ |
|||
Task LockLoginAsync(string menuCode,string userAccount); |
|||
Task LockLogoutAsync(string menuCode, string userAccount); |
|||
} |
@ -0,0 +1,5 @@ |
|||
namespace Win_in.Sfs.Auth.Application.Contracts; |
|||
|
|||
public class PageLockCreateInput : PageLockCreateUpdateInputBase |
|||
{ |
|||
} |
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
|
|||
namespace Win_in.Sfs.Auth.Application.Contracts; |
|||
|
|||
public abstract class PageLockCreateUpdateInputBase : SfsAuthCreateUpdateInputBase |
|||
{ |
|||
/// <summary>
|
|||
/// 菜单代码
|
|||
/// </summary>
|
|||
public string MenuCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户账户
|
|||
/// </summary>
|
|||
public string UserAccount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 登录时间
|
|||
/// </summary>
|
|||
public string LoginTime { get; set; } |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Win_in.Sfs.Auth.Application.Contracts; |
|||
|
|||
public class PageLockUpdateInput : PageLockCreateUpdateInputBase, IHasConcurrencyStamp |
|||
{ |
|||
/// <summary>
|
|||
/// 乐观锁
|
|||
/// </summary>
|
|||
[Display(Name = "乐观锁")] |
|||
[Required(ErrorMessage = "{0}是必填项")] |
|||
public string ConcurrencyStamp { get; set; } |
|||
} |
@ -0,0 +1,27 @@ |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Win_in.Sfs.Auth.Domain; |
|||
using Win_in.Sfs.Auth.Permissions; |
|||
|
|||
namespace Win_in.Sfs.Auth.Application.Contracts; |
|||
|
|||
public static class PageLockPermissions |
|||
{ |
|||
public const string Default = AuthPermissions.GroupName + "." + nameof(PageLock); |
|||
public const string Create = Default + "." + AuthPermissions.CreateStr; |
|||
public const string Update = Default + "." + AuthPermissions.UpdateStr; |
|||
public const string Delete = Default + "." + AuthPermissions.DeleteStr; |
|||
|
|||
//POA菜单
|
|||
public const string PageLock = AuthPermissions.GroupName + "." + nameof(PageLock); |
|||
|
|||
public static void AddPageLockPermission(this PermissionGroupDefinition permissionGroup) |
|||
{ |
|||
var PageLockPermission = permissionGroup.AddPermission(Default, AuthPermissionDefinitionProvider.L(nameof(PageLock))); |
|||
PageLockPermission.AddChild(Create, AuthPermissionDefinitionProvider.L(AuthPermissions.CreateStr)); |
|||
PageLockPermission.AddChild(Update, AuthPermissionDefinitionProvider.L(AuthPermissions.UpdateStr)); |
|||
PageLockPermission.AddChild(Delete, AuthPermissionDefinitionProvider.L(AuthPermissions.DeleteStr)); |
|||
|
|||
permissionGroup.AddPermission(PageLock, AuthPermissionDefinitionProvider.L(nameof(PageLock))); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,76 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using DocumentFormat.OpenXml.Office2010.Excel; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Volo.Abp.PermissionManagement; |
|||
using Volo.Abp.Uow; |
|||
using Volo.Abp.Users; |
|||
using Win_in.Sfs.Auth.Application.Contracts; |
|||
using Win_in.Sfs.Auth.Domain; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
|
|||
namespace Win_in.Sfs.Auth.Application; |
|||
|
|||
[AllowAnonymous] |
|||
[Route($"{AuthConsts.RootPath}page-lock")] |
|||
public class PageLockAppService : |
|||
SfsAuthCrudAppServiceBase<PageLock, PageLockDto, SfsAuthRequestInputBase, PageLockCreateInput>, |
|||
IPageLockAppService |
|||
{ |
|||
|
|||
public PageLockAppService( |
|||
IPageLockRepository repository) : base(repository) |
|||
{ |
|||
base.CreatePolicyName = PageLockPermissions.Create; |
|||
base.UpdatePolicyName = PageLockPermissions.Update; |
|||
base.DeletePolicyName = PageLockPermissions.Delete; |
|||
} |
|||
|
|||
[HttpGet("lock-login")] |
|||
[AllowAnonymous] |
|||
[UnitOfWork] |
|||
public async Task LockLoginAsync(string menuCode,string userAccount) |
|||
{ |
|||
var pageLock=await _repository.GetListAsync(p=>p.MenuCode==menuCode).ConfigureAwait(false); |
|||
if (pageLock.Count == 1&& pageLock.First().UserAccount== userAccount) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
if (pageLock.Count>1) |
|||
{ |
|||
throw new UserFriendlyException($"该页面已被多人锁定锁定,请联系管理员清除锁定信息"); |
|||
} |
|||
|
|||
if (pageLock.Count == 1 && userAccount != pageLock.First().UserAccount) |
|||
{ |
|||
throw new UserFriendlyException($"该页面已被{pageLock.First().UserAccount}用户锁定"); |
|||
} |
|||
|
|||
await _repository.InsertAsync(new PageLock() |
|||
{ |
|||
UserAccount = userAccount, |
|||
LoginTime = DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm"), |
|||
MenuCode = menuCode |
|||
}).ConfigureAwait(false); |
|||
} |
|||
|
|||
[HttpGet("lock-logout")] |
|||
[AllowAnonymous] |
|||
[UnitOfWork] |
|||
public async Task LockLogoutAsync(string menuCode, string userAccount) |
|||
{ |
|||
var pageLock = await _repository.GetListAsync(p => p.MenuCode == menuCode&&p.UserAccount==userAccount).ConfigureAwait(false); |
|||
if (pageLock.Count==1) |
|||
{ |
|||
await _repository.DeleteAsync(pageLock.First()).ConfigureAwait(false); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
using AutoMapper; |
|||
using Volo.Abp.AutoMapper; |
|||
using Win_in.Sfs.Auth.Application.Contracts; |
|||
using Win_in.Sfs.Auth.Domain; |
|||
|
|||
namespace Win_in.Sfs.Auth.Application; |
|||
|
|||
public class PageLockAutoMapperProfile : Profile |
|||
{ |
|||
public PageLockAutoMapperProfile() |
|||
{ |
|||
CreateMap<PageLock, PageLockDto>() |
|||
.IgnoreAuditedObjectProperties() |
|||
; |
|||
|
|||
CreateMap<PageLockCreateInput, PageLock>() |
|||
.IgnoreAuditedObjectProperties() |
|||
.Ignore(x => x.ConcurrencyStamp) |
|||
.Ignore(x => x.Id) |
|||
; |
|||
|
|||
CreateMap<PageLockUpdateInput, PageLock>() |
|||
.IgnoreAuditedObjectProperties() |
|||
|
|||
.Ignore(x => x.Id) |
|||
; |
|||
; |
|||
} |
|||
} |
@ -0,0 +1,5 @@ |
|||
namespace Win_in.Sfs.Auth.Domain; |
|||
|
|||
public interface IPageLockRepository : ISfsAuthRepository<PageLock> |
|||
{ |
|||
} |
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using Win_in.Sfs.Auth.Domain; |
|||
|
|||
namespace Win_in.Sfs.Auth.Domain; |
|||
|
|||
public class PageLock : SfsAuthAggregateRootBase |
|||
{ |
|||
/// <summary>
|
|||
/// 菜单代码
|
|||
/// </summary>
|
|||
public string MenuCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户账户
|
|||
/// </summary>
|
|||
public string UserAccount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 登录时间
|
|||
/// </summary>
|
|||
public string LoginTime { get; set; } |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,237 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace Win_in.Sfs.Auth.Migrations |
|||
{ |
|||
public partial class Added_PageLock : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Remark", |
|||
table: "Auth_UserWorkGroup", |
|||
type: "nvarchar(3072)", |
|||
maxLength: 3072, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(max)", |
|||
oldMaxLength: 4096, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Remark", |
|||
table: "Auth_UserMenu", |
|||
type: "nvarchar(3072)", |
|||
maxLength: 3072, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(max)", |
|||
oldMaxLength: 4096, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Portal", |
|||
table: "Auth_UserMenu", |
|||
type: "nvarchar(64)", |
|||
maxLength: 64, |
|||
nullable: false, |
|||
oldClrType: typeof(int), |
|||
oldType: "int"); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Status", |
|||
table: "Auth_Menu", |
|||
type: "nvarchar(64)", |
|||
maxLength: 64, |
|||
nullable: false, |
|||
defaultValue: "Enable", |
|||
oldClrType: typeof(int), |
|||
oldType: "int", |
|||
oldDefaultValue: 1); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Remark", |
|||
table: "Auth_Menu", |
|||
type: "nvarchar(3072)", |
|||
maxLength: 3072, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(max)", |
|||
oldMaxLength: 4096, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Portal", |
|||
table: "Auth_Menu", |
|||
type: "nvarchar(64)", |
|||
maxLength: 64, |
|||
nullable: false, |
|||
oldClrType: typeof(int), |
|||
oldType: "int"); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Component", |
|||
table: "Auth_Menu", |
|||
type: "nvarchar(1024)", |
|||
maxLength: 1024, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(64)", |
|||
oldMaxLength: 64, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Remark", |
|||
table: "Auth_Department", |
|||
type: "nvarchar(3072)", |
|||
maxLength: 3072, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(max)", |
|||
oldMaxLength: 4096, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Description", |
|||
table: "Auth_Department", |
|||
type: "nvarchar(1024)", |
|||
maxLength: 1024, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(max)", |
|||
oldMaxLength: 4096, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "Auth_PageLock", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
MenuCode = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), |
|||
UserAccount = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
LoginTime = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
Remark = table.Column<string>(type: "nvarchar(3072)", maxLength: 3072, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_Auth_PageLock", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_Auth_PageLock_MenuCode", |
|||
table: "Auth_PageLock", |
|||
column: "MenuCode", |
|||
unique: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "Auth_PageLock"); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Remark", |
|||
table: "Auth_UserWorkGroup", |
|||
type: "nvarchar(max)", |
|||
maxLength: 4096, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(3072)", |
|||
oldMaxLength: 3072, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Remark", |
|||
table: "Auth_UserMenu", |
|||
type: "nvarchar(max)", |
|||
maxLength: 4096, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(3072)", |
|||
oldMaxLength: 3072, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<int>( |
|||
name: "Portal", |
|||
table: "Auth_UserMenu", |
|||
type: "int", |
|||
nullable: false, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(64)", |
|||
oldMaxLength: 64); |
|||
|
|||
migrationBuilder.AlterColumn<int>( |
|||
name: "Status", |
|||
table: "Auth_Menu", |
|||
type: "int", |
|||
nullable: false, |
|||
defaultValue: 1, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(64)", |
|||
oldMaxLength: 64, |
|||
oldDefaultValue: "Enable"); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Remark", |
|||
table: "Auth_Menu", |
|||
type: "nvarchar(max)", |
|||
maxLength: 4096, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(3072)", |
|||
oldMaxLength: 3072, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<int>( |
|||
name: "Portal", |
|||
table: "Auth_Menu", |
|||
type: "int", |
|||
nullable: false, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(64)", |
|||
oldMaxLength: 64); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Component", |
|||
table: "Auth_Menu", |
|||
type: "nvarchar(64)", |
|||
maxLength: 64, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(1024)", |
|||
oldMaxLength: 1024, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Remark", |
|||
table: "Auth_Department", |
|||
type: "nvarchar(max)", |
|||
maxLength: 4096, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(3072)", |
|||
oldMaxLength: 3072, |
|||
oldNullable: true); |
|||
|
|||
migrationBuilder.AlterColumn<string>( |
|||
name: "Description", |
|||
table: "Auth_Department", |
|||
type: "nvarchar(max)", |
|||
maxLength: 4096, |
|||
nullable: true, |
|||
oldClrType: typeof(string), |
|||
oldType: "nvarchar(1024)", |
|||
oldMaxLength: 1024, |
|||
oldNullable: true); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.Modeling; |
|||
using Win_in.Sfs.Auth.Domain; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
using Win_in.Sfs.Shared.EntityFrameworkCore; |
|||
|
|||
namespace Win_in.Sfs.Auth.EntityFrameworkCore; |
|||
|
|||
public static class PageLockDbContextModelCreatingExtensions |
|||
{ |
|||
public static void ConfigurePageLock(this ModelBuilder builder, AuthModelBuilderConfigurationOptions options) |
|||
{ |
|||
builder.Entity<PageLock>(b => |
|||
{ |
|||
//Configure table & schema name
|
|||
b.ToTable(options.TablePrefix + nameof(PageLock), options.Schema); |
|||
b.ConfigureByConvention(); |
|||
b.ConfigureSfsBase(); |
|||
|
|||
//Properties
|
|||
b.Property(q => q.MenuCode).IsRequired().HasMaxLength(64); |
|||
|
|||
//Indexes
|
|||
b.HasIndex(q => new { q.MenuCode }).IsUnique(); |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Win_in.Sfs.Auth.Domain; |
|||
|
|||
namespace Win_in.Sfs.Auth.EntityFrameworkCore; |
|||
|
|||
public class PageLockEfCoreRepository : SfsAuthEfCoreRepositoryBase<AuthDbContext, PageLock>, IPageLockRepository |
|||
{ |
|||
public PageLockEfCoreRepository(IDbContextProvider<AuthDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
} |
Loading…
Reference in new issue