添加用户协议与隐私政策
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-20 06:17:15Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Collections.Generic;
|
||||
namespace IRaCIS.Core.Application.Service.Document.DTO;
|
||||
|
||||
public class UserAgreementView : UserAgreementAddOrEdit
|
||||
{
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public DateTime UpdateTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class UserAgreementAddOrEdit
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
|
||||
public DateTime EffectiveDate { get; set; }
|
||||
|
||||
public string FileContent { get; set; }
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string FileVersion { get; set; }
|
||||
|
||||
public bool IsCurrentVersion { get; set; }
|
||||
|
||||
public DateTime UpdateDate { get; set; }
|
||||
|
||||
public UserAgreementType UserAgreementTypeEnum { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class SetCurrentVersionInDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
||||
public class UserAgreementQuery:PageInput
|
||||
{
|
||||
public DateTime? StartEffectiveDate { get; set; }
|
||||
|
||||
public DateTime? EndEffectiveDate { get; set; }
|
||||
|
||||
public string? FileContent { get; set; }
|
||||
|
||||
public string? FileName { get; set; }
|
||||
|
||||
public string? FileVersion { get; set; }
|
||||
|
||||
public bool? IsCurrentVersion { get; set; }
|
||||
|
||||
public DateTime? StartUpdateDate { get; set; }
|
||||
|
||||
public DateTime? EndUpdateDate { get; set; }
|
||||
|
||||
public UserAgreementType? UserAgreementTypeEnum { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-20 06:17:15Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using System;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Application.Service.Document.DTO;
|
||||
namespace IRaCIS.Core.Application.Service.Document.Interface;
|
||||
|
||||
public interface IUserAgreementService
|
||||
{
|
||||
|
||||
Task<PageOutput<UserAgreementView>> GetUserAgreementList(UserAgreementQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateUserAgreement(UserAgreementAddOrEdit addOrEditUserAgreement);
|
||||
|
||||
Task<IResponseOutput> DeleteUserAgreement(Guid userAgreementId);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// 此代码由liquid模板自动生成 byzhouhang 20240909
|
||||
// 生成时间 2025-10-20 06:17:11Z
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
|
||||
//--------------------------------------------------------------------
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Application.Service.Document.Interface;
|
||||
using IRaCIS.Core.Application.Service.Document.DTO;
|
||||
namespace IRaCIS.Core.Application.Service;
|
||||
|
||||
/// <summary>
|
||||
/// 用户协议和隐私采集服务
|
||||
/// </summary>
|
||||
/// <param name="_userAgreementRepository"></param>
|
||||
/// <param name="_mapper"></param>
|
||||
/// <param name="_userInfo"></param>
|
||||
/// <param name="_localizer"></param>
|
||||
[ApiExplorerSettings(GroupName = "FileRecord")]
|
||||
public class UserAgreementService(IRepository<UserAgreement> _userAgreementRepository,
|
||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IUserAgreementService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户协议和隐私采集列表
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<UserAgreementView>> GetUserAgreementList(UserAgreementQuery inQuery)
|
||||
{
|
||||
var userAgreementQueryable =_userAgreementRepository
|
||||
.WhereIf(inQuery.StartEffectiveDate.HasValue, t => t.EffectiveDate >= inQuery.StartEffectiveDate.Value)
|
||||
.WhereIf(inQuery.EndEffectiveDate.HasValue, t => t.EffectiveDate <= inQuery.EndEffectiveDate.Value)
|
||||
.WhereIf(inQuery.FileContent != null, t => t.FileContent.Contains(inQuery.FileContent))
|
||||
.WhereIf(inQuery.FileName != null, t => t.FileName.Contains(inQuery.FileName))
|
||||
.WhereIf(inQuery.FileVersion != null, t => t.FileVersion.Contains(inQuery.FileVersion))
|
||||
.WhereIf(inQuery.IsCurrentVersion != null, t => t.IsCurrentVersion==inQuery.IsCurrentVersion)
|
||||
.WhereIf(inQuery.UserAgreementTypeEnum != null, t => t.UserAgreementTypeEnum == inQuery.UserAgreementTypeEnum)
|
||||
.WhereIf(inQuery.StartUpdateDate.HasValue, t => t.UpdateDate >= inQuery.StartUpdateDate.Value)
|
||||
.WhereIf(inQuery.EndUpdateDate.HasValue, t => t.UpdateDate <= inQuery.EndUpdateDate.Value)
|
||||
.ProjectTo<UserAgreementView>(_mapper.ConfigurationProvider);
|
||||
var pageList= await userAgreementQueryable.ToPagedListAsync(inQuery);
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置为当前版本
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<IResponseOutput> SetCurrentVersion(SetCurrentVersionInDto inDto)
|
||||
{
|
||||
var userAgreement=await _userAgreementRepository.Where(x=>x.Id==inDto.Id).FirstNotNullAsync();
|
||||
await _userAgreementRepository.UpdatePartialFromQueryAsync(
|
||||
x => x.UserAgreementTypeEnum== userAgreement.UserAgreementTypeEnum&&x.IsCurrentVersion,
|
||||
x => new UserAgreement { IsCurrentVersion = false },true);
|
||||
|
||||
await _userAgreementRepository.UpdatePartialFromQueryAsync(
|
||||
inDto.Id,
|
||||
x => new UserAgreement { IsCurrentVersion = true },true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增或者修改用户协议和隐私采集
|
||||
/// </summary>
|
||||
/// <param name="addOrEditUserAgreement"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> AddOrUpdateUserAgreement(UserAgreementAddOrEdit addOrEditUserAgreement)
|
||||
{
|
||||
var entity = await _userAgreementRepository.InsertOrUpdateAsync(addOrEditUserAgreement, true);
|
||||
return ResponseOutput.Ok(entity.Id.ToString());
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户协议和隐私采集
|
||||
/// </summary>
|
||||
/// <param name="userAgreementId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{userAgreementId:guid}")]
|
||||
public async Task<IResponseOutput> DeleteUserAgreement(Guid userAgreementId)
|
||||
{
|
||||
var success = await _userAgreementRepository.DeleteFromQueryAsync(t => t.Id == userAgreementId,true);
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using AutoMapper.EquivalencyExpression;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Application.Service.Document.DTO;
|
||||
using IRaCIS.Core.Application.Service.DTO;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
@@ -16,6 +17,11 @@ namespace IRaCIS.Core.Application.Service
|
||||
var userId = Guid.Empty;
|
||||
var isEn_Us = false;
|
||||
|
||||
// 在此处拷贝automapper 映射
|
||||
|
||||
CreateMap<UserAgreement, UserAgreementView>();
|
||||
CreateMap<UserAgreement, UserAgreementAddOrEdit>().ReverseMap();
|
||||
|
||||
// 在此处拷贝automapper 映射
|
||||
CreateMap<TrialDocumentAttachment, TrialDocumentAttachmentView>();
|
||||
CreateMap<TrialDocumentAttachment, TrialDocumentAttachmentAddOrEdit>().ReverseMap();
|
||||
|
||||
@@ -112,7 +112,15 @@ namespace IRaCIS.Application.Contracts
|
||||
/// </summary>
|
||||
public DateTime? LastChangePassWordTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户协议Id
|
||||
/// </summary>
|
||||
public Guid? UserAgreementId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 隐私政策Id
|
||||
/// </summary>
|
||||
public Guid? PrivacyPolicyId { get; set; }
|
||||
}
|
||||
|
||||
public class MenuFuncTreeNodeView
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
public class UserService(IRepository<UserRole> _userRoleRepository,
|
||||
IMailVerificationService _mailVerificationService,
|
||||
IRepository<VerificationCode> _verificationCodeRepository,
|
||||
IRepository<UserAgreement> _userAgreementRepository,
|
||||
IRepository<TrialUserRole> _userTrialRepository,
|
||||
IRepository<UserLog> _userLogRepository,
|
||||
IRepository<UserPassWordLog> _userPassWordLogRepository,
|
||||
@@ -1095,6 +1096,52 @@ namespace IRaCIS.Core.Application.Service
|
||||
//登录成功 清除缓存
|
||||
await _fusionCache.SetAsync(cacheKey, 0, TimeSpan.FromMinutes(lockoutMinutes));
|
||||
|
||||
// 记录同意用户协议以及隐私政策
|
||||
#region 记录同意用户协议以及隐私政策
|
||||
|
||||
var userAgreementList = await _userAgreementRepository.Where(t => t.IsCurrentVersion).OrderByDescending(t => t.CreateTime).ToListAsync();
|
||||
|
||||
var userAgreement= userAgreementList.FirstOrDefault(t => t.UserAgreementTypeEnum == UserAgreementType.UserAgreement);
|
||||
|
||||
if (userAgreement!=null&& loginUser.UserAgreementId!= userAgreement.Id)
|
||||
{
|
||||
await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.IdentityUserId, x => new IdentityUser()
|
||||
{
|
||||
UserAgreementId = userAgreement.Id,
|
||||
});
|
||||
|
||||
var obj = new
|
||||
{
|
||||
UserAgreementTypeEnum = UserAgreementType.UserAgreement,
|
||||
FileVersion=userAgreement.FileVersion,
|
||||
UserAgreementId=userAgreement.Id
|
||||
};
|
||||
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.AcceptUserAgreement, JsonObj= obj.ToJsonStr() }, true);
|
||||
|
||||
}
|
||||
|
||||
var privacyCollection = userAgreementList.FirstOrDefault(t => t.UserAgreementTypeEnum == UserAgreementType.PrivacyCollection);
|
||||
|
||||
if (privacyCollection != null && loginUser.PrivacyPolicyId != privacyCollection.Id)
|
||||
{
|
||||
await _identityUserRepository.BatchUpdateNoTrackingAsync(x => x.Id == loginUser.IdentityUserId, x => new IdentityUser()
|
||||
{
|
||||
PrivacyPolicyId = privacyCollection.Id,
|
||||
});
|
||||
|
||||
var obj = new
|
||||
{
|
||||
UserAgreementTypeEnum = UserAgreementType.PrivacyCollection,
|
||||
FileVersion = privacyCollection.FileVersion,
|
||||
UserAgreementId = privacyCollection.Id
|
||||
};
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.AcceptPrivacyPolicy, JsonObj = obj.ToJsonStr() }, true);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = loginUser.IdentityUserId, ActionUserName = loginUser.UserName, OptType = UserOptType.Login, IsLoginUncommonly = isLoginUncommonly }, true);
|
||||
|
||||
|
||||
@@ -243,8 +243,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
CreateMap<ReadingQuestionTrial, TrialAdditionaQuestion>()
|
||||
.ForMember(d => d.GroupName, u => u.MapFrom(s => s.GroupInfo == null ? s.GroupName : s.GroupInfo.GroupName))
|
||||
.ForMember(d => d.GroupEnName, u => u.MapFrom(s => s.GroupInfo == null ? s.GroupEnName : s.GroupInfo.GroupEnName))
|
||||
.ForMember(d => d.GroupName, u => u.MapFrom(s => s.GroupInfo == null ? string.Empty : s.GroupInfo.GroupName))
|
||||
.ForMember(d => d.GroupEnName, u => u.MapFrom(s => s.GroupInfo == null ? string.Empty : s.GroupInfo.GroupEnName))
|
||||
.ForMember(t => t.PageName, u => u.MapFrom(c => c.ReadingCriterionPage.PageName))
|
||||
.ForMember(d => d.ParentQuestionGenre, u => u.MapFrom(s => s.ParentReadingQuestionTrial.QuestionGenre))
|
||||
.ForMember(d => d.ParentDictionaryCode, u => u.MapFrom(s => s.ParentReadingQuestionTrial.DictionaryCode))
|
||||
@@ -253,8 +253,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
.ForMember(t => t.ParentQuestionShowOrder, u => u.MapFrom(c => c.ParentReadingQuestionTrial.ShowOrder));
|
||||
|
||||
CreateMap<ReadingQuestionTrial, TrialReadQuestion>()
|
||||
.ForMember(d => d.GroupName, u => u.MapFrom(s => s.GroupInfo == null ? s.GroupName : s.GroupInfo.GroupName))
|
||||
.ForMember(d => d.GroupEnName, u => u.MapFrom(s => s.GroupInfo == null ? s.GroupEnName : s.GroupInfo.GroupEnName))
|
||||
.ForMember(d => d.GroupName, u => u.MapFrom(s => s.GroupInfo == null ? string.Empty : s.GroupInfo.GroupName))
|
||||
.ForMember(d => d.GroupEnName, u => u.MapFrom(s => s.GroupInfo == null ? string.Empty : s.GroupInfo.GroupEnName))
|
||||
.ForMember(t => t.PageName, u => u.MapFrom(c => c.ReadingCriterionPage.PageName))
|
||||
.ForMember(d => d.ParentQuestionGenre, u => u.MapFrom(s => s.ParentReadingQuestionTrial.QuestionGenre))
|
||||
.ForMember(d => d.ParentDictionaryCode, u => u.MapFrom(s => s.ParentReadingQuestionTrial.DictionaryCode))
|
||||
|
||||
Reference in New Issue
Block a user