diff --git a/LctMonolith/Controllers/GamificationController.cs b/LctMonolith/Controllers/GamificationController.cs deleted file mode 100644 index 55c9ec9..0000000 --- a/LctMonolith/Controllers/GamificationController.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Security.Claims; -using LctMonolith.Services; -using LctMonolith.Services.Contracts; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace LctMonolith.Controllers; - -/// -/// Endpoints exposing gamification progress information. -/// -[ApiController] -[Route("api/gamification")] -[Authorize] -public class GamificationController : ControllerBase -{ - private readonly IGamificationService _gamificationService; - - public GamificationController(IGamificationService gamificationService) - { - _gamificationService = gamificationService; - } - - private Guid GetUserId() => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!); - - /// Returns current user progress snapshot (rank, xp, outstanding requirements). - [HttpGet("progress")] - public async Task GetProgress(CancellationToken ct) - { - var snapshot = await _gamificationService.GetProgressAsync(GetUserId(), ct); - return Ok(snapshot); - } -} - diff --git a/LctMonolith/Controllers/InventoryController.cs b/LctMonolith/Controllers/InventoryController.cs deleted file mode 100644 index 5c88260..0000000 --- a/LctMonolith/Controllers/InventoryController.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Security.Claims; -using LctMonolith.Services; -using LctMonolith.Services.Contracts; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace LctMonolith.Controllers; - -/// -/// Inventory endpoints for viewing owned store items and artifacts. -/// -[ApiController] -[Route("api/inventory")] -[Authorize] -public class InventoryController : ControllerBase -{ - private readonly IInventoryService _inventory; - public InventoryController(IInventoryService inventory) - { - _inventory = inventory; - } - - private Guid GetUserId() => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!); - - /// List owned store inventory entries. - [HttpGet("store-items")] - public async Task GetStoreItems(CancellationToken ct) - { - var items = await _inventory.GetStoreInventoryAsync(GetUserId(), ct); - return Ok(items.Select(i => new { i.StoreItemId, i.Quantity, i.AcquiredAt, i.IsReturned, i.StoreItem?.Name })); - } - - /// List owned artifacts. - [HttpGet("artifacts")] - public async Task GetArtifacts(CancellationToken ct) - { - var artifacts = await _inventory.GetArtifactsAsync(GetUserId(), ct); - return Ok(artifacts.Select(a => new { a.ArtifactId, a.ObtainedAt, a.Artifact?.Name, a.Artifact?.Rarity })); - } -} - diff --git a/LctMonolith/Controllers/MissionsController.cs b/LctMonolith/Controllers/MissionsController.cs deleted file mode 100644 index 8cf5ffb..0000000 --- a/LctMonolith/Controllers/MissionsController.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Security.Claims; -using LctMonolith.Models.Database; -using LctMonolith.Services; -using LctMonolith.Services.Contracts; -using LctMonolith.Services.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace LctMonolith.Controllers; - -/// -/// Endpoints for listing and managing missions. -/// -[ApiController] -[Route("api/missions")] -[Authorize] -public class MissionsController : ControllerBase -{ - private readonly IMissionService _missionService; - - public MissionsController(IMissionService missionService) - { - _missionService = missionService; - } - - private Guid GetUserId() => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!); - - /// Returns missions currently available to the authenticated user. - [HttpGet] - public async Task>> GetAvailable(CancellationToken ct) - { - var userId = GetUserId(); - var list = await _missionService.GetAvailableMissionsAsync(userId, ct); - return Ok(list); - } - - /// Create a mission (HR functionality – for now any authenticated user). - [HttpPost] - public async Task> Create(CreateMissionModel model, CancellationToken ct) - { - var mission = await _missionService.CreateMissionAsync(model, ct); - return CreatedAtAction(nameof(GetAvailable), new { id = mission.Id }, mission); - } - - /// Update mission status for current user (submit/complete/etc.). - [HttpPatch("{missionId:guid}/status")] - public async Task UpdateStatus(Guid missionId, UpdateMissionStatusRequest req, CancellationToken ct) - { - var userId = GetUserId(); - var result = await _missionService.UpdateStatusAsync(userId, missionId, req.Status, req.SubmissionData, ct); - return Ok(new { result.MissionId, result.Status, result.UpdatedAt }); - } -} diff --git a/LctMonolith/Database/Data/DbSeeder.cs b/LctMonolith/Database/Data/DbSeeder.cs index d490835..56f7904 100644 --- a/LctMonolith/Database/Data/DbSeeder.cs +++ b/LctMonolith/Database/Data/DbSeeder.cs @@ -18,21 +18,21 @@ public static class DbSeeder { var ranks = new List { - new() { Name = "Искатель", Order = 0, RequiredExperience = 0 }, - new() { Name = "Пилот-кандидат", Order = 1, RequiredExperience = 500 }, - new() { Name = "Принятый в экипаж", Order = 2, RequiredExperience = 1500 } + new() { Title = "Искатель", ExpNeeded = 0 }, + new() { Title = "Пилот-кандидат", ExpNeeded = 500 }, + new() { Title = "Принятый в экипаж", ExpNeeded = 1500 } }; db.Ranks.AddRange(ranks); Log.Information("Seeded {Count} ranks", ranks.Count); } - if (!await db.Competencies.AnyAsync(ct)) + if (!await db.Skills.AnyAsync(ct)) { var comps = new[] { "Вера в дело","Стремление к большему","Общение","Аналитика","Командование","Юриспруденция","Трёхмерное мышление","Базовая экономика","Основы аэронавигации" - }.Select(n => new Competency { Name = n }); - db.Competencies.AddRange(comps); + }.Select(n => new Skill { Title = n }); + db.Skills.AddRange(comps); Log.Information("Seeded competencies"); } diff --git a/LctMonolith/Models/Database/AppUser.cs b/LctMonolith/Models/Database/AppUser.cs index 4339360..e343d02 100644 --- a/LctMonolith/Models/Database/AppUser.cs +++ b/LctMonolith/Models/Database/AppUser.cs @@ -13,8 +13,8 @@ public class AppUser : IdentityUser public Rank? Rank { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; - public ICollection Competencies { get; set; } = new List(); - public ICollection Missions { get; set; } = new List(); + public ICollection Competencies { get; set; } = new List(); + public ICollection Missions { get; set; } = new List(); public ICollection Inventory { get; set; } = new List(); public ICollection Transactions { get; set; } = new List(); public ICollection RefreshTokens { get; set; } = new List(); diff --git a/LctMonolith/Program.cs b/LctMonolith/Program.cs index 9b59c11..7aa941a 100644 --- a/LctMonolith/Program.cs +++ b/LctMonolith/Program.cs @@ -95,11 +95,8 @@ builder.Services.AddScoped(); // Domain services builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.Services.AddScoped(); builder.Services.AddScoped(); // CORS diff --git a/LctMonolith/Services/AnalyticsService.cs b/LctMonolith/Services/AnalyticsService.cs index 42b721a..0f7a161 100644 --- a/LctMonolith/Services/AnalyticsService.cs +++ b/LctMonolith/Services/AnalyticsService.cs @@ -17,16 +17,12 @@ public class AnalyticsService : IAnalyticsService { var totalUsers = await _uow.Users.Query().CountAsync(ct); var totalMissions = await _uow.Missions.Query().CountAsync(ct); - var completedMissions = await _uow.UserMissions.Query(um => um.Status == MissionStatus.Completed).CountAsync(ct); - var totalArtifacts = await _uow.Artifacts.Query().CountAsync(ct); var totalStoreItems = await _uow.StoreItems.Query().CountAsync(ct); var totalExperience = await _uow.Users.Query().SumAsync(u => (long)u.Experience, ct); return new AnalyticsSummary { TotalUsers = totalUsers, TotalMissions = totalMissions, - CompletedMissions = completedMissions, - TotalArtifacts = totalArtifacts, TotalStoreItems = totalStoreItems, TotalExperience = totalExperience }; diff --git a/LctMonolith/Services/Contracts/IAnalyticsService.cs b/LctMonolith/Services/Contracts/IAnalyticsService.cs index 6276fd4..1a589f4 100644 --- a/LctMonolith/Services/Contracts/IAnalyticsService.cs +++ b/LctMonolith/Services/Contracts/IAnalyticsService.cs @@ -1,7 +1,5 @@ using LctMonolith.Services.Models; -using LctMonolith.Services.Models; - namespace LctMonolith.Services; public interface IAnalyticsService diff --git a/LctMonolith/Services/Contracts/IInventoryService.cs b/LctMonolith/Services/Contracts/IInventoryService.cs index f76df92..760fbc4 100644 --- a/LctMonolith/Services/Contracts/IInventoryService.cs +++ b/LctMonolith/Services/Contracts/IInventoryService.cs @@ -5,5 +5,4 @@ namespace LctMonolith.Services.Contracts; public interface IInventoryService { Task> GetStoreInventoryAsync(Guid userId, CancellationToken ct = default); - Task> GetArtifactsAsync(Guid userId, CancellationToken ct = default); } diff --git a/LctMonolith/Services/Models/UpdateMissionStatusRequest.cs b/LctMonolith/Services/Models/UpdateMissionStatusRequest.cs deleted file mode 100644 index a27ac93..0000000 --- a/LctMonolith/Services/Models/UpdateMissionStatusRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -using LctMonolith.Models.Database; - -namespace LctMonolith.Services.Models; - -public class UpdateMissionStatusRequest -{ - public MissionStatus Status { get; set; } - public string? SubmissionData { get; set; } -} diff --git a/LctMonolith/Services/TokenService.cs b/LctMonolith/Services/TokenService.cs index 6871849..3e5bd37 100644 --- a/LctMonolith/Services/TokenService.cs +++ b/LctMonolith/Services/TokenService.cs @@ -10,7 +10,6 @@ using LctMonolith.Services.Models; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; -using Serilog; namespace LctMonolith.Services;