Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6b12620
✨feat: Add new JsonConverter
IseduardoRezende Sep 6, 2025
fabe05e
📦build: Update nuget packages
IseduardoRezende Sep 6, 2025
1c5ae45
♻️refactor: Update Employees DTOS
IseduardoRezende Sep 6, 2025
2ae7368
✨feat: Add EnumUtils
IseduardoRezende Sep 6, 2025
20e03be
✨feat: Add ValidationUtils
IseduardoRezende Sep 6, 2025
5e135af
♻️refactor: Update ErrorUtils
IseduardoRezende Sep 6, 2025
9dea427
♻️refactor: Update Employee Enums
IseduardoRezende Sep 6, 2025
efe1d23
✨feat: Add EmployeeFilter
IseduardoRezende Sep 6, 2025
96b4c1b
♻️refactor: Update EmployeeRepository
IseduardoRezende Sep 6, 2025
ef88067
♻️refactor: Update EmployeeService
IseduardoRezende Sep 6, 2025
943a035
♻️refactor: Update Employee Validators
IseduardoRezende Sep 6, 2025
5725fd1
♻️refactor: Update EmployeeController
IseduardoRezende Sep 6, 2025
7f840ce
Merge pull request #5 from OneBus/dev-eduardo
IseduardoRezende Sep 6, 2025
0206af8
📦build: Update nuget packages
IseduardoRezende Sep 20, 2025
55c6169
✨feat: Add Messages.resx
IseduardoRezende Sep 20, 2025
e7771af
✨feat: Add ResourceMgr
IseduardoRezende Sep 20, 2025
aecd918
♻️refactor: Update DbQueryOptions
IseduardoRezende Sep 20, 2025
f1c4864
♻️refactor: Update Enums values
IseduardoRezende Sep 20, 2025
4b5edda
✨feat: Add LocalizationExtensions
IseduardoRezende Sep 20, 2025
c64fd8d
✨feat: Add EmployeeFilter
IseduardoRezende Sep 20, 2025
5b2457a
✨feat: Add EmployeeWorkday Repository
IseduardoRezende Sep 20, 2025
c592c57
♻️refactor: Update DependencyInjection
IseduardoRezende Sep 20, 2025
4911770
♻️refactor: Update Employee DTOs
IseduardoRezende Sep 20, 2025
a430416
♻️refactor: Update EmployeeWorkday DTOs
IseduardoRezende Sep 20, 2025
3b09d40
♻️refactor: Update BaseReadOnly Service
IseduardoRezende Sep 20, 2025
48bd656
♻️refactor: Update Employee Service
IseduardoRezende Sep 20, 2025
852a397
✨feat: Add EmployeeWorkday Service
IseduardoRezende Sep 20, 2025
9368e0e
🧹cleanup: Remove EnumUtils
IseduardoRezende Sep 20, 2025
0aaed46
♻️refactor: Update Employee Validators
IseduardoRezende Sep 20, 2025
0df9a8e
✨feat: Update EmployeeWorkday Validators
IseduardoRezende Sep 20, 2025
ee2965e
♻️refactor: Update Controllers
IseduardoRezende Sep 20, 2025
7698b95
Merge pull request #6 from OneBus/dev-eduardo
IseduardoRezende Sep 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions OneBus.API/Controllers/EmployeeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace OneBus.API.Controllers
{
[NonController]
[Route("api/v1/employees")]
[ApiController]
[Produces("application/json")]
Expand Down Expand Up @@ -102,9 +101,9 @@ public async Task<IActionResult> DeleteAsync([FromRoute] long id, CancellationTo
/// <response code="200">Funcionários paginados e filtrados com sucesso</response>
[HttpGet]
[ProducesResponseType(typeof(SuccessResult<Pagination<ReadEmployeeDTO>>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
public async Task<IActionResult> GetPaginedAsync([FromQuery] EmployeeFilter filter, CancellationToken cancellationToken = default)
{
return (await _employeeService.GetPaginedAsync(filter, cancellationToken)).ToActionResult();
return (await _employeeService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
}

/// <summary>
Expand All @@ -123,7 +122,52 @@ public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult<ReadEmployeeDTO>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
return (await _employeeService.GetByIdAsync(id, cancellationToken)).ToActionResult();
return (await _employeeService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
}

/// <summary>
/// Listar status
/// </summary>
/// <remarks>
/// GET de status
/// </remarks>
/// <returns>Status disponíveis</returns>
/// <response code="200">Status retornados com sucesso</response>
[HttpGet("status")]
[ProducesResponseType(typeof(SuccessResult<IEnumerable<ReadStatusDTO>>), StatusCodes.Status200OK)]
public IActionResult GetStatus()
{
return _employeeService.GetStatus().ToActionResult();
}

/// <summary>
/// Listar cargos
/// </summary>
/// <remarks>
/// GET de cargos
/// </remarks>
/// <returns>Cargos disponíveis</returns>
/// <response code="200">Cargos retornados com sucesso</response>
[HttpGet("roles")]
[ProducesResponseType(typeof(SuccessResult<IEnumerable<ReadRoleDTO>>), StatusCodes.Status200OK)]
public IActionResult GetRoles()
{
return _employeeService.GetRoles().ToActionResult();
}

/// <summary>
/// Listar tipos sanguíneos
/// </summary>
/// <remarks>
/// GET de tipos sanguíneos
/// </remarks>
/// <returns>Tipos sanguíneos disponíveis</returns>
/// <response code="200">Tipos sanguíneos retornados com sucesso</response>
[HttpGet("bloodTypes")]
[ProducesResponseType(typeof(SuccessResult<IEnumerable<ReadBloodTypeDTO>>), StatusCodes.Status200OK)]
public IActionResult GetBloodTypes()
{
return _employeeService.GetBloodTypes().ToActionResult();
}
}
}
26 changes: 22 additions & 4 deletions OneBus.API/Controllers/EmployeeWorkdayController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace OneBus.API.Controllers
{
[NonController]
[Route("api/v1/employeesWorkdays")]
[ApiController]
[Produces("application/json")]
Expand Down Expand Up @@ -102,9 +101,11 @@ public async Task<IActionResult> DeleteAsync([FromRoute] long id, CancellationTo
/// <response code="200">Horários dos Funcionários paginados e filtrados com sucesso</response>
[HttpGet]
[ProducesResponseType(typeof(SuccessResult<Pagination<ReadEmployeeWorkdayDTO>>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
public async Task<IActionResult> GetPaginedAsync([FromQuery] EmployeeWorkDayFilter filter, CancellationToken cancellationToken = default)
{
return (await _employeeWorkdayService.GetPaginedAsync(filter, cancellationToken)).ToActionResult();
return (await _employeeWorkdayService.GetPaginedAsync(filter,
DbQueryOptions.Create(["Employee"]),
cancellationToken)).ToActionResult();
}

/// <summary>
Expand All @@ -123,7 +124,24 @@ public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult<ReadEmployeeWorkdayDTO>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
return (await _employeeWorkdayService.GetByIdAsync(id, cancellationToken)).ToActionResult();
return (await _employeeWorkdayService.GetByIdAsync(id,
DbQueryOptions.Create(["Employee"]),
cancellationToken)).ToActionResult();
}

/// <summary>
/// Listar tipos de dias
/// </summary>
/// <remarks>
/// GET de tipos de dias
/// </remarks>
/// <returns>Tipos de Dias disponíveis</returns>
/// <response code="200">Status retornados com sucesso</response>
[HttpGet("daysTypes")]
[ProducesResponseType(typeof(SuccessResult<IEnumerable<ReadDayTypeDTO>>), StatusCodes.Status200OK)]
public IActionResult GetDaysTypes()
{
return _employeeWorkdayService.GetDaysTypes().ToActionResult();
}
}
}
4 changes: 2 additions & 2 deletions OneBus.API/Controllers/LineController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task<IActionResult> DeleteAsync([FromRoute] long id, CancellationTo
[ProducesResponseType(typeof(SuccessResult<Pagination<ReadLineDTO>>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
{
return (await _lineService.GetPaginedAsync(filter, cancellationToken)).ToActionResult();
return (await _lineService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
}

/// <summary>
Expand All @@ -123,7 +123,7 @@ public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult<ReadLineDTO>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
return (await _lineService.GetByIdAsync(id, cancellationToken)).ToActionResult();
return (await _lineService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
}
}
}
4 changes: 2 additions & 2 deletions OneBus.API/Controllers/LineTimeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task<IActionResult> DeleteAsync([FromRoute] long id, CancellationTo
[ProducesResponseType(typeof(SuccessResult<Pagination<ReadLineTimeDTO>>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
{
return (await _lineTimeService.GetPaginedAsync(filter, cancellationToken)).ToActionResult();
return (await _lineTimeService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
}

/// <summary>
Expand All @@ -123,7 +123,7 @@ public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult<ReadLineTimeDTO>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
return (await _lineTimeService.GetByIdAsync(id, cancellationToken)).ToActionResult();
return (await _lineTimeService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
}
}
}
4 changes: 2 additions & 2 deletions OneBus.API/Controllers/MaintenanceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task<IActionResult> DeleteAsync([FromRoute] long id, CancellationTo
[ProducesResponseType(typeof(SuccessResult<Pagination<ReadMaintenanceDTO>>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
{
return (await _maintenanceService.GetPaginedAsync(filter, cancellationToken)).ToActionResult();
return (await _maintenanceService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
}

/// <summary>
Expand All @@ -123,7 +123,7 @@ public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult<ReadMaintenanceDTO>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
return (await _maintenanceService.GetByIdAsync(id, cancellationToken)).ToActionResult();
return (await _maintenanceService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
}
}
}
2 changes: 1 addition & 1 deletion OneBus.API/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public UserController(IUserService userService)
/// Efetuar login
/// </summary>
/// <remarks>
/// Example:
/// Exemplo:
///
/// POST /logins
/// {
Expand Down
6 changes: 3 additions & 3 deletions OneBus.API/Controllers/VehicleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public VehicleController(IVehicleService vehicleService)
[ProducesResponseType(typeof(InvalidResult<ReadVehicleDTO>), StatusCodes.Status422UnprocessableEntity)]
public async Task<IActionResult> CreateAsync([FromBody] CreateVehicleDTO createDTO, CancellationToken cancellationToken = default)
{
return (await _vehicleService.CreateAsync(createDTO, cancellationToken)).ToActionResult();
return (await _vehicleService.CreateAsync(createDTO, cancellationToken: cancellationToken)).ToActionResult();
}

/// <summary>
Expand Down Expand Up @@ -104,7 +104,7 @@ public async Task<IActionResult> DeleteAsync([FromRoute] long id, CancellationTo
[ProducesResponseType(typeof(SuccessResult<Pagination<ReadVehicleDTO>>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
{
return (await _vehicleService.GetPaginedAsync(filter, cancellationToken)).ToActionResult();
return (await _vehicleService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
}

/// <summary>
Expand All @@ -123,7 +123,7 @@ public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult<ReadVehicleDTO>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
return (await _vehicleService.GetByIdAsync(id, cancellationToken)).ToActionResult();
return (await _vehicleService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
}
}
}
4 changes: 2 additions & 2 deletions OneBus.API/Controllers/VehicleOperationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task<IActionResult> DeleteAsync([FromRoute] long id, CancellationTo
[ProducesResponseType(typeof(SuccessResult<Pagination<ReadVehicleOperationDTO>>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
{
return (await _vehicleOperationService.GetPaginedAsync(filter, cancellationToken)).ToActionResult();
return (await _vehicleOperationService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
}

/// <summary>
Expand All @@ -123,7 +123,7 @@ public async Task<IActionResult> GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult<ReadVehicleOperationDTO>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
return (await _vehicleOperationService.GetByIdAsync(id, cancellationToken)).ToActionResult();
return (await _vehicleOperationService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
}
}
}
18 changes: 18 additions & 0 deletions OneBus.API/Converters/TrimmingJsonConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace OneBus.API.Converters
{
public class TrimmingJsonConverter : JsonConverter<string>
{
public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetString()?.Trim()!;
}

public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
{
writer.WriteStringValue(value);
}
}
}
14 changes: 7 additions & 7 deletions OneBus.API/OneBus.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.8" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.9" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.22.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="9.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="9.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="9.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 10 additions & 8 deletions OneBus.API/Program.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
using System.Text;
using OneBus.Infra.Ioc;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Http.Json;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using OneBus.API.Converters;
using OneBus.API.Handlers;
using OneBus.Domain.Settings;
using Microsoft.OpenApi.Models;
using OneBus.Infra.Data.DbContexts;
using Microsoft.EntityFrameworkCore;
using OneBus.Infra.Ioc;
using System.Text;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http.Json;
using Microsoft.IdentityModel.Tokens;
using Microsoft.AspNetCore.Authentication.JwtBearer;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container:

builder.Services
.AddControllers()
.AddJsonOptions(c => c.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
.AddJsonOptions(c => c.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()))
.AddJsonOptions(c => c.JsonSerializerOptions.Converters.Add(new TrimmingJsonConverter()));

// Configuring json visualization for Enums
builder.Services.Configure<JsonOptions>(options =>
Expand Down
35 changes: 35 additions & 0 deletions OneBus.Application/DTOs/Employee/CreateEmployeeDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,40 @@
{
public class CreateEmployeeDTO : BaseCreateDTO
{
public CreateEmployeeDTO()
{
Name = string.Empty;
Rg = string.Empty;
Cpf = string.Empty;
Code = string.Empty;
Email = string.Empty;
Phone = string.Empty;
}

public string Name { get; set; }

public string Rg { get; set; }

public string Cpf { get; set; }

public byte? BloodType { get; set; }

public string Code { get; set; }

public byte Role { get; set; }

public string Email { get; set; }

public string Phone { get; set; }

public DateOnly HiringDate { get; set; }

public string? CnhNumber { get; set; }

public DateOnly? CnhExpiration { get; set; }

public byte Status { get; set; }

public byte[]? Image { get; set; }
}
}
14 changes: 14 additions & 0 deletions OneBus.Application/DTOs/Employee/ReadBloodTypeDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace OneBus.Application.DTOs.Employee
{
public class ReadBloodTypeDTO
{
public ReadBloodTypeDTO()
{
Name = string.Empty;
}

public byte Value { get; set; }

public string Name { get; set; }
}
}
Loading