using Tiobon.Core.IServices.BASE;
using Tiobon.Core.Model;
namespace Tiobon.Core.Api.Controllers.Tenant;
///
/// 多租户-多表方案 测试
///
[Produces("application/json")]
[Route("api/Tenant/ByTable")]
[Authorize, ApiExplorerSettings(GroupName = Grouping.GroupName_Other)]
public class TenantByTableController : BaseApiController
{
private readonly IBaseServices _services;
private readonly IUser _user;
public TenantByTableController(IUser user, IBaseServices services)
{
_user = user;
_services = services;
}
///
/// 获取租户下全部业务数据
///
///
[HttpGet]
public async Task>> GetAll()
{
//查询
// var data = await _services.Query();
//关联查询
var data = await _services.Db
.Queryable()
.Includes(s => s.Child)
.ToListAsync();
return Success(data);
}
///
/// 新增数据
///
///
[HttpPost]
public async Task Post(MultiBusinessTable data)
{
await _services.Db.Insertable(data).ExecuteReturnSnowflakeIdAsync();
return Success();
}
}