Release v1.0.0 #16
.editorconfig.envnuget.config
.gitea/workflows
.gitignoreApiDto
ApiDto.csproj
Backend.slnDockerfileCommon
AuthRoles.csCacheType.csDatabaseType.csOAuthProvider.csPairPeriodTime.csPasswordPolicy.csTwoFactorAuthentication.cs
Requests
Responses
Endpoint
Backend.httpISaveSettings.cs
README.mdCommon
Attributes
BadRequestResponseAttribute.csCacheMaxAgeAttribute.csLocalhostAttribute.csMaintenanceModeIgnoreAttribute.csNotFoundResponseAttribute.csSwaggerDefaultAttribute.csTokenAuthenticationAttribute.cs
Exceptions
Interfaces
MapperDto
AvailableProvidersConverter.csPairPeriodTimeConverter.csPasswordPolicyConverter.csTwoFactorAuthenticationConverter.cs
Services
Configuration
Core
BackgroundTasks
Middleware
CacheMaxAgeMiddleware.csCookieAuthorizationMiddleware.csCustomExceptionHandlerMiddleware.csJwtRevocationMiddleware.csMaintenanceModeMiddleware.cs
Startup
Model
SwaggerOptions
Validation
Controllers
BaseController.cs
Endpoint.csprojProgram.csConfiguration
V1
AuthController.csCampusController.csDisciplineController.csFacultyController.csGroupController.csImportController.csLectureHallController.csProfessorController.csScheduleController.csSecurityController.cs
WeatherForecastController.csSync
WeatherForecast.cswwwroot/css/swagger
Security
Common
CookieNames.cs
DependencyInjection.csDomain
Caching
CookieOptionsParameters.csOAuth2
OAuthProvider.csOAuthUser.csPasswordPolicy.csRequestContextInfo.csTwoFactorAuthenticator.csUser.csInterfaces
Properties
Security.csprojServices
SqlData
Application
Application.csprojDependencyInjection.cs
Common
Cqrs
Campus/Queries
GetCampusBasicInfoList
CampusBasicInfoDto.csCampusBasicInfoVm.csGetCampusBasicInfoListQuery.csGetCampusBasicInfoListQueryHandler.cs
GetCampusDetails
Discipline/Queries
GetDisciplineDetails
GetDisciplineList
Faculty/Queries/GetFacultyList
Group/Queries
GetGroupDetails
GetGroupList
LectureHall/Queries
GetLectureHallDetails
GetLectureHallList
Professor/Queries
GetProfessorDetails
GetProfessorDetailsBySearch
GetProfessorList
Schedule/Queries/GetScheduleList
Interfaces/DbContexts
Domain
Domain.csproj
Schedule
Migrations
MysqlMigrations
Migrations
20240601023106_InitialMigration.Designer.cs20240601023106_InitialMigration.cs20241027034820_RemoveUnusedRef.Designer.cs20241027034820_RemoveUnusedRef.csUberDbContextModelSnapshot.cs
MysqlMigrations.csprojPsqlMigrations
Migrations
20240601021702_InitialMigration.Designer.cs20240601021702_InitialMigration.cs20241027032753_RemoveUnusedRef.Designer.cs20241027032753_RemoveUnusedRef.csUberDbContextModelSnapshot.cs
PsqlMigrations.csprojSqliteMigrations
Persistence
Common
BaseDbContext.csConfigurationResolver.csDatabaseProvider.csDbContextFactory.csModelBuilderExtensions.cs
Contexts/Schedule
CampusDbContext.csDisciplineDbContext.csFacultyDbContext.csGroupDbContext.csLectureHallDbContext.csLessonAssociationDbContext.csLessonDbContext.csProfessorDbContext.csSpecificWeekDbContext.csTypeOfOccupationDbContext.cs
DbInitializer.csDependencyInjection.csEntityTypeConfigurations
Mark.cs
Persistence.csprojUberDbContext.csMysql/Schedule
CampusConfiguration.csDisciplineConfiguration.csFacultyConfiguration.csGroupConfiguration.csLectureHallConfiguration.csLessonAssociationConfiguration.csLessonConfiguration.csProfessorConfiguration.csSpecificWeekConfiguration.csTypeOfOccupationConfiguration.cs
Postgresql/Schedule
CampusConfiguration.csDisciplineConfiguration.csFacultyConfiguration.csGroupConfiguration.csLectureHallConfiguration.csLessonAssociationConfiguration.csLessonConfiguration.csProfessorConfiguration.csSpecificWeekConfiguration.csTypeOfOccupationConfiguration.cs
Sqlite/Schedule
@ -19,6 +19,7 @@ public static class SwaggerConfiguration
|
|||||||
{
|
{
|
||||||
options.SchemaFilter<SwaggerExampleFilter>();
|
options.SchemaFilter<SwaggerExampleFilter>();
|
||||||
options.OperationFilter<SwaggerDefaultValues>();
|
options.OperationFilter<SwaggerDefaultValues>();
|
||||||
|
options.OperationFilter<ActionResultSchemaFilter>();
|
||||||
var basePath = AppDomain.CurrentDomain.BaseDirectory;
|
var basePath = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
|
||||||
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions;
|
||||||
|
|
||||||
|
public class ActionResultSchemaFilter : IOperationFilter
|
||||||
|
{
|
||||||
|
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||||
|
{
|
||||||
|
var returnType = context.MethodInfo.ReturnType;
|
||||||
|
if (!returnType.IsEquivalentTo(typeof(ActionResult)) &&
|
||||||
|
!returnType.IsEquivalentTo(typeof(ContentResult)) &&
|
||||||
|
!returnType.IsEquivalentTo(typeof(FileStreamResult)) &&
|
||||||
|
!returnType.IsGenericType)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (returnType.IsGenericType &&
|
||||||
|
!returnType.GetGenericTypeDefinition().IsEquivalentTo(typeof(ActionResult<>)) &&
|
||||||
|
!returnType.GetGenericTypeDefinition().IsEquivalentTo(typeof(Task<>)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var genericType = returnType.IsGenericType ? returnType.GetGenericArguments().FirstOrDefault() : returnType;
|
||||||
|
if (genericType == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var responseTypeAttributes = context.MethodInfo.GetCustomAttributes(typeof(ProducesResponseTypeAttribute), false)
|
||||||
|
.Cast<ProducesResponseTypeAttribute>()
|
||||||
|
.Where(attr => attr.StatusCode == 200)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var contentType = "application/json";
|
||||||
|
|
||||||
|
if (context.MethodInfo.GetCustomAttributes(typeof(ProducesAttribute), false)
|
||||||
|
.FirstOrDefault() is ProducesAttribute producesAttribute)
|
||||||
|
contentType = producesAttribute.ContentTypes.FirstOrDefault() ?? "application/json";
|
||||||
|
|
||||||
|
if (responseTypeAttributes.Count != 0)
|
||||||
|
{
|
||||||
|
var responseType = responseTypeAttributes.First().Type;
|
||||||
|
genericType = responseType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (genericType.IsEquivalentTo(typeof(ContentResult)) || genericType.IsEquivalentTo(typeof(FileStreamResult)))
|
||||||
|
{
|
||||||
|
operation.Responses["200"] = new OpenApiResponse
|
||||||
|
{
|
||||||
|
Description = "OK",
|
||||||
|
Content = new Dictionary<string, OpenApiMediaType>
|
||||||
|
{
|
||||||
|
[contentType] = new()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (genericType == typeof(ActionResult))
|
||||||
|
{
|
||||||
|
operation.Responses["200"] = new OpenApiResponse { Description = "OK" };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OpenApiSchema schema;
|
||||||
|
if (genericType.IsGenericType && genericType.GetGenericTypeDefinition() == typeof(ActionResult<>))
|
||||||
|
schema = context.SchemaGenerator.GenerateSchema(genericType.GetGenericArguments().FirstOrDefault(),
|
||||||
|
context.SchemaRepository);
|
||||||
|
else
|
||||||
|
schema = context.SchemaGenerator.GenerateSchema(genericType, context.SchemaRepository);
|
||||||
|
|
||||||
|
operation.Responses["200"] = new OpenApiResponse
|
||||||
|
{
|
||||||
|
Description = "OK",
|
||||||
|
Content = new Dictionary<string, OpenApiMediaType>
|
||||||
|
{
|
||||||
|
[contentType] = new() { Schema = schema }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -48,7 +48,6 @@ public class AuthController(IOptionsSnapshot<Admin> user, IOptionsSnapshot<Gener
|
|||||||
|
|
||||||
[HttpGet("OAuth2")]
|
[HttpGet("OAuth2")]
|
||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
|
|
||||||
[Produces("text/html")]
|
[Produces("text/html")]
|
||||||
[MaintenanceModeIgnore]
|
[MaintenanceModeIgnore]
|
||||||
public async Task<ContentResult> OAuth2([FromQuery] string code, [FromQuery] string state)
|
public async Task<ContentResult> OAuth2([FromQuery] string code, [FromQuery] string state)
|
||||||
|
@ -40,7 +40,7 @@ public class ImportController(IMediator mediator, IOptionsSnapshot<GeneralConfig
|
|||||||
/// <returns>Excel file</returns>
|
/// <returns>Excel file</returns>
|
||||||
[HttpPost("ImportToExcel")]
|
[HttpPost("ImportToExcel")]
|
||||||
[Produces("application/vnd.ms-excel")]
|
[Produces("application/vnd.ms-excel")]
|
||||||
public async Task<IActionResult> ImportToExcel([FromBody] ScheduleRequest request)
|
public async Task<FileStreamResult> ImportToExcel([FromBody] ScheduleRequest request)
|
||||||
{
|
{
|
||||||
var result = (await mediator.Send(new GetScheduleListQuery
|
var result = (await mediator.Send(new GetScheduleListQuery
|
||||||
{
|
{
|
||||||
@ -51,9 +51,6 @@ public class ImportController(IMediator mediator, IOptionsSnapshot<GeneralConfig
|
|||||||
ProfessorIds = request.Professors
|
ProfessorIds = request.Professors
|
||||||
})).Schedules.ToList();
|
})).Schedules.ToList();
|
||||||
|
|
||||||
if (result.Count == 0)
|
|
||||||
return NoContent();
|
|
||||||
|
|
||||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||||
using var package = new ExcelPackage();
|
using var package = new ExcelPackage();
|
||||||
var worksheet = package.Workbook.Worksheets.Add("Расписание");
|
var worksheet = package.Workbook.Worksheets.Add("Расписание");
|
||||||
|
@ -28,7 +28,7 @@ public class SecurityController(IOptionsSnapshot<GeneralConfig> generalConfig) :
|
|||||||
[HttpGet("GenerateTotpQrCode")]
|
[HttpGet("GenerateTotpQrCode")]
|
||||||
[Produces("image/svg+xml")]
|
[Produces("image/svg+xml")]
|
||||||
[MaintenanceModeIgnore]
|
[MaintenanceModeIgnore]
|
||||||
public IActionResult GenerateTotpQrCode(
|
public ContentResult GenerateTotpQrCode(
|
||||||
[FromQuery] string totpKey,
|
[FromQuery] string totpKey,
|
||||||
[FromQuery] string label,
|
[FromQuery] string label,
|
||||||
[FromQuery] string? backgroundColor = null,
|
[FromQuery] string? backgroundColor = null,
|
||||||
|
Reference in New Issue
Block a user