TenantController.cs 1.9 KB
Newer Older
S
simon 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Aurora.Tenant.IService;
using Aurora.Tenant.IService.Dto;
using Aurora.Infrastructure.Response;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace Aurora.Tenant.Api.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    public class TenantController : ControllerBase
    {
        private readonly ILogger<TenantController> _logger;
        private readonly ITenantService _tenantService;

        public TenantController(ILogger<TenantController> logger,
        ITenantService TenantService)
        {
            _logger = logger;
            _tenantService = TenantService;
        }

        [HttpGet]
        /// <summary>
        /// get tenants list
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> GetList()
        {
            var res = await _tenantService.GetList();
            return Ok(res);
        }

        [HttpGet]
        /// <summary>
        /// get tenant by id
        /// </summary>
        /// <returns></returns>
        public async Task<ResponseModel<TenantUserDto>> GetById(int id)
        {
            var res = await _tenantService.GetById(id);
            return res;
        }
lwplvx's avatar
lwplvx 已提交
48 49 50 51 52 53 54 55 56 57 58
     
        [HttpGet]
        /// <summary>
        /// get tenant by current request url
        /// </summary>
        /// <returns></returns>
        public async Task<ResponseModel<TenantUserDto>> GetByUrl(string url)
        {
            var res = await _tenantService.GetById(id);
            return res;
        }
S
simon 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71

        [HttpPost]
        /// <summary>
        /// add tenant
        /// </summary>
        /// <returns></returns>
        public async Task<ResponseModel<TenantUserDto>> Add(TenantUserDto model)
        {
            var res = await _tenantService.Add(model);
            return res;
        }
    }
}