manager-service/ManagerService/Data/ApplicationInstance.cs
Thomas Fransolet 4e17c572ba Nom d'app, drapeau QR et liens stores par application
ApplicationInstance porte désormais AppName (traductions, jsonb),
IsQRCodeEnabled (défaut true) et les liens App Store / Play Store.
Une ligne existe par (instance, type d'app) : chaque réglage vaut
donc séparément pour le mobile et pour le web.

Les liens stores ne sont modifiables que par un SuperAdmin — c'est
Unov qui publie les apps —, contrôlé côté API et pas seulement masqué
dans l'UI.

La liste anonyme des apps expose le slug web et le nom de l'instance :
la page /download de visitapp-web n'a que l'instanceId d'un QR imprimé.

Réserve les slugs download, demo et api : un segment statique de
visitapp-web l'emporte sur [slug], l'instance serait inaccessible.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 11:42:07 +02:00

132 lines
4.5 KiB
C#

using Manager.DTOs;
using ManagerService.Data.SubSection;
using ManagerService.DTOs;
using ManagerService.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace ManagerService.Data
{
/// <summary>
/// Defines the link between an application instance and a configuration,
/// allowing apps to use one or multiple configurations.
/// </summary>
[Index(nameof(InstanceId))]
[Index(nameof(InstanceId), nameof(AppType), IsUnique = true)]
public class ApplicationInstance : IAuditableEntity
{
[Key]
public string Id { get; set; }
[Required]
public string InstanceId { get; set; }
public DateTime DateCreation { get; set; }
public DateTime DateUpdate { get; set; }
[Required]
public AppType AppType { get; set; }
public List<AppConfigurationLink> Configurations { get; set; }
public string MainImageId { get; set; } // Specific Mobile et web(?)
public string MainImageUrl { get; set; } // Specific Mobile et web(?)
public string LoaderImageId { get; set; } // Specific Mobile et web
public string LoaderImageUrl { get; set; } // Specific Mobile et web
public string PrimaryColor { get; set; } // Specific Mobile et web
public string SecondaryColor { get; set; } // Specific Mobile et web
public List<string> Languages { get; set; } // All app must support languages, if not, client's problem
public string? SectionEventId { get; set; } // Specific Mobile et web(?)
[ForeignKey("SectionEventId")]
public SectionEvent? SectionEvent { get; set; } // => To Display in large a event with countdown (in mobile app).
public bool IsAssistant { get; set; } = false;
public bool IsQRCodeEnabled { get; set; } = true;
public List<TranslationDTO>? AppName { get; set; } // Specific Mobile et web
// Chaque client a sa propre app publiée par Unov : seul un SuperAdmin les modifie.
public string? AppStoreUrl { get; set; } // Specific Mobile
public string? PlayStoreUrl { get; set; } // Specific Mobile
public ApplicationInstanceDTO ToDTO(MyInfoMateDbContext myInfoMateDbContext)
{
SectionEventDTO sectionEventDTO = null;
if (SectionEventId != null)
{
SectionEvent = myInfoMateDbContext.Sections.OfType<SectionEvent>().FirstOrDefault(s => s.Id == SectionEventId);
sectionEventDTO = SectionEvent != null ? SectionFactory.ToDTO(SectionEvent) as SectionEventDTO : null;
}
return new ApplicationInstanceDTO()
{
id = Id,
instanceId = InstanceId,
appType = AppType,
configurations = Configurations,
mainImageId = MainImageId,
mainImageUrl = MainImageUrl,
loaderImageId = LoaderImageId,
loaderImageUrl = LoaderImageUrl,
primaryColor = PrimaryColor,
secondaryColor = SecondaryColor,
languages = Languages,
sectionEventId = SectionEventId,
sectionEventDTO = sectionEventDTO,
isAssistant = IsAssistant,
isQRCodeEnabled = IsQRCodeEnabled,
appName = AppName,
appStoreUrl = AppStoreUrl,
playStoreUrl = PlayStoreUrl
};
}
public ApplicationInstance FromDTO(ApplicationInstanceDTO dto)
{
InstanceId = dto.instanceId;
AppType = dto.appType;
MainImageId = dto.mainImageId;
MainImageUrl = dto.mainImageUrl;
LoaderImageId = dto.loaderImageId;
LoaderImageUrl = dto.loaderImageUrl;
PrimaryColor = dto.primaryColor;
SecondaryColor = dto.secondaryColor;
Languages = dto.languages;
Configurations = dto.configurations;
SectionEventId = dto.sectionEventId;
IsAssistant = dto.isAssistant;
IsQRCodeEnabled = dto.isQRCodeEnabled;
AppName = dto.appName;
AppStoreUrl = dto.appStoreUrl;
PlayStoreUrl = dto.playStoreUrl;
return this;
}
}
public enum AppType
{
Mobile,
Tablet,
Web,
VR,
Voice // Lunettes Ray-Ban Meta / interface vocale — pas de navigation UI
}
}