浏览器版本推荐 --迁移

IRC_NewDev
hang 2024-07-02 09:45:18 +08:00
parent 2354ee9174
commit 7c3b0e9e72
8 changed files with 245 additions and 4 deletions

View File

@ -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
{
/// <summary> ExploreRecommendView 列表视图模型 </summary>
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; }
}
///<summary>ExploreRecommendQuery 列表查询参数模型</summary>
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; }
}
///<summary> ExploreRecommendAddOrEdit 列表查询参数模型</summary>
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; }
}
}

View File

@ -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
{
/// <summary>
/// ExploreRecommendService
/// </summary>
[ApiExplorerSettings(GroupName = "Common")]
public class ExploreRecommendService : BaseService, IExploreRecommendService
{
private readonly IRepository<ExploreRecommend> _exploreRecommendRepository;
public ExploreRecommendService(IRepository<ExploreRecommend> exploreRecommendRepository)
{
_exploreRecommendRepository = exploreRecommendRepository;
}
[HttpPost]
public async Task<PageOutput<ExploreRecommendView>> 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<ExploreRecommendView>(_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<IResponseOutput> AddOrUpdateExploreRecommend(ExploreRecommendAddOrEdit addOrEditExploreRecommend)
{
var verifyExp2 = new EntityVerifyExp<ExploreRecommend>()
{
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<IResponseOutput> DeleteExploreRecommend(Guid exploreRecommendId)
{
var success = await _exploreRecommendRepository.DeleteFromQueryAsync(t => t.Id == exploreRecommendId, true);
return ResponseOutput.Ok();
}
[AllowAnonymous]
public async Task<ExploreRecommendView> GetExploreRecommentInfo()
{
var result = await _exploreRecommendRepository.Where(t => t.IsDeleted == false).ProjectTo<ExploreRecommendView>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
if (result == null)
{
throw new QueryBusinessObjectNotExistException("系统浏览器版本推荐未维护,请联系维护人员");
}
return result;
}
}
}

View File

@ -0,0 +1,24 @@
//--------------------------------------------------------------------
// 此代码由T4模板自动生成 byzhouhang 20210918
// 生成时间 2024-07-02 09:27:36
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using IRaCIS.Core.Application.ViewModel;
namespace IRaCIS.Core.Application.Interfaces
{
/// <summary>
/// IExploreRecommendService
/// </summary>
public interface IExploreRecommendService
{
Task<PageOutput<ExploreRecommendView>> GetExploreRecommendList(ExploreRecommendQuery inQuery);
Task<IResponseOutput> AddOrUpdateExploreRecommend(ExploreRecommendAddOrEdit addOrEditExploreRecommend);
Task<IResponseOutput> DeleteExploreRecommend(Guid exploreRecommendId);
}
}

View File

@ -80,8 +80,9 @@ namespace IRaCIS.Core.Application.Service
CreateMap<PublishLog, PublishLogAddOrEdit>().ReverseMap();
CreateMap<PublishLog, PublishVersionSelect>();
CreateMap<ExploreRecommend, ExploreRecommendView>();
CreateMap<ExploreRecommend, ExploreRecommendAddOrEdit>().ReverseMap();
}
}

View File

@ -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
{
///<summary>
///ExploreRecommend
///</summary>
[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; }
}
}

View File

@ -481,6 +481,9 @@ namespace IRaCIS.Core.Infra.EFCore
public virtual DbSet<TrialBodyPart> TrialBodyPart { get; set; }
public virtual DbSet<ExploreRecommend> ExploreRecommend { get; set; }
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
{
// 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因

View File

@ -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 可以配置是否分页
}
#>

View File

@ -65,6 +65,7 @@ namespace IRaCIS.Core.Application.Service
}
<# if(isPage){#>
[HttpPost]
public async Task<PageOutput<<#=tableName#>View>> 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 Task<List<<#=tableName#>View>> Get<#=tableName#>List(<#=tableName#>Query inQuery)
{