From c8372e7f1e8933d0b6958619d2a9e439a82175ba Mon Sep 17 00:00:00 2001 From: tleodev Date: Sun, 18 May 2025 22:26:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Initialization=20of=20micro=20se?= =?UTF-8?q?rvices=20+=20add=20Catalog=20svc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 801 ++++++++++++++++++ OptifitWebServices.sln | 34 + docker-compose.yml | 11 + src/CatalogService/CatalogService.csproj | 23 + src/CatalogService/CatalogService.http | 6 + .../DTOs/CreateExerciceTemplateDto.cs | 19 + src/CatalogService/Data/CatalogDbContext.cs | 13 + src/CatalogService/Data/DbInitializer.cs | 77 ++ ...16_InitialialCreate Catalog DB.Designer.cs | 61 ++ ...50514124016_InitialialCreate Catalog DB.cs | 40 + .../CatalogDbContextModelSnapshot.cs | 58 ++ src/CatalogService/Entities/Exercice.cs | 22 + src/CatalogService/Program.cs | 30 + .../Properties/launchSettings.json | 14 + .../appsettings.Development.json | 11 + src/CatalogService/appsettings.json | 9 + src/DTOs/ExerciceTemplateDto.cs | 15 + src/Shared/DTOs/ExerciceTemplateDto.cs | 6 + src/Shared/Entities/EntityBase.cs | 8 + src/Shared/Enum/ETarget.cs | 11 + src/Shared/Shared.csproj | 9 + 21 files changed, 1278 insertions(+) create mode 100644 .gitignore create mode 100644 OptifitWebServices.sln create mode 100644 docker-compose.yml create mode 100644 src/CatalogService/CatalogService.csproj create mode 100644 src/CatalogService/CatalogService.http create mode 100644 src/CatalogService/DTOs/CreateExerciceTemplateDto.cs create mode 100644 src/CatalogService/Data/CatalogDbContext.cs create mode 100644 src/CatalogService/Data/DbInitializer.cs create mode 100644 src/CatalogService/Data/Migrations/20250514124016_InitialialCreate Catalog DB.Designer.cs create mode 100644 src/CatalogService/Data/Migrations/20250514124016_InitialialCreate Catalog DB.cs create mode 100644 src/CatalogService/Data/Migrations/CatalogDbContextModelSnapshot.cs create mode 100644 src/CatalogService/Entities/Exercice.cs create mode 100644 src/CatalogService/Program.cs create mode 100644 src/CatalogService/Properties/launchSettings.json create mode 100644 src/CatalogService/appsettings.Development.json create mode 100644 src/CatalogService/appsettings.json create mode 100644 src/DTOs/ExerciceTemplateDto.cs create mode 100644 src/Shared/DTOs/ExerciceTemplateDto.cs create mode 100644 src/Shared/Entities/EntityBase.cs create mode 100644 src/Shared/Enum/ETarget.cs create mode 100644 src/Shared/Shared.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fed8a6b --- /dev/null +++ b/.gitignore @@ -0,0 +1,801 @@ +# Created by https://www.toptal.com/developers/gitignore/api/rider,intellij,intellij+all,dotnetcore,csharp,python +# Edit at https://www.toptal.com/developers/gitignore?templates=rider,intellij,intellij+all,dotnetcore,csharp,python + +### Csharp ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +### DotnetCore ### +# .NET Core build folders +bin/ +obj/ + +# Common node modules locations +/node_modules +/wwwroot/node_modules + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +# Azure Toolkit for IntelliJ plugin +# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij +.idea/**/azureSettings.xml + +### Intellij+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff + +# AWS User-specific + +# Generated files + +# Sensitive or high-churn files + +# Gradle + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake + +# Mongo Explorer plugin + +# File-based project format + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# SonarLint plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +# Editor-based Rest Client + +# Android studio 3.1+ serialized cache file + +### Intellij+all Patch ### +# Ignore everything but code style settings and run configurations +# that are supposed to be shared within teams. + +.idea/* + +!.idea/codeStyles +!.idea/runConfigurations + +### Python ### +# Byte-compiled / optimized / DLL files +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +### Rider ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff + +# AWS User-specific + +# Generated files + +# Sensitive or high-churn files + +# Gradle + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake + +# Mongo Explorer plugin + +# File-based project format + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# SonarLint plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +# Editor-based Rest Client + +# Android studio 3.1+ serialized cache file + +# End of https://www.toptal.com/developers/gitignore/api/rider,intellij,intellij+all,dotnetcore,csharp,python \ No newline at end of file diff --git a/OptifitWebServices.sln b/OptifitWebServices.sln new file mode 100644 index 0000000..e0fc7d6 --- /dev/null +++ b/OptifitWebServices.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2A7200CA-F40B-4715-8726-4ED30C785FA4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CatalogService", "src\CatalogService\CatalogService.csproj", "{54BE8DE8-08BD-429F-BCCA-3363A879D922}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "src\Shared\Shared.csproj", "{BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {54BE8DE8-08BD-429F-BCCA-3363A879D922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54BE8DE8-08BD-429F-BCCA-3363A879D922}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54BE8DE8-08BD-429F-BCCA-3363A879D922}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54BE8DE8-08BD-429F-BCCA-3363A879D922}.Release|Any CPU.Build.0 = Release|Any CPU + {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {54BE8DE8-08BD-429F-BCCA-3363A879D922} = {2A7200CA-F40B-4715-8726-4ED30C785FA4} + {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2} = {2A7200CA-F40B-4715-8726-4ED30C785FA4} + EndGlobalSection +EndGlobal diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..94ed0e8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +services: + postgres: + image: postgres + environment: + - POSTGRES_PASSWORD=montretesfesseslouis + ports: + - 5433:5432 + volumes: + - pgdata:/var/lib/postgresql/data +volumes: + pgdata: \ No newline at end of file diff --git a/src/CatalogService/CatalogService.csproj b/src/CatalogService/CatalogService.csproj new file mode 100644 index 0000000..497f0c0 --- /dev/null +++ b/src/CatalogService/CatalogService.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + disable + enable + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + \ No newline at end of file diff --git a/src/CatalogService/CatalogService.http b/src/CatalogService/CatalogService.http new file mode 100644 index 0000000..e682781 --- /dev/null +++ b/src/CatalogService/CatalogService.http @@ -0,0 +1,6 @@ +@CatalogService_HostAddress = http://localhost:5138 + +GET {{CatalogService_HostAddress}}/weatherforecast/ +Accept: application/json + +### diff --git a/src/CatalogService/DTOs/CreateExerciceTemplateDto.cs b/src/CatalogService/DTOs/CreateExerciceTemplateDto.cs new file mode 100644 index 0000000..7104e69 --- /dev/null +++ b/src/CatalogService/DTOs/CreateExerciceTemplateDto.cs @@ -0,0 +1,19 @@ +using System.ComponentModel.DataAnnotations; +using Shared.Enum; + +namespace CatalogService.DTOs; + +public class CreateExerciceTemplateDto +{ + [Required] + public string Name { get; set; } + + [Required] + public string Description { get; set; } + + public ETarget? Target { get; set; } = ETarget.None; + + public string? ImageUrl { get; set; } = "images/default.jpg"; + + public string? VideoUrl { get; set; } = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley"; +} \ No newline at end of file diff --git a/src/CatalogService/Data/CatalogDbContext.cs b/src/CatalogService/Data/CatalogDbContext.cs new file mode 100644 index 0000000..f870489 --- /dev/null +++ b/src/CatalogService/Data/CatalogDbContext.cs @@ -0,0 +1,13 @@ +using CatalogService.Entities; +using Microsoft.EntityFrameworkCore; + +namespace CatalogService.Data; + +public class CatalogDbContext : DbContext +{ + public CatalogDbContext(DbContextOptions options) : base(options) + { + } + + public DbSet Exercices { get; set; } +} \ No newline at end of file diff --git a/src/CatalogService/Data/DbInitializer.cs b/src/CatalogService/Data/DbInitializer.cs new file mode 100644 index 0000000..65cea6b --- /dev/null +++ b/src/CatalogService/Data/DbInitializer.cs @@ -0,0 +1,77 @@ +using CatalogService.Entities; +using Microsoft.EntityFrameworkCore; +using Shared.Enum; + +namespace CatalogService.Data; + +public class DbInitializer +{ + public static void InitDb(WebApplication app) + { + using var scope = app.Services.CreateScope(); + SeedData(scope.ServiceProvider.GetService()); + } + + private static void SeedData(CatalogDbContext context) + { + context.Database.Migrate(); + + if (context.Exercices.Any()) + { + Console.WriteLine("Already have data in the database"); + return; + } + + var exercices = new List() + { + new Exercice + { + Id = Guid.NewGuid().ToString(), + Name = "Squat", + Description = "Squat is a compound exercise that targets the lower body, primarily the quadriceps, hamstrings, and glutes.", + Target = ETarget.Legs, + ImageUrl = "images/squat.jpg", + VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", + }, + new Exercice + { + Id = Guid.NewGuid().ToString(), + Name = "Bench Press", + Description = "Bench Press is a compound exercise that primarily targets the chest, shoulders, and triceps.", + Target = ETarget.Chest, + ImageUrl = "images/bench_press.jpg", + VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", + }, + new Exercice + { + Id = Guid.NewGuid().ToString(), + Name = "Deadlift", + Description = "Deadlift is a compound exercise that primarily targets the back, glutes, and hamstrings.", + Target = ETarget.Back, + ImageUrl = "images/deadlift.jpg", + VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", + }, + new Exercice + { + Id = Guid.NewGuid().ToString(), + Name = "Shoulder Press", + Description = "Shoulder Press is a compound exercise that primarily targets the shoulders and triceps.", + Target = ETarget.Arms, + ImageUrl = "images/shoulder_press.jpg", + VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", + }, + new Exercice + { + Id = Guid.NewGuid().ToString(), + Name = "Running on Treadmill", + Description = "Running on Treadmill is a cardiovascular exercise that primarily targets the legs and improves overall fitness.", + Target = ETarget.Cardio, + ImageUrl = "images/running_treadmill.jpg", + VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", + }, + }; + context.AddRange(exercices); + + context.SaveChanges(); + } +} \ No newline at end of file diff --git a/src/CatalogService/Data/Migrations/20250514124016_InitialialCreate Catalog DB.Designer.cs b/src/CatalogService/Data/Migrations/20250514124016_InitialialCreate Catalog DB.Designer.cs new file mode 100644 index 0000000..ddb3687 --- /dev/null +++ b/src/CatalogService/Data/Migrations/20250514124016_InitialialCreate Catalog DB.Designer.cs @@ -0,0 +1,61 @@ +// +using System; +using CatalogService.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace CatalogService.Data.Migrations +{ + [DbContext(typeof(CatalogDbContext))] + [Migration("20250514124016_InitialialCreate Catalog DB")] + partial class InitialialCreateCatalogDB + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.15") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("CatalogService.Entities.Exercice", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Target") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoUrl") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Exercices"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CatalogService/Data/Migrations/20250514124016_InitialialCreate Catalog DB.cs b/src/CatalogService/Data/Migrations/20250514124016_InitialialCreate Catalog DB.cs new file mode 100644 index 0000000..c503a63 --- /dev/null +++ b/src/CatalogService/Data/Migrations/20250514124016_InitialialCreate Catalog DB.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CatalogService.Data.Migrations +{ + /// + public partial class InitialialCreateCatalogDB : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Exercices", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: true), + Description = table.Column(type: "text", nullable: true), + Target = table.Column(type: "integer", nullable: false), + ImageUrl = table.Column(type: "text", nullable: true), + VideoUrl = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Exercices", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Exercices"); + } + } +} diff --git a/src/CatalogService/Data/Migrations/CatalogDbContextModelSnapshot.cs b/src/CatalogService/Data/Migrations/CatalogDbContextModelSnapshot.cs new file mode 100644 index 0000000..88627f2 --- /dev/null +++ b/src/CatalogService/Data/Migrations/CatalogDbContextModelSnapshot.cs @@ -0,0 +1,58 @@ +// +using System; +using CatalogService.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace CatalogService.Data.Migrations +{ + [DbContext(typeof(CatalogDbContext))] + partial class CatalogDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.15") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("CatalogService.Entities.Exercice", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Target") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoUrl") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Exercices"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/CatalogService/Entities/Exercice.cs b/src/CatalogService/Entities/Exercice.cs new file mode 100644 index 0000000..99ed2fc --- /dev/null +++ b/src/CatalogService/Entities/Exercice.cs @@ -0,0 +1,22 @@ +using Shared.Entities; +using Shared.Enum; + +namespace CatalogService.Entities; + +public class Exercice : EntityBase +{ + public string Name { get; set; } + + public string Description { get; set; } + + public ETarget Target { get; set; } + + public string ImageUrl { get; set; } + + public string VideoUrl { get; set; } + + // Default value (UTC time because it's the most common format and it's the one used by postgres database) + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + + public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; +} \ No newline at end of file diff --git a/src/CatalogService/Program.cs b/src/CatalogService/Program.cs new file mode 100644 index 0000000..cc4a318 --- /dev/null +++ b/src/CatalogService/Program.cs @@ -0,0 +1,30 @@ +using CatalogService.Data; +using Microsoft.EntityFrameworkCore; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddControllers(); +builder.Services.AddDbContext(opt => +{ + opt.UseNpgsql(builder.Configuration.GetConnectionString("CatalogDb")); + +}); + + +var app = builder.Build(); + +app.UseAuthorization(); + +app.MapControllers(); + +try +{ + DbInitializer.InitDb(app); +} +catch (Exception e) +{ + Console.WriteLine(e); +} + +app.Run(); diff --git a/src/CatalogService/Properties/launchSettings.json b/src/CatalogService/Properties/launchSettings.json new file mode 100644 index 0000000..f50eeab --- /dev/null +++ b/src/CatalogService/Properties/launchSettings.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:7001", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/CatalogService/appsettings.Development.json b/src/CatalogService/appsettings.Development.json new file mode 100644 index 0000000..817fcfd --- /dev/null +++ b/src/CatalogService/appsettings.Development.json @@ -0,0 +1,11 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Information" + } + }, + "ConnectionStrings": { + "CatalogDb": "Server=localhost;Port=5433;Database=CatalogDb;User Id=postgres;Password=montretesfesseslouis;" + } +} diff --git a/src/CatalogService/appsettings.json b/src/CatalogService/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/CatalogService/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/DTOs/ExerciceTemplateDto.cs b/src/DTOs/ExerciceTemplateDto.cs new file mode 100644 index 0000000..6fa2ccf --- /dev/null +++ b/src/DTOs/ExerciceTemplateDto.cs @@ -0,0 +1,15 @@ +namespace System.Collections.Generic; + +public class ExerciceTemplateDto +{ + public string Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public ETarget Target { get; set; } + public string ImageUrl { get; set; } + public string VideoUrl { get; set; } + + // Default value (UTC time because it's the most common format and it's the one used by postgres database) + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; +} \ No newline at end of file diff --git a/src/Shared/DTOs/ExerciceTemplateDto.cs b/src/Shared/DTOs/ExerciceTemplateDto.cs new file mode 100644 index 0000000..12c6dee --- /dev/null +++ b/src/Shared/DTOs/ExerciceTemplateDto.cs @@ -0,0 +1,6 @@ +namespace Shared.DTOs; + +public class ExerciceTemplateDto +{ + +} \ No newline at end of file diff --git a/src/Shared/Entities/EntityBase.cs b/src/Shared/Entities/EntityBase.cs new file mode 100644 index 0000000..b77071d --- /dev/null +++ b/src/Shared/Entities/EntityBase.cs @@ -0,0 +1,8 @@ +using System.ComponentModel.DataAnnotations; + +namespace Shared.Entities; + +public abstract class EntityBase +{ + [Key] public string? Id { get; set; } = Guid.NewGuid().ToString(); +} \ No newline at end of file diff --git a/src/Shared/Enum/ETarget.cs b/src/Shared/Enum/ETarget.cs new file mode 100644 index 0000000..1e7b9c1 --- /dev/null +++ b/src/Shared/Enum/ETarget.cs @@ -0,0 +1,11 @@ +namespace Shared.Enum; + +public enum ETarget +{ + None, + Legs, + Arms, + Back, + Cardio, + Chest, +} \ No newline at end of file diff --git a/src/Shared/Shared.csproj b/src/Shared/Shared.csproj new file mode 100644 index 0000000..3a63532 --- /dev/null +++ b/src/Shared/Shared.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + +