update:添加中转等待界面

This commit is contained in:
2021-02-23 18:08:06 +08:00
parent 43de7445bd
commit cd23716d1b
8 changed files with 55 additions and 18 deletions

View File

@@ -9,4 +9,9 @@
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" /> <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Events\" />
<Folder Include="Exceptions\" />
</ItemGroup>
</Project> </Project>

View File

@@ -9,6 +9,6 @@ namespace QRCodeService.Application.Commands
{ {
public class CreateLinkCommand : IRequest<bool> public class CreateLinkCommand : IRequest<bool>
{ {
public string SuffixUrl { get; set; }
} }
} }

View File

@@ -0,0 +1,21 @@
using FluentValidation;
using Microsoft.Extensions.Logging;
using QRCodeService.Application.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QRCodeService.Application.Validations
{
public class CreateLinkCommandValidator: AbstractValidator<CreateLinkCommand>
{
public CreateLinkCommandValidator(ILogger<CreateLinkCommandValidator> logger)
{
RuleFor(link=>link.SuffixUrl).NotEmpty().WithMessage("No SuffixUrl found");
logger.LogTrace("----- INSTANCE CREATED - {ClassName}", GetType().Name);
}
}
}

View File

@@ -12,23 +12,19 @@ namespace QRCodeService.Controllers
/// 跳转url请求的地址 /// 跳转url请求的地址
/// </summary> /// </summary>
[Route("{shortCode}")] [Route("{shortCode}")]
[ApiController] public class GoController: Controller
public class GoController: ControllerBase
{ {
readonly ILinkRepository LinkRepository; //readonly ILinkRepository LinkRepository;
public GoController(ILinkRepository linkRepository) //public GoController(ILinkRepository linkRepository)
{ //{
LinkRepository = linkRepository; // LinkRepository = linkRepository;
} //}
[HttpGet] [HttpGet]
public async Task<IActionResult> Get(string shortcode) public async Task<IActionResult> Index(string shortcode)
{ {
var link = await LinkRepository.GetAsync(shortcode); var a = new { Url = "asdasd" };
if (link == null) //var link = await LinkRepository.GetAsync(shortcode);
{ return View(a);
return NotFound();
}
return Redirect(link.FullUrl);
} }
} }
} }

View File

@@ -6,6 +6,13 @@
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath> <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Remove="Logs\**" />
<Content Remove="Logs\**" />
<EmbeddedResource Remove="Logs\**" />
<None Remove="Logs\**" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Base62-Net" Version="1.2.157201" /> <PackageReference Include="Base62-Net" Version="1.2.157201" />
<PackageReference Include="Dapper" Version="2.0.78" /> <PackageReference Include="Dapper" Version="2.0.78" />

View File

@@ -32,8 +32,8 @@ namespace QRCodeService
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
//提供等待界面优化用户体验
services.AddControllers(); services.AddControllersWithViews();
services.AddSwaggerGen(c => services.AddSwaggerGen(c =>
{ {
c.SwaggerDoc("v1", new OpenApiInfo { Title = "QRCodeService", Version = "v1" }); c.SwaggerDoc("v1", new OpenApiInfo { Title = "QRCodeService", Version = "v1" });

View File

@@ -0,0 +1,8 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
<div>
loading
</div>
}

View File

@@ -1 +1 @@
施工图审查系统二维码短链生成服务 # 施工图审查系统二维码短链生成服务