Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 7ceeb02f

Přidáno uživatelem Vojtěch Bartička před více než 2 roky(ů)

Created TagController, implemented GET on /tags

Zobrazit rozdíly:

Backend/Backend/Controllers/TagController.cs
1
using Core.Services.DocumentService;
2
using Microsoft.AspNetCore.Mvc;
3
using RestAPI.Utils;
4
using System.Net;
5
using Serilog;
6
using ILogger = Serilog.ILogger;
7
using Models.Documents;
8
using RestAPI.Exceptions;
9
using RestAPI.Authentication;
10
using Core.Services.TagService;
11
using Models.Tags;
12

  
13
namespace RestAPI.Controllers;
14

  
15

  
16

  
17
public class TagController : Common.CommonControllerBase
18
{
19
    private readonly ITagService tagService;
20
    private readonly ILogger logger;
21

  
22

  
23
    public TagController(ITagService tagService, ILogger logger)
24
    {
25
        this.tagService = tagService;
26
        this.logger = logger;
27
    }
28

  
29
    [HttpGet("/tags")]
30
    [Authorize]
31
    [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(TagTreeResponse))]
32
    [ProducesResponseType((int)HttpStatusCode.Forbidden)]
33
    public ActionResult<DocumentListResponse> GetTagTree([FromServices] ClientInfo clientInfo)
34
    {
35
        if (clientInfo.LoggedUser == null)
36
        {
37
            logger.Warning("ClientInfo has null LoggerUser in controller /tags");
38
            return Problem();
39
        }
40

  
41
        return Ok(tagService.GetTagTree());
42
    }
43
}
44

  

Také k dispozici: Unified diff