大版本更新
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.Query;
|
||||
using Yi.Framework.Repository;
|
||||
@@ -19,7 +21,6 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public readonly ILogger<T> _logger;
|
||||
public IBaseService<T> _baseService;
|
||||
public IRepository<T> _repository;
|
||||
|
||||
public BaseCrudController(ILogger<T> logger, IBaseService<T> iBaseService)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -34,7 +35,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:get:one")]
|
||||
[HttpGet]
|
||||
public async Task<Result> Get(object id)
|
||||
public async Task<Result> Get(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
||||
}
|
||||
@@ -71,7 +72,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(T entity)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.InsertReturnEntityAsync(entity));
|
||||
return Result.Success().SetData(await _repository.InsertReturnSnowflakeIdAsync(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -93,7 +94,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:delete:list")]
|
||||
[HttpDelete]
|
||||
public async Task<Result> DeleteList(List<Guid> ids)
|
||||
public async Task<Result> DeleteList(List<long> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.DeleteByLogic(ids));
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class TenantController : BaseCrudController<TenantEntity>
|
||||
{
|
||||
public TenantController(ILogger<TenantEntity> logger, ITenantService iTenantService) : base(logger, iTenantService)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class TestController : ControllerBase
|
||||
{
|
||||
private IStringLocalizer<LocalLanguage> _local;
|
||||
public TestController(ILogger<UserEntity> logger, IUserService iUserService, IStringLocalizer<LocalLanguage> local)
|
||||
{
|
||||
_local = local;
|
||||
}
|
||||
/// <summary>
|
||||
/// 国际化测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result LocalTest()
|
||||
{
|
||||
return Result.Success().SetData(_local["succeed"]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 权限测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Permission("user:get:test")]
|
||||
public Result PermissionTest()
|
||||
{
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 策略授权测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Authorize(PolicyName.Sid)]
|
||||
public Result AutnTest()
|
||||
{
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user