pull/4/head
Vianney JOURDY 3 days ago
parent cbb99a399f
commit 65ef3f17ce

@ -4,7 +4,6 @@ namespace UserSvc.DTOs;
public class UpdateUserDto
{
public Guid Id { get; set; }
public string? Name { get; set; }
public string? Surname { get; set; }
public int? Age { get; set; }

@ -1,10 +1,13 @@
using Shared.Enum;
using System.ComponentModel.DataAnnotations;
using Shared.Enum;
namespace UserSvc.DTOs;
public class UserDto
{
[Required]
public string Name { get; set; } = "Guest";
[Required]
public string Surname { get; set; } = "Gest";
public int Age { get; set; } = 0;
public float Weight { get; set; } = 0.0f;

@ -1,6 +1,5 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
@ -13,7 +12,7 @@ using UserSvc.Data;
namespace UserSvc.Data.Migrations
{
[DbContext(typeof(UserDbContext))]
[Migration("20250615155615_InitialCreate")]
[Migration("20250616180524_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
@ -26,11 +25,10 @@ namespace UserSvc.Data.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("UserService.Entities.User", b =>
modelBuilder.Entity("UserSvc.Entities.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("Age")
.HasColumnType("integer");
@ -38,13 +36,12 @@ namespace UserSvc.Data.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Goal")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Goal")
.HasColumnType("integer");
b.Property<List<string>>("HealthProblems")
b.Property<int[]>("HealthProblems")
.IsRequired()
.HasColumnType("text[]");
.HasColumnType("integer[]");
b.Property<float>("Height")
.HasColumnType("real");
@ -63,17 +60,15 @@ namespace UserSvc.Data.Migrations
b.Property<bool>("Sexe")
.HasColumnType("boolean");
b.Property<string>("SleepLevel")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SleepLevel")
.HasColumnType("integer");
b.Property<string>("SportLevel")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SportLevel")
.HasColumnType("integer");
b.Property<List<string>>("Sports")
b.Property<int[]>("Sports")
.IsRequired()
.HasColumnType("text[]");
.HasColumnType("integer[]");
b.Property<string>("Surname")
.IsRequired()
@ -87,6 +82,9 @@ namespace UserSvc.Data.Migrations
b.HasKey("Id");
b.HasIndex("Name", "Surname")
.IsUnique();
b.ToTable("Users");
});
#pragma warning restore 612, 618

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
@ -16,7 +15,7 @@ namespace UserSvc.Data.Migrations
name: "Users",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Surname = table.Column<string>(type: "text", nullable: false),
Age = table.Column<int>(type: "integer", nullable: false),
@ -25,11 +24,11 @@ namespace UserSvc.Data.Migrations
Sexe = table.Column<bool>(type: "boolean", nullable: false),
ProfilePict = table.Column<string>(type: "text", nullable: false),
NbSessionWeek = table.Column<int>(type: "integer", nullable: false),
Goal = table.Column<string>(type: "text", nullable: false),
SleepLevel = table.Column<string>(type: "text", nullable: false),
SportLevel = table.Column<string>(type: "text", nullable: false),
Sports = table.Column<List<string>>(type: "text[]", nullable: false),
HealthProblems = table.Column<List<string>>(type: "text[]", nullable: false),
Goal = table.Column<int>(type: "integer", nullable: false),
SleepLevel = table.Column<int>(type: "integer", nullable: false),
SportLevel = table.Column<int>(type: "integer", nullable: false),
Sports = table.Column<int[]>(type: "integer[]", nullable: false),
HealthProblems = table.Column<int[]>(type: "integer[]", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
@ -37,6 +36,12 @@ namespace UserSvc.Data.Migrations
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Users_Name_Surname",
table: "Users",
columns: new[] { "Name", "Surname" },
unique: true);
}
/// <inheritdoc />

@ -1,6 +1,5 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@ -23,11 +22,10 @@ namespace UserSvc.Data.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("UserService.Entities.User", b =>
modelBuilder.Entity("UserSvc.Entities.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Id")
.HasColumnType("text");
b.Property<int>("Age")
.HasColumnType("integer");
@ -35,13 +33,12 @@ namespace UserSvc.Data.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Goal")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Goal")
.HasColumnType("integer");
b.Property<List<string>>("HealthProblems")
b.Property<int[]>("HealthProblems")
.IsRequired()
.HasColumnType("text[]");
.HasColumnType("integer[]");
b.Property<float>("Height")
.HasColumnType("real");
@ -60,17 +57,15 @@ namespace UserSvc.Data.Migrations
b.Property<bool>("Sexe")
.HasColumnType("boolean");
b.Property<string>("SleepLevel")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SleepLevel")
.HasColumnType("integer");
b.Property<string>("SportLevel")
.IsRequired()
.HasColumnType("text");
b.Property<int>("SportLevel")
.HasColumnType("integer");
b.Property<List<string>>("Sports")
b.Property<int[]>("Sports")
.IsRequired()
.HasColumnType("text[]");
.HasColumnType("integer[]");
b.Property<string>("Surname")
.IsRequired()
@ -84,6 +79,9 @@ namespace UserSvc.Data.Migrations
b.HasKey("Id");
b.HasIndex("Name", "Surname")
.IsUnique();
b.ToTable("Users");
});
#pragma warning restore 612, 618

@ -1,10 +1,12 @@
using Shared.Enum;
using Microsoft.EntityFrameworkCore;
using Shared.Entities;
using Shared.Enum;
namespace UserSvc.Entities;
public class User
[Index(nameof(Name), nameof(Surname), IsUnique = true)]
public class User : EntityBase
{
public Guid Id { get; set; }
public string Name { get; set; } = "Gest";
public string Surname { get; set; } = "Gest";
public int Age { get; set; } = 0;

@ -10,7 +10,8 @@ public class UserProfile : Profile
{
CreateMap<User, UserDto>();
CreateMap<UserDto, User>();
CreateMap<UpdateUserDto, User>();
CreateMap<UpdateUserDto, User>()
.ForAllMembers(opt => opt.Condition((src, dest, srcMember) => srcMember != null));
CreateMap<User, UpdateUserDto>();
}
}
Loading…
Cancel
Save