fix: Add JSON string enum converter for Issue Management API

- Configure AddControllers() with JsonStringEnumConverter
- Allows API to accept Issue type/priority/status as strings ("Story", "High", "Backlog")
- Frontend can now send readable enum values instead of integers
- All Issue Management CRUD operations tested and working

Test results:
- Create Issue (Story, Bug, Task) ✓
- List all issues ✓
- Filter by status (Backlog, InProgress) ✓
- Change issue status (Kanban workflow) ✓
- Update issue details ✓
- Multi-tenant isolation verified ✓
This commit is contained in:
Yaojia Wang
2025-11-04 12:04:57 +01:00
parent 6b11af9bea
commit 1246445a0b
7 changed files with 835 additions and 23 deletions

View File

@@ -0,0 +1,98 @@
// <auto-generated />
using System;
using ColaFlow.Modules.IssueManagement.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ColaFlow.Modules.IssueManagement.Infrastructure.Migrations
{
[DbContext(typeof(IssueManagementDbContext))]
[Migration("20251104104008_InitialIssueModule")]
partial class InitialIssueModule
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ColaFlow.Modules.IssueManagement.Domain.Entities.Issue", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<Guid?>("AssigneeId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.Property<string>("Priority")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("ProjectId")
.HasColumnType("uuid");
b.Property<Guid>("ReporterId")
.HasColumnType("uuid");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("TenantId")
.HasColumnType("uuid");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("AssigneeId")
.HasDatabaseName("IX_Issues_AssigneeId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_Issues_CreatedAt");
b.HasIndex("ProjectId")
.HasDatabaseName("IX_Issues_ProjectId");
b.HasIndex("TenantId")
.HasDatabaseName("IX_Issues_TenantId");
b.HasIndex("ProjectId", "Status")
.HasDatabaseName("IX_Issues_ProjectId_Status");
b.ToTable("Issues", "issue_management");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,79 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ColaFlow.Modules.IssueManagement.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class InitialIssueModule : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "issue_management");
migrationBuilder.CreateTable(
name: "Issues",
schema: "issue_management",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ProjectId = table.Column<Guid>(type: "uuid", nullable: false),
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
Title = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Description = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: false),
Type = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Status = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Priority = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
AssigneeId = table.Column<Guid>(type: "uuid", nullable: true),
ReporterId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Issues", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Issues_AssigneeId",
schema: "issue_management",
table: "Issues",
column: "AssigneeId");
migrationBuilder.CreateIndex(
name: "IX_Issues_CreatedAt",
schema: "issue_management",
table: "Issues",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_Issues_ProjectId",
schema: "issue_management",
table: "Issues",
column: "ProjectId");
migrationBuilder.CreateIndex(
name: "IX_Issues_ProjectId_Status",
schema: "issue_management",
table: "Issues",
columns: new[] { "ProjectId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_Issues_TenantId",
schema: "issue_management",
table: "Issues",
column: "TenantId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Issues",
schema: "issue_management");
}
}
}

View File

@@ -0,0 +1,95 @@
// <auto-generated />
using System;
using ColaFlow.Modules.IssueManagement.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ColaFlow.Modules.IssueManagement.Infrastructure.Migrations
{
[DbContext(typeof(IssueManagementDbContext))]
partial class IssueManagementDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ColaFlow.Modules.IssueManagement.Domain.Entities.Issue", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
b.Property<Guid?>("AssigneeId")
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.Property<string>("Priority")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("ProjectId")
.HasColumnType("uuid");
b.Property<Guid>("ReporterId")
.HasColumnType("uuid");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<Guid>("TenantId")
.HasColumnType("uuid");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("AssigneeId")
.HasDatabaseName("IX_Issues_AssigneeId");
b.HasIndex("CreatedAt")
.HasDatabaseName("IX_Issues_CreatedAt");
b.HasIndex("ProjectId")
.HasDatabaseName("IX_Issues_ProjectId");
b.HasIndex("TenantId")
.HasDatabaseName("IX_Issues_TenantId");
b.HasIndex("ProjectId", "Status")
.HasDatabaseName("IX_Issues_ProjectId_Status");
b.ToTable("Issues", "issue_management");
});
#pragma warning restore 612, 618
}
}
}