添加命令数据验证和其他杂项修改
This commit is contained in:
46
QRCodeService/Controllers/Api/LinkController.cs
Normal file
46
QRCodeService/Controllers/Api/LinkController.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Domain.AggregateModel.AppAggregate;
|
||||
using Domain.AggregateModel.LinkAggregate;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QRCodeService.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using QRCodeService.Application.Queries;
|
||||
using QRCodeService.Application.Commands;
|
||||
|
||||
namespace QRCodeService.Controllers.Api
|
||||
{
|
||||
[Route("api/v1/[controller]")]
|
||||
[ApiController]
|
||||
public class LinkController:ControllerBase
|
||||
{
|
||||
readonly IMediator mediator;
|
||||
readonly ILinkQueries queries;
|
||||
|
||||
public LinkController(IMediator mediator, ILinkQueries queries)
|
||||
{
|
||||
this.mediator = mediator;
|
||||
this.queries = queries;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Get()
|
||||
{
|
||||
return Ok();
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create(CreateLinkModel input)
|
||||
{
|
||||
var command = new CreateLinkCommand(input.SuffixUrl,1);
|
||||
var link = await mediator.Send(command);
|
||||
if (link==null)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
return Ok(link.ShortCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user