From cd23716d1b6a57bf86c07635bc7fefaef5b23365 Mon Sep 17 00:00:00 2001 From: zhangqi <2794379662@qq.com> Date: Tue, 23 Feb 2021 18:08:06 +0800 Subject: [PATCH] =?UTF-8?q?update:=E6=B7=BB=E5=8A=A0=E4=B8=AD=E8=BD=AC?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Domain/Domain.csproj | 5 ++++ .../Application/Commands/CreateLinkCommand.cs | 2 +- .../Validations/CreateLinkCommandValidator.cs | 21 ++++++++++++++++ QRCodeService/Controllers/GoController.cs | 24 ++++++++----------- QRCodeService/QRCodeService.csproj | 7 ++++++ QRCodeService/Startup.cs | 4 ++-- QRCodeService/Views/Go/Index.cshtml | 8 +++++++ README.md | 2 +- 8 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 QRCodeService/Application/Validations/CreateLinkCommandValidator.cs create mode 100644 QRCodeService/Views/Go/Index.cshtml diff --git a/Domain/Domain.csproj b/Domain/Domain.csproj index 27b30d8..ca8eba3 100644 --- a/Domain/Domain.csproj +++ b/Domain/Domain.csproj @@ -9,4 +9,9 @@ + + + + + diff --git a/QRCodeService/Application/Commands/CreateLinkCommand.cs b/QRCodeService/Application/Commands/CreateLinkCommand.cs index 9f7315c..4c616a9 100644 --- a/QRCodeService/Application/Commands/CreateLinkCommand.cs +++ b/QRCodeService/Application/Commands/CreateLinkCommand.cs @@ -9,6 +9,6 @@ namespace QRCodeService.Application.Commands { public class CreateLinkCommand : IRequest { - + public string SuffixUrl { get; set; } } } diff --git a/QRCodeService/Application/Validations/CreateLinkCommandValidator.cs b/QRCodeService/Application/Validations/CreateLinkCommandValidator.cs new file mode 100644 index 0000000..88e65ec --- /dev/null +++ b/QRCodeService/Application/Validations/CreateLinkCommandValidator.cs @@ -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 + { + public CreateLinkCommandValidator(ILogger logger) + { + RuleFor(link=>link.SuffixUrl).NotEmpty().WithMessage("No SuffixUrl found"); + + logger.LogTrace("----- INSTANCE CREATED - {ClassName}", GetType().Name); + } + } +} diff --git a/QRCodeService/Controllers/GoController.cs b/QRCodeService/Controllers/GoController.cs index 4011744..f95a034 100644 --- a/QRCodeService/Controllers/GoController.cs +++ b/QRCodeService/Controllers/GoController.cs @@ -12,23 +12,19 @@ namespace QRCodeService.Controllers /// 跳转url请求的地址 /// [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 Get(string shortcode) + public async Task 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); } } } diff --git a/QRCodeService/QRCodeService.csproj b/QRCodeService/QRCodeService.csproj index c860cfc..fe86347 100644 --- a/QRCodeService/QRCodeService.csproj +++ b/QRCodeService/QRCodeService.csproj @@ -6,6 +6,13 @@ ..\docker-compose.dcproj + + + + + + + diff --git a/QRCodeService/Startup.cs b/QRCodeService/Startup.cs index 62ef8cb..734409d 100644 --- a/QRCodeService/Startup.cs +++ b/QRCodeService/Startup.cs @@ -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" }); diff --git a/QRCodeService/Views/Go/Index.cshtml b/QRCodeService/Views/Go/Index.cshtml new file mode 100644 index 0000000..76fcc76 --- /dev/null +++ b/QRCodeService/Views/Go/Index.cshtml @@ -0,0 +1,8 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +
+ loading +
+} diff --git a/README.md b/README.md index 1488dca..1d0e864 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -施工图审查系统二维码短链生成服务 \ No newline at end of file +# 施工图审查系统二维码短链生成服务 \ No newline at end of file