update:添加中转等待界面
This commit is contained in:
@@ -9,4 +9,9 @@
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Events\" />
|
||||
<Folder Include="Exceptions\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace QRCodeService.Application.Commands
|
||||
{
|
||||
public class CreateLinkCommand : IRequest<bool>
|
||||
{
|
||||
|
||||
public string SuffixUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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" });
|
||||
|
||||
8
QRCodeService/Views/Go/Index.cshtml
Normal file
8
QRCodeService/Views/Go/Index.cshtml
Normal 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>
|
||||
}
|
||||
Reference in New Issue
Block a user