修改日志,以及添加项目参与人员
continuous-integration/drone/push Build is passing Details

Uat_IRC_Net8
hang 2024-12-30 11:36:25 +08:00
parent 2a42a921c4
commit b42bf4e201
8 changed files with 18660 additions and 80 deletions

View File

@ -84,6 +84,8 @@ namespace IRaCIS.Core.API
triggerOptions.AddTrigger<UserLogAfterTrigger>();
triggerOptions.AddTrigger<IdenttiyUserRoleInfoTrigger>();
});

View File

@ -407,7 +407,7 @@ namespace IRaCIS.Core.Application.Service
await VerifyUserPwdAsync(identityUserId, newPwd);
var success = await _identityUserRepository.BatchUpdateNoTrackingAsync(t => t.Id == identityUserId, u => new IdentityUser()
await _identityUserRepository.UpdatePartialFromQueryAsync(t => t.Id == identityUserId, u => new IdentityUser()
{
Password = newPwd,
IsFirstAdd = false
@ -416,7 +416,7 @@ namespace IRaCIS.Core.Application.Service
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = identityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.LoginModifyPassword }, true);
return ResponseOutput.Result(success);
return ResponseOutput.Ok();
}
@ -437,7 +437,7 @@ namespace IRaCIS.Core.Application.Service
await VerifyUserNameAsync(_userInfo.IdentityUserId, editPwModel.NewUserName);
await _identityUserRepository.BatchUpdateNoTrackingAsync(t => t.Id == _userInfo.IdentityUserId, u => new IdentityUser()
await _identityUserRepository.UpdatePartialFromQueryAsync(t => t.Id == _userInfo.IdentityUserId, u => new IdentityUser()
{
UserName = editPwModel.NewUserName,
});
@ -916,7 +916,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.BeginDate != null, t => t.CreateTime >= inQuery.BeginDate)
.WhereIf(inQuery.EndDate != null, t => t.CreateTime <= inQuery.EndDate)
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginUserName), t => t.ActionUserName.Contains(inQuery.LoginUserName!))
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginFaildName), t => t.LoginFaildName.Contains(inQuery.LoginFaildName!))
.WhereIf(!string.IsNullOrEmpty(inQuery.LoginFaildName), t => t.ActionUserName.Contains(inQuery.LoginFaildName!))
.WhereIf(!string.IsNullOrEmpty(inQuery.IP), t => t.IP.Contains(inQuery.IP!))
.WhereIf(inQuery.LoginUserTypeEnum != null, t => t.CreateUserRole.UserTypeEnum == inQuery.LoginUserTypeEnum)
.WhereIf(inQuery.UserTypeId != null, t => t.CreateUserRole.UserTypeId == inQuery.UserTypeId)
@ -984,7 +984,7 @@ namespace IRaCIS.Core.Application.Service
if (failCount >= maxFailures)
{
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountLocked }, true);
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.AccountLocked }, true);
//$"密码连续错误{maxFailures}次,当前账号已被限制登录,请等待 {lockoutMinutes} 分钟后再试。"
throw new BusinessValidationFailedException(_localizer["User_ErrorLimit", maxFailures, lockoutMinutes]);
@ -1004,7 +1004,7 @@ namespace IRaCIS.Core.Application.Service
var errorPwdUserId = await _identityUserRepository.Where(u => u.UserName == userName).Select(t => t.Id).FirstOrDefaultAsync();
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginFaildName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError }, true);
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionUserName = userName, LoginPassword = password, OptType = UserOptType.AccountOrPasswordError }, true);
return ResponseOutput.NotOk(_localizer["User_CheckNameOrPw"], new IRCLoginReturnDTO());
@ -1012,7 +1012,7 @@ namespace IRaCIS.Core.Application.Service
if (loginUser.Status == 0)
{
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, LoginFaildName = userName, OptType = UserOptType.LoginLockedAccount }, true);
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = userName, OptType = UserOptType.LoginLockedAccount }, true);
//---该用户已经被禁用。
return ResponseOutput.NotOk(_localizer["User_Disabled"], new IRCLoginReturnDTO());
@ -1136,7 +1136,7 @@ namespace IRaCIS.Core.Application.Service
UserTypeShortName = t.UserTypeRole.UserTypeShortName,
}).FirstOrDefaultAsync();
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = userTokenInfo.IdentityUserId, ActionUserName = $"{userTokenInfo.UserName } ({userTokenInfo.UserTypeShortName})", OptType = UserOptType.LoginSelectRole }, true);
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = userTokenInfo.IdentityUserId, ActionUserName = $"{userTokenInfo.UserName}", ActionUserType=userTokenInfo.UserTypeShortName ,OptType = UserOptType.LoginSelectRole }, true);
if (userTokenInfo != null)
{

View File

@ -16,7 +16,7 @@ namespace IRaCIS.Core.Application.Service
[ApiExplorerSettings(GroupName = "Trial")]
public class TrialService(IRepository<Trial> _trialRepository,
IRepository<TrialUserRole> _trialUserRoleRepository,
IRepository<TrialIdentityUser> _trialIdentityUserRepository,
IRepository<CRO> _croRepository,
IRepository<EnrollDetail> _enrollDetailRepository,
IRepository<Dictionary> _dictionaryRepository,
@ -208,7 +208,14 @@ namespace IRaCIS.Core.Application.Service
//如果是PM 则需要将该人员添加到 运维人员表
//添加运维人员PM
await _trialUserRoleRepository.AddAsync(new TrialUserRole() { TrialId = trial.Id, UserId = _userInfo.UserRoleId, JoinTime = DateTime.Now });
await _trialIdentityUserRepository.AddAsync(new TrialIdentityUser()
{
TrialId = trial.Id,
IdentityUserId = _userInfo.IdentityUserId,
JoinTime = DateTime.Now,
TrialUserRoleList = new List<TrialUserRole>(){
new TrialUserRole(){TrialId=trial.Id,UserId=_userInfo.UserRoleId} }
});
// 添加扩展信息表记录
await _trialPaymentPriceRepository.AddAsync(new TrialPaymentPrice() { TrialId = trial.Id });

View File

@ -0,0 +1,28 @@
using EntityFrameworkCore.Triggered;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Application.Triggers.AfterSaveTrigger
{
public class IdenttiyUserRoleInfoTrigger(IRepository<IdentityUser> _identityUserRepository, IRepository<UserRole> _userRoleRepository) : IAfterSaveTrigger<IdentityUser>
{
public async Task AfterSave(ITriggerContext<IdentityUser> context, CancellationToken cancellationToken)
{
var identityUser = context.Entity;
//保持用户角色表和用户表信息一致
await _userRoleRepository.BatchUpdateNoTrackingAsync(t => t.IdentityUserId == identityUser.Id, u => new UserRole()
{
UserName = identityUser.UserName,
FirstName = identityUser.FirstName,
LastName = identityUser.LastName,
EMail = identityUser.EMail,
});
}
}
}

View File

@ -17,7 +17,6 @@ public class UserLog : BaseAddAuditEntity
#endregion
public string IP { get; set; } = string.Empty;
public string LoginFaildName { get; set; } = string.Empty;
public UserOptType OptType { get; set; }
public string LoginPassword { get; set; } = string.Empty;
@ -30,6 +29,9 @@ public class UserLog : BaseAddAuditEntity
public string ActionUserName { get; set; }
public string ActionUserType { get; set; }
[MaxLength]
public string JsonObj { get; set; }
@ -39,10 +41,18 @@ public class UserLog : BaseAddAuditEntity
#endregion
#region 后续删除
public string LoginFaildName { get; set; } = string.Empty;
[Comment("后续删除")]
public Guid? LoginUserId { get; set; }
[Comment("被操作的人,自己操作的就是自己--后续删除")]
public Guid? OptUserId { get; set; }
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IRaCIS.Core.Infra.EFCore.Migrations
{
/// <inheritdoc />
public partial class UserLogAddUserType : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ActionUserType",
table: "UserLog",
type: "nvarchar(400)",
maxLength: 400,
nullable: false,
defaultValue: "");
migrationBuilder.CreateIndex(
name: "IX_UserLog_ActionIdentityUserId",
table: "UserLog",
column: "ActionIdentityUserId");
migrationBuilder.AddForeignKey(
name: "FK_UserLog_IdentityUser_ActionIdentityUserId",
table: "UserLog",
column: "ActionIdentityUserId",
principalTable: "IdentityUser",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_UserLog_IdentityUser_ActionIdentityUserId",
table: "UserLog");
migrationBuilder.DropIndex(
name: "IX_UserLog_ActionIdentityUserId",
table: "UserLog");
migrationBuilder.DropColumn(
name: "ActionUserType",
table: "UserLog");
}
}
}

View File

@ -12949,6 +12949,11 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<string>("ActionUserType")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<DateTime>("CreateTime")
.HasColumnType("datetime2");
@ -12965,6 +12970,10 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<string>("JsonObj")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LoginFaildName")
.IsRequired()
.HasMaxLength(400)
@ -12992,6 +13001,8 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
b.HasKey("Id");
b.HasIndex("ActionIdentityUserId");
b.HasIndex("CreateUserId");
b.HasIndex("TargetIdentityUserId");
@ -17326,7 +17337,7 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
.IsRequired();
b.HasOne("IRaCIS.Core.Domain.Models.IdentityUser", "IdentityUser")
.WithMany()
.WithMany("UserTrialList")
.HasForeignKey("IdentityUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -17753,6 +17764,10 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
modelBuilder.Entity("IRaCIS.Core.Domain.Models.UserLog", b =>
{
b.HasOne("IRaCIS.Core.Domain.Models.IdentityUser", "ActionIdentityUser")
.WithMany()
.HasForeignKey("ActionIdentityUserId");
b.HasOne("IRaCIS.Core.Domain.Models.UserRole", "CreateUserRole")
.WithMany()
.HasForeignKey("CreateUserId")
@ -17763,77 +17778,10 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
.WithMany()
.HasForeignKey("TargetIdentityUserId");
b.OwnsOne("IRaCIS.Core.Domain.Models.UserLogJsonObj", "JsonObj", b1 =>
{
b1.Property<Guid>("UserLogId")
.HasColumnType("uniqueidentifier");
b1.Property<string>("DepartmentName")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("EMail")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("LastName")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("OrganizationName")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("Phone")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("PositionName")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<int?>("Sex")
.HasColumnType("int");
b1.Property<int>("Status")
.HasColumnType("int");
b1.Property<string>("UserCode")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("UserName")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.HasKey("UserLogId");
b1.ToTable("UserLog");
b1.ToJson("JsonObj");
b1.WithOwner()
.HasForeignKey("UserLogId");
});
b.Navigation("ActionIdentityUser");
b.Navigation("CreateUserRole");
b.Navigation("JsonObj")
.IsRequired();
b.Navigation("TargetIdentityUser");
});
@ -18234,6 +18182,8 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
modelBuilder.Entity("IRaCIS.Core.Domain.Models.IdentityUser", b =>
{
b.Navigation("UserRoleList");
b.Navigation("UserTrialList");
});
modelBuilder.Entity("IRaCIS.Core.Domain.Models.Menu", b =>