Moved guided stuffs

This commit is contained in:
Thomas Fransolet 2025-08-20 14:35:37 +02:00
parent cbf3a3c7f5
commit fd191ec647
4 changed files with 185 additions and 169 deletions

View File

@ -0,0 +1,79 @@
using ManagerService.DTOs;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace ManagerService.Data.SubSection
{
public class GuidedPath // Parcours
{
[Key]
public string Id { get; set; }
[Required]
public string InstanceId { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; }
// Lié à une carte (optionnel)
public string? SectionMapId { get; set; }
[ForeignKey("SectionMapId")]
public SectionMap? SectionMap { get; set; }
// Lié à un événement (optionnel)
public string? SectionEventId { get; set; }
[ForeignKey("SectionEventId")]
public SectionEvent? SectionEvent { get; set; }
// Type de parcours
public bool IsLinear { get; set; } = true; // Avancer dans lordre - Ordre obligatoire
public bool RequireSuccessToAdvance { get; set; } = false; // Par exemple: résoudre une énigme
public bool HideNextStepsUntilComplete { get; set; } = false; // Étapes cachées tant que non terminées
public int Order { get; set; }
public List<GuidedStep> Steps { get; set; } = new();
public GuidedPathDTO ToDTO()
{
return new GuidedPathDTO
{
id = Id,
instanceId = InstanceId,
title = Title,
description = Description,
sectionMapId = SectionMapId,
sectionEventId = SectionEventId,
isLinear = IsLinear,
requireSuccessToAdvance = RequireSuccessToAdvance,
hideNextStepsUntilComplete = HideNextStepsUntilComplete,
order = Order,
steps = Steps?.Select(s => s.ToDTO()).ToList()
};
}
public GuidedPath FromDTO(GuidedPathDTO dto)
{
if (dto == null) return null;
InstanceId = dto.instanceId;
Title = dto.title ?? new List<TranslationDTO>();
Description = dto.description ?? new List<TranslationDTO>();
SectionMapId = dto.sectionMapId;
SectionEventId = dto.sectionEventId;
IsLinear = dto.isLinear;
RequireSuccessToAdvance = dto.requireSuccessToAdvance;
HideNextStepsUntilComplete = dto.hideNextStepsUntilComplete;
Order = dto.order;
//Steps = dto.Steps?.Select(s => s.FromDTO()).ToList() ?? new List<GuidedStep>() // Other method
return this;
}
}
}

View File

@ -0,0 +1,105 @@
using ManagerService.DTOs;
using NetTopologySuite.Geometries;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using ManagerService.Helpers;
namespace ManagerService.Data.SubSection
{
public class GuidedStep // Étape dun parcours
{
[Key]
public string Id { get; set; }
[Required]
public string GuidedPathId { get; set; }
[ForeignKey("GuidedPathId")]
public GuidedPath GuidedPath { get; set; }
public int Order { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; }
public Geometry Geometry { get; set; } // Polygon ou centre du cercle
public double? ZoneRadiusMeters { get; set; } // Optionnel, utile si zone cercle ou point
public string ImageUrl { get; set; }
public int? TriggerGeoPointId { get; set; } // Lieu lié à l'étape et genre si on veut plus d'info ou pourrait afficher les infos du geopoint.
[ForeignKey("TriggerGeoPointId")]
public GeoPoint TriggerGeoPoint { get; set; }
public bool IsHiddenInitially { get; set; } = false;
// Exemple pour escape game
public List<QuizQuestion>? QuizQuestions { get; set; } // One or multiple question
// Option : si true, cette étape a un compte à rebourds, false sinon
public bool IsStepTimer { get; set; } = false;
// Option : si true, cette étape doit être validée avant de passer à la suivante
public bool IsStepLocked { get; set; } = true;
// Timer en secondes (durée max pour valider cette étape, optionnel)
public int? TimerSeconds { get; set; }
// Option : message ou action à effectuer si timer expire (ex: afficher aide, fin du jeu...)
[Column(TypeName = "jsonb")]
public List<TranslationDTO> TimerExpiredMessage { get; set; }
public GuidedStepDTO ToDTO()
{
return new GuidedStepDTO
{
id = Id,
guidedPathId = GuidedPathId,
order = Order,
title = Title,
description = Description,
geometry = Geometry.ToDto(),
zoneRadiusMeters = ZoneRadiusMeters,
imageUrl = ImageUrl,
triggerGeoPointId = TriggerGeoPointId,
triggerGeoPoint = TriggerGeoPoint.ToDTO(),
isHiddenInitially = IsHiddenInitially,
isStepTimer = IsStepTimer,
isStepLocked = IsStepLocked,
timerSeconds = TimerSeconds,
timerExpiredMessage = TimerExpiredMessage,
quizQuestions = QuizQuestions
};
}
public GuidedStep FromDTO(GuidedStepDTO dto)
{
if (dto == null) return null;
GuidedPathId = dto.guidedPathId;
Title = dto.title ?? new List<TranslationDTO>();
Description = dto.description ?? new List<TranslationDTO>();
Geometry = dto.geometry.FromDto();
ZoneRadiusMeters = dto.zoneRadiusMeters;
ImageUrl = dto.imageUrl;
TriggerGeoPointId = dto.triggerGeoPointId;
IsHiddenInitially = dto.isHiddenInitially;
IsStepTimer = dto.isStepTimer;
IsStepLocked = dto.isStepLocked;
TimerSeconds = dto.timerSeconds;
TimerExpiredMessage = dto.timerExpiredMessage ?? new List<TranslationDTO>();
Order = dto.order;
QuizQuestions = dto.quizQuestions;
return this;
}
}
}

View File

@ -148,174 +148,6 @@ namespace ManagerService.Data.SubSection
}
public class GuidedPath // Parcours
{
[Key]
public string Id { get; set; }
[Required]
public string InstanceId { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; }
// Lié à une carte (optionnel)
public string? SectionMapId { get; set; }
[ForeignKey("SectionMapId")]
public SectionMap? SectionMap { get; set; }
// Lié à un événement (optionnel)
public string? SectionEventId { get; set; }
[ForeignKey("SectionEventId")]
public SectionEvent? SectionEvent { get; set; }
// Type de parcours
public bool IsLinear { get; set; } = true; // Avancer dans lordre - Ordre obligatoire
public bool RequireSuccessToAdvance { get; set; } = false; // Par exemple: résoudre une énigme
public bool HideNextStepsUntilComplete { get; set; } = false; // Étapes cachées tant que non terminées
public int Order { get; set; }
public List<GuidedStep> Steps { get; set; } = new();
public GuidedPathDTO ToDTO()
{
return new GuidedPathDTO
{
id = Id,
instanceId = InstanceId,
title = Title,
description = Description,
sectionMapId = SectionMapId,
sectionEventId = SectionEventId,
isLinear = IsLinear,
requireSuccessToAdvance = RequireSuccessToAdvance,
hideNextStepsUntilComplete = HideNextStepsUntilComplete,
order = Order,
steps = Steps?.Select(s => s.ToDTO()).ToList()
};
}
public GuidedPath FromDTO(GuidedPathDTO dto)
{
if (dto == null) return null;
InstanceId = dto.instanceId;
Title = dto.title ?? new List<TranslationDTO>();
Description = dto.description ?? new List<TranslationDTO>();
SectionMapId = dto.sectionMapId;
SectionEventId = dto.sectionEventId;
IsLinear = dto.isLinear;
RequireSuccessToAdvance = dto.requireSuccessToAdvance;
HideNextStepsUntilComplete = dto.hideNextStepsUntilComplete;
Order = dto.order;
//Steps = dto.Steps?.Select(s => s.FromDTO()).ToList() ?? new List<GuidedStep>() // Other method
return this;
}
}
public class GuidedStep // Étape dun parcours
{
[Key]
public string Id { get; set; }
[Required]
public string GuidedPathId { get; set; }
[ForeignKey("GuidedPathId")]
public GuidedPath GuidedPath { get; set; }
public int Order { get; set; }
[Required]
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Title { get; set; }
[Column(TypeName = "jsonb")]
public List<TranslationDTO> Description { get; set; }
public Geometry Geometry { get; set; } // Polygon ou centre du cercle
public double? ZoneRadiusMeters { get; set; } // Optionnel, utile si zone cercle ou point
public string ImageUrl { get; set; }
public int? TriggerGeoPointId { get; set; } // Lieu lié à l'étape et genre si on veut plus d'info ou pourrait afficher les infos du geopoint.
[ForeignKey("TriggerGeoPointId")]
public GeoPoint TriggerGeoPoint { get; set; }
public bool IsHiddenInitially { get; set; } = false;
// Exemple pour escape game
public List<QuizQuestion>? QuizQuestions { get; set; } // One or multiple question
// Option : si true, cette étape a un compte à rebourds, false sinon
public bool IsStepTimer { get; set; } = false;
// Option : si true, cette étape doit être validée avant de passer à la suivante
public bool IsStepLocked { get; set; } = true;
// Timer en secondes (durée max pour valider cette étape, optionnel)
public int? TimerSeconds { get; set; }
// Option : message ou action à effectuer si timer expire (ex: afficher aide, fin du jeu...)
[Column(TypeName = "jsonb")]
public List<TranslationDTO> TimerExpiredMessage { get; set; }
public GuidedStepDTO ToDTO()
{
return new GuidedStepDTO
{
id = Id,
guidedPathId = GuidedPathId,
order = Order,
title = Title,
description = Description,
geometry = Geometry.ToDto(),
zoneRadiusMeters = ZoneRadiusMeters,
imageUrl = ImageUrl,
triggerGeoPointId = TriggerGeoPointId,
triggerGeoPoint = TriggerGeoPoint.ToDTO(),
isHiddenInitially = IsHiddenInitially,
isStepTimer = IsStepTimer,
isStepLocked = IsStepLocked,
timerSeconds = TimerSeconds,
timerExpiredMessage = TimerExpiredMessage,
quizQuestions = QuizQuestions
};
}
public GuidedStep FromDTO(GuidedStepDTO dto)
{
if (dto == null) return null;
GuidedPathId = dto.guidedPathId;
Title = dto.title ?? new List<TranslationDTO>();
Description = dto.description ?? new List<TranslationDTO>();
Geometry = dto.geometry.FromDto();
ZoneRadiusMeters = dto.zoneRadiusMeters;
ImageUrl = dto.imageUrl;
TriggerGeoPointId = dto.triggerGeoPointId;
IsHiddenInitially = dto.isHiddenInitially;
IsStepTimer = dto.isStepTimer;
IsStepLocked = dto.isStepLocked;
TimerSeconds = dto.timerSeconds;
TimerExpiredMessage = dto.timerExpiredMessage ?? new List<TranslationDTO>();
Order = dto.order;
QuizQuestions = dto.quizQuestions;
return this;
}
}
// SectionMap "normal" comme avant => Via geopoints. Si il y a des guidedPath lié à la sectionMap alors il y a un parcours lié à la sectionMap, tu peux aussi avoir des geopoints classique mis là + des parcours. et aussi lier un guidedstep à un geopoint (pour le trigger et aussi pour "afficher plus")
// parcours libre

View File

@ -188,7 +188,7 @@ namespace ManagerService
app.UseCors(
#if DEBUG
options => options
.SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:52172")
.SetIsOriginAllowed(origin => string.IsNullOrEmpty(origin) || origin == "http://localhost:64515")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()