diff --git a/IRaCIS.Core.Application/Service/Common/DTO/ExploreRecommendViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/ExploreRecommendViewModel.cs new file mode 100644 index 000000000..b87cfc9e7 --- /dev/null +++ b/IRaCIS.Core.Application/Service/Common/DTO/ExploreRecommendViewModel.cs @@ -0,0 +1,67 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2024-07-02 09:29:36 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- +using System; +using IRaCIS.Core.Domain.Share; +using System.Collections.Generic; +namespace IRaCIS.Core.Application.ViewModel +{ + /// ExploreRecommendView 列表视图模型 + public class ExploreRecommendView + { + public Guid Id { get; set; } + public string Version { get; set; } + public string Title { get; set; } + public DateTime CreateTime { get; set; } + public Guid CreateUserId { get; set; } + public Guid UpdateUserId { get; set; } + public DateTime UpdateTime { get; set; } + public bool IsDeleted { get; set; } + public string DownloadUrl { get; set; } + public string Path { get; set; } + public string FileName { get; set; } + public DateTime? DeleteTime { get; set; } + public Guid? DeleteUserId { get; set; } + } + + ///ExploreRecommendQuery 列表查询参数模型 + public class ExploreRecommendQuery:PageInput + { + + public string? Version { get; set; } + + + public string? Title { get; set; } + + + public string? DownloadUrl { get; set; } + + + public string? FileName { get; set; } + + public bool? IsDeleted { get; set; } + + } + + /// ExploreRecommendAddOrEdit 列表查询参数模型 + public class ExploreRecommendAddOrEdit + { + public Guid Id { get; set; } + public string Version { get; set; } + public string Title { get; set; } + public DateTime CreateTime { get; set; } + public Guid CreateUserId { get; set; } + public Guid UpdateUserId { get; set; } + public DateTime UpdateTime { get; set; } + public bool IsDeleted { get; set; } + public string DownloadUrl { get; set; } + public string Path { get; set; } + public string FileName { get; set; } + } + + +} + + diff --git a/IRaCIS.Core.Application/Service/Common/ExploreRecommendService.cs b/IRaCIS.Core.Application/Service/Common/ExploreRecommendService.cs new file mode 100644 index 000000000..76d181268 --- /dev/null +++ b/IRaCIS.Core.Application/Service/Common/ExploreRecommendService.cs @@ -0,0 +1,92 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2024-07-02 09:26:59 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + +using IRaCIS.Core.Domain.Models; +using Microsoft.AspNetCore.Mvc; +using IRaCIS.Core.Application.Interfaces; +using IRaCIS.Core.Application.ViewModel; +using Microsoft.AspNetCore.Authorization; +namespace IRaCIS.Core.Application.Service +{ + /// + /// ExploreRecommendService + /// + [ApiExplorerSettings(GroupName = "Common")] + public class ExploreRecommendService : BaseService, IExploreRecommendService + { + + private readonly IRepository _exploreRecommendRepository; + + public ExploreRecommendService(IRepository exploreRecommendRepository) + { + _exploreRecommendRepository = exploreRecommendRepository; + } + + [HttpPost] + public async Task> GetExploreRecommendList(ExploreRecommendQuery inQuery) + { + + var exploreRecommendQueryable = + + _exploreRecommendRepository + .WhereIf(string.IsNullOrEmpty(inQuery.Title), t => t.Title.Contains(inQuery.Title)) + .WhereIf(string.IsNullOrEmpty(inQuery.FileName), t => t.Title.Contains(inQuery.FileName)) + .WhereIf(string.IsNullOrEmpty(inQuery.DownloadUrl), t => t.Title.Contains(inQuery.DownloadUrl)) + .WhereIf(string.IsNullOrEmpty(inQuery.Version), t => t.Title.Contains(inQuery.Version)) + .WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == t.IsDeleted) + .ProjectTo(_mapper.ConfigurationProvider); + + var pageList = await exploreRecommendQueryable + .ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(ExploreRecommendView.Id) : inQuery.SortField, + inQuery.Asc); + + return pageList; + } + + + public async Task AddOrUpdateExploreRecommend(ExploreRecommendAddOrEdit addOrEditExploreRecommend) + { + var verifyExp2 = new EntityVerifyExp() + { + VerifyExp = u => u.IsDeleted == addOrEditExploreRecommend.IsDeleted, + + VerifyMsg = "当前启用版本只允许有一个", + + IsVerify = addOrEditExploreRecommend.IsDeleted == false + }; + + var entity = await _exploreRecommendRepository.InsertOrUpdateAsync(addOrEditExploreRecommend, true, verifyExp2); + + return ResponseOutput.Ok(entity.Id.ToString()); + + } + + + [HttpDelete("{exploreRecommendId:guid}")] + public async Task DeleteExploreRecommend(Guid exploreRecommendId) + { + var success = await _exploreRecommendRepository.DeleteFromQueryAsync(t => t.Id == exploreRecommendId, true); + return ResponseOutput.Ok(); + } + + [AllowAnonymous] + public async Task GetExploreRecommentInfo() + { + + + var result = await _exploreRecommendRepository.Where(t => t.IsDeleted == false).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); + + if (result == null) + { + throw new QueryBusinessObjectNotExistException("系统浏览器版本推荐未维护,请联系维护人员"); + } + + return result; + } + + + } +} diff --git a/IRaCIS.Core.Application/Service/Common/Interface/IExploreRecommendService.cs b/IRaCIS.Core.Application/Service/Common/Interface/IExploreRecommendService.cs new file mode 100644 index 000000000..2dc5556b2 --- /dev/null +++ b/IRaCIS.Core.Application/Service/Common/Interface/IExploreRecommendService.cs @@ -0,0 +1,24 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2024-07-02 09:27:36 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + +using IRaCIS.Core.Application.ViewModel; +namespace IRaCIS.Core.Application.Interfaces +{ + /// + /// IExploreRecommendService + /// + public interface IExploreRecommendService + { + + Task> GetExploreRecommendList(ExploreRecommendQuery inQuery); + + Task AddOrUpdateExploreRecommend(ExploreRecommendAddOrEdit addOrEditExploreRecommend); + + Task DeleteExploreRecommend(Guid exploreRecommendId); + + + } +} diff --git a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs index 7312de9f9..916cabf1f 100644 --- a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs @@ -80,8 +80,9 @@ namespace IRaCIS.Core.Application.Service CreateMap().ReverseMap(); CreateMap(); - + CreateMap(); + CreateMap().ReverseMap(); } } diff --git a/IRaCIS.Core.Domain/Common/ExploreRecommend.cs b/IRaCIS.Core.Domain/Common/ExploreRecommend.cs new file mode 100644 index 000000000..db000e174 --- /dev/null +++ b/IRaCIS.Core.Domain/Common/ExploreRecommend.cs @@ -0,0 +1,53 @@ + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2024-07-02 09:26:43 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +using System; +using IRaCIS.Core.Domain.Share; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +namespace IRaCIS.Core.Domain.Models +{ + /// + ///ExploreRecommend + /// + [Table("ExploreRecommend")] + public class ExploreRecommend : Entity, IAuditUpdate, IAuditAdd,ISoftDelete + { + + public string Version { get; set; }=string.Empty; + + + public string Title { get; set; } = string.Empty; + + + public DateTime CreateTime { get; set; } + + + public Guid CreateUserId { get; set; } + + + public Guid UpdateUserId { get; set; } + + + public DateTime UpdateTime { get; set; } + + + public bool IsDeleted { get; set; } + + + public string DownloadUrl { get; set; } = string.Empty; + + + public string Path { get; set; } = string.Empty; + + public string FileName { get; set; } = string.Empty; + + public DateTime? DeletedTime { get; set; } + + public Guid? DeleteUserId { get; set; } + + } + +} diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 913ae7a94..c5e8715c7 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -481,6 +481,9 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet TrialBodyPart { get; set; } + public virtual DbSet ExploreRecommend { get; set; } + + public override async Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()) { // 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因 diff --git a/IRaCIS.Core.Test/DbHelper.ttinclude b/IRaCIS.Core.Test/DbHelper.ttinclude index 93d6bd2d6..649ef03e0 100644 --- a/IRaCIS.Core.Test/DbHelper.ttinclude +++ b/IRaCIS.Core.Test/DbHelper.ttinclude @@ -4,7 +4,7 @@ public static readonly string ConnectionString = "Server=106.14.89.110,1435;Database=Test_IRC;User ID=sa;Password=xc@123456;TrustServerCertificate=true"; public static readonly string DbDatabase = "Test_IRC"; //表名称用字符串,拼接 - public static readonly string TableName = "TrialBodyPart"; + public static readonly string TableName = "ExploreRecommend"; //具体文件里面 例如service 可以配置是否分页 } #> diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS .Core.ServiceAsync.tt b/IRaCIS.Core.Test/TT_Template/IRaCIS .Core.ServiceAsync.tt index fa5c367b7..5a1998a61 100644 --- a/IRaCIS.Core.Test/TT_Template/IRaCIS .Core.ServiceAsync.tt +++ b/IRaCIS.Core.Test/TT_Template/IRaCIS .Core.ServiceAsync.tt @@ -65,6 +65,7 @@ namespace IRaCIS.Core.Application.Service } <# if(isPage){#> + [HttpPost] public async TaskView>> Get<#=tableName#>List(<#=tableName#>Query inQuery) { @@ -74,13 +75,13 @@ namespace IRaCIS.Core.Application.Service .ProjectTo<<#=tableName#>View>(_mapper.ConfigurationProvider); var pageList= await <#=char.ToLower(tableName[0]) + tableName.Substring(1)#>Queryable - .ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? "Id" : inQuery.SortField, + .ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(<#=tableName#>View.Id) : inQuery.SortField, inQuery.Asc); return pageList; } <# } else {#> - + [HttpPost] public async TaskView>> Get<#=tableName#>List(<#=tableName#>Query inQuery) {