mirror of
https://github.com/ryzij/URL-Shortener.git
synced 2026-07-14 03:56:58 +00:00
Добавил дату и время обновления ссылки
This commit is contained in:
@@ -70,6 +70,8 @@ namespace URL_Shortener.Controllers
|
||||
if (dto.ResetExpirationDateTime)
|
||||
shortUrl.ExpirationDateTime = null;
|
||||
|
||||
shortUrl.UpdateDateTime = DateTime.UtcNow;
|
||||
|
||||
await _db.SaveChangesAsync();
|
||||
|
||||
return Ok(shortUrl);
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using URL_Shortener;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace URL_Shortener.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20260514100330_AddUpdateDateTime")]
|
||||
partial class AddUpdateDateTime
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("URL_Shortener.Models.ClickInfo", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("ClickDateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("ShortUrlId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ClickInfos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("URL_Shortener.Models.ShortUrl", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClickLimit")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("CreationDateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("ExpirationDateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("OriginalUrl")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ShortCode")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("TotalClickCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("UpdateDateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ShortUrls");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("URL_Shortener.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("HashedPassword")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("LastLoginDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("RegisterDate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace URL_Shortener.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddUpdateDateTime : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "UpdateDateTime",
|
||||
table: "ShortUrls",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "UpdateDateTime",
|
||||
table: "ShortUrls");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,9 @@ namespace URL_Shortener.Migrations
|
||||
b.Property<int>("TotalClickCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("UpdateDateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
public string ShortCode { get; set; } = string.Empty;
|
||||
public int TotalClickCount { get; set; }
|
||||
public DateTime CreationDateTime { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdateDateTime { get; set; } = DateTime.UtcNow;
|
||||
public DateTime? ExpirationDateTime { get; set; } = null;
|
||||
public int ClickLimit { get; set; } = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user