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,6 +9,6 @@ namespace QRCodeService.Application.Commands
{
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请求的地址
/// </summary>
[Route("{shortCode}")]
[ApiController]
public class GoController: ControllerBase
public class GoController: Controller
{
readonly ILinkRepository LinkRepository;
public GoController(ILinkRepository linkRepository)
{
LinkRepository = linkRepository;
}
//readonly ILinkRepository LinkRepository;
//public GoController(ILinkRepository linkRepository)
//{
// LinkRepository = linkRepository;
//}
[HttpGet]
public async Task<IActionResult> Get(string shortcode)
public async Task<IActionResult> Index(string shortcode)
{
var link = await LinkRepository.GetAsync(shortcode);
if (link == null)
{
return NotFound();
}
return Redirect(link.FullUrl);
var a = new { Url = "asdasd" };
//var link = await LinkRepository.GetAsync(shortcode);
return View(a);
}
}
}

View File

@@ -6,6 +6,13 @@
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Logs\**" />
<Content Remove="Logs\**" />
<EmbeddedResource Remove="Logs\**" />
<None Remove="Logs\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Base62-Net" Version="1.2.157201" />
<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.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
//提供等待界面优化用户体验
services.AddControllersWithViews();
services.AddSwaggerGen(c =>
{
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>
}