@atlashub/smartstack-mcp 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -155
- package/config/default-config.json +62 -62
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/component.tsx.hbs +298 -298
- package/templates/controller.cs.hbs +166 -166
- package/templates/entity-extension.cs.hbs +87 -87
- package/templates/service-extension.cs.hbs +53 -53
|
@@ -1,166 +1,166 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.Collections.Generic;
|
|
3
|
-
using System.Threading;
|
|
4
|
-
using System.Threading.Tasks;
|
|
5
|
-
using Microsoft.AspNetCore.Authorization;
|
|
6
|
-
using Microsoft.AspNetCore.Mvc;
|
|
7
|
-
using Microsoft.Extensions.Logging;
|
|
8
|
-
|
|
9
|
-
namespace {{namespace}}.Controllers;
|
|
10
|
-
|
|
11
|
-
/// <summary>
|
|
12
|
-
/// API controller for {{name}} operations
|
|
13
|
-
/// </summary>
|
|
14
|
-
[ApiController]
|
|
15
|
-
[Route("api/[controller]")]
|
|
16
|
-
[Authorize]
|
|
17
|
-
[Produces("application/json")]
|
|
18
|
-
public class {{name}}Controller : ControllerBase
|
|
19
|
-
{
|
|
20
|
-
private readonly ILogger<{{name}}Controller> _logger;
|
|
21
|
-
// private readonly I{{name}}Service _{{nameCamel}}Service;
|
|
22
|
-
|
|
23
|
-
public {{name}}Controller(
|
|
24
|
-
ILogger<{{name}}Controller> logger
|
|
25
|
-
// I{{name}}Service {{nameCamel}}Service
|
|
26
|
-
)
|
|
27
|
-
{
|
|
28
|
-
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
29
|
-
// _{{nameCamel}}Service = {{nameCamel}}Service ?? throw new ArgumentNullException(nameof({{nameCamel}}Service));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/// <summary>
|
|
33
|
-
/// Get all {{namePlural}}
|
|
34
|
-
/// </summary>
|
|
35
|
-
/// <param name="cancellationToken">Cancellation token</param>
|
|
36
|
-
/// <returns>List of {{namePlural}}</returns>
|
|
37
|
-
[HttpGet]
|
|
38
|
-
[ProducesResponseType(typeof(IEnumerable<{{name}}Dto>), 200)]
|
|
39
|
-
public async Task<ActionResult<IEnumerable<{{name}}Dto>>> GetAll(CancellationToken cancellationToken = default)
|
|
40
|
-
{
|
|
41
|
-
_logger.LogInformation("Getting all {{namePlural}}");
|
|
42
|
-
|
|
43
|
-
// TODO: Implement using service
|
|
44
|
-
// var result = await _{{nameCamel}}Service.GetAllAsync(cancellationToken);
|
|
45
|
-
// return Ok(result);
|
|
46
|
-
|
|
47
|
-
return Ok(Array.Empty<{{name}}Dto>());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/// <summary>
|
|
51
|
-
/// Get {{nameCamel}} by ID
|
|
52
|
-
/// </summary>
|
|
53
|
-
/// <param name="id">{{name}} ID</param>
|
|
54
|
-
/// <param name="cancellationToken">Cancellation token</param>
|
|
55
|
-
/// <returns>{{name}} details</returns>
|
|
56
|
-
[HttpGet("{id:guid}")]
|
|
57
|
-
[ProducesResponseType(typeof({{name}}Dto), 200)]
|
|
58
|
-
[ProducesResponseType(404)]
|
|
59
|
-
public async Task<ActionResult<{{name}}Dto>> GetById(
|
|
60
|
-
Guid id,
|
|
61
|
-
CancellationToken cancellationToken = default)
|
|
62
|
-
{
|
|
63
|
-
_logger.LogInformation("Getting {{nameCamel}} {Id}", id);
|
|
64
|
-
|
|
65
|
-
// TODO: Implement using service
|
|
66
|
-
// var result = await _{{nameCamel}}Service.GetByIdAsync(id, cancellationToken);
|
|
67
|
-
// if (result == null) return NotFound();
|
|
68
|
-
// return Ok(result);
|
|
69
|
-
|
|
70
|
-
return NotFound();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/// <summary>
|
|
74
|
-
/// Create new {{nameCamel}}
|
|
75
|
-
/// </summary>
|
|
76
|
-
/// <param name="request">Create request</param>
|
|
77
|
-
/// <param name="cancellationToken">Cancellation token</param>
|
|
78
|
-
/// <returns>Created {{nameCamel}}</returns>
|
|
79
|
-
[HttpPost]
|
|
80
|
-
[ProducesResponseType(typeof({{name}}Dto), 201)]
|
|
81
|
-
[ProducesResponseType(400)]
|
|
82
|
-
public async Task<ActionResult<{{name}}Dto>> Create(
|
|
83
|
-
[FromBody] Create{{name}}Request request,
|
|
84
|
-
CancellationToken cancellationToken = default)
|
|
85
|
-
{
|
|
86
|
-
_logger.LogInformation("Creating new {{nameCamel}}");
|
|
87
|
-
|
|
88
|
-
// TODO: Validate and create using service
|
|
89
|
-
// var result = await _{{nameCamel}}Service.CreateAsync(request, cancellationToken);
|
|
90
|
-
// return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
|
|
91
|
-
|
|
92
|
-
var id = Guid.NewGuid();
|
|
93
|
-
return CreatedAtAction(nameof(GetById), new { id }, null);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/// <summary>
|
|
97
|
-
/// Update {{nameCamel}}
|
|
98
|
-
/// </summary>
|
|
99
|
-
/// <param name="id">{{name}} ID</param>
|
|
100
|
-
/// <param name="request">Update request</param>
|
|
101
|
-
/// <param name="cancellationToken">Cancellation token</param>
|
|
102
|
-
[HttpPut("{id:guid}")]
|
|
103
|
-
[ProducesResponseType(204)]
|
|
104
|
-
[ProducesResponseType(404)]
|
|
105
|
-
[ProducesResponseType(400)]
|
|
106
|
-
public async Task<ActionResult> Update(
|
|
107
|
-
Guid id,
|
|
108
|
-
[FromBody] Update{{name}}Request request,
|
|
109
|
-
CancellationToken cancellationToken = default)
|
|
110
|
-
{
|
|
111
|
-
_logger.LogInformation("Updating {{nameCamel}} {Id}", id);
|
|
112
|
-
|
|
113
|
-
// TODO: Implement using service
|
|
114
|
-
// await _{{nameCamel}}Service.UpdateAsync(id, request, cancellationToken);
|
|
115
|
-
|
|
116
|
-
return NoContent();
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/// <summary>
|
|
120
|
-
/// Delete {{nameCamel}}
|
|
121
|
-
/// </summary>
|
|
122
|
-
/// <param name="id">{{name}} ID</param>
|
|
123
|
-
/// <param name="cancellationToken">Cancellation token</param>
|
|
124
|
-
[HttpDelete("{id:guid}")]
|
|
125
|
-
[ProducesResponseType(204)]
|
|
126
|
-
[ProducesResponseType(404)]
|
|
127
|
-
public async Task<ActionResult> Delete(
|
|
128
|
-
Guid id,
|
|
129
|
-
CancellationToken cancellationToken = default)
|
|
130
|
-
{
|
|
131
|
-
_logger.LogInformation("Deleting {{nameCamel}} {Id}", id);
|
|
132
|
-
|
|
133
|
-
// TODO: Implement using service
|
|
134
|
-
// await _{{nameCamel}}Service.DeleteAsync(id, cancellationToken);
|
|
135
|
-
|
|
136
|
-
return NoContent();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// ============================================================================
|
|
141
|
-
// DTOs
|
|
142
|
-
// ============================================================================
|
|
143
|
-
|
|
144
|
-
/// <summary>
|
|
145
|
-
/// {{name}} data transfer object
|
|
146
|
-
/// </summary>
|
|
147
|
-
public record {{name}}Dto(
|
|
148
|
-
Guid Id,
|
|
149
|
-
DateTime CreatedAt,
|
|
150
|
-
DateTime? UpdatedAt
|
|
151
|
-
// TODO: Add additional properties
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
/// <summary>
|
|
155
|
-
/// Request to create a new {{nameCamel}}
|
|
156
|
-
/// </summary>
|
|
157
|
-
public record Create{{name}}Request(
|
|
158
|
-
// TODO: Add creation properties
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
/// <summary>
|
|
162
|
-
/// Request to update a {{nameCamel}}
|
|
163
|
-
/// </summary>
|
|
164
|
-
public record Update{{name}}Request(
|
|
165
|
-
// TODO: Add update properties
|
|
166
|
-
);
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Threading;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
using Microsoft.AspNetCore.Authorization;
|
|
6
|
+
using Microsoft.AspNetCore.Mvc;
|
|
7
|
+
using Microsoft.Extensions.Logging;
|
|
8
|
+
|
|
9
|
+
namespace {{namespace}}.Controllers;
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// API controller for {{name}} operations
|
|
13
|
+
/// </summary>
|
|
14
|
+
[ApiController]
|
|
15
|
+
[Route("api/[controller]")]
|
|
16
|
+
[Authorize]
|
|
17
|
+
[Produces("application/json")]
|
|
18
|
+
public class {{name}}Controller : ControllerBase
|
|
19
|
+
{
|
|
20
|
+
private readonly ILogger<{{name}}Controller> _logger;
|
|
21
|
+
// private readonly I{{name}}Service _{{nameCamel}}Service;
|
|
22
|
+
|
|
23
|
+
public {{name}}Controller(
|
|
24
|
+
ILogger<{{name}}Controller> logger
|
|
25
|
+
// I{{name}}Service {{nameCamel}}Service
|
|
26
|
+
)
|
|
27
|
+
{
|
|
28
|
+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
29
|
+
// _{{nameCamel}}Service = {{nameCamel}}Service ?? throw new ArgumentNullException(nameof({{nameCamel}}Service));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// <summary>
|
|
33
|
+
/// Get all {{namePlural}}
|
|
34
|
+
/// </summary>
|
|
35
|
+
/// <param name="cancellationToken">Cancellation token</param>
|
|
36
|
+
/// <returns>List of {{namePlural}}</returns>
|
|
37
|
+
[HttpGet]
|
|
38
|
+
[ProducesResponseType(typeof(IEnumerable<{{name}}Dto>), 200)]
|
|
39
|
+
public async Task<ActionResult<IEnumerable<{{name}}Dto>>> GetAll(CancellationToken cancellationToken = default)
|
|
40
|
+
{
|
|
41
|
+
_logger.LogInformation("Getting all {{namePlural}}");
|
|
42
|
+
|
|
43
|
+
// TODO: Implement using service
|
|
44
|
+
// var result = await _{{nameCamel}}Service.GetAllAsync(cancellationToken);
|
|
45
|
+
// return Ok(result);
|
|
46
|
+
|
|
47
|
+
return Ok(Array.Empty<{{name}}Dto>());
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// <summary>
|
|
51
|
+
/// Get {{nameCamel}} by ID
|
|
52
|
+
/// </summary>
|
|
53
|
+
/// <param name="id">{{name}} ID</param>
|
|
54
|
+
/// <param name="cancellationToken">Cancellation token</param>
|
|
55
|
+
/// <returns>{{name}} details</returns>
|
|
56
|
+
[HttpGet("{id:guid}")]
|
|
57
|
+
[ProducesResponseType(typeof({{name}}Dto), 200)]
|
|
58
|
+
[ProducesResponseType(404)]
|
|
59
|
+
public async Task<ActionResult<{{name}}Dto>> GetById(
|
|
60
|
+
Guid id,
|
|
61
|
+
CancellationToken cancellationToken = default)
|
|
62
|
+
{
|
|
63
|
+
_logger.LogInformation("Getting {{nameCamel}} {Id}", id);
|
|
64
|
+
|
|
65
|
+
// TODO: Implement using service
|
|
66
|
+
// var result = await _{{nameCamel}}Service.GetByIdAsync(id, cancellationToken);
|
|
67
|
+
// if (result == null) return NotFound();
|
|
68
|
+
// return Ok(result);
|
|
69
|
+
|
|
70
|
+
return NotFound();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// <summary>
|
|
74
|
+
/// Create new {{nameCamel}}
|
|
75
|
+
/// </summary>
|
|
76
|
+
/// <param name="request">Create request</param>
|
|
77
|
+
/// <param name="cancellationToken">Cancellation token</param>
|
|
78
|
+
/// <returns>Created {{nameCamel}}</returns>
|
|
79
|
+
[HttpPost]
|
|
80
|
+
[ProducesResponseType(typeof({{name}}Dto), 201)]
|
|
81
|
+
[ProducesResponseType(400)]
|
|
82
|
+
public async Task<ActionResult<{{name}}Dto>> Create(
|
|
83
|
+
[FromBody] Create{{name}}Request request,
|
|
84
|
+
CancellationToken cancellationToken = default)
|
|
85
|
+
{
|
|
86
|
+
_logger.LogInformation("Creating new {{nameCamel}}");
|
|
87
|
+
|
|
88
|
+
// TODO: Validate and create using service
|
|
89
|
+
// var result = await _{{nameCamel}}Service.CreateAsync(request, cancellationToken);
|
|
90
|
+
// return CreatedAtAction(nameof(GetById), new { id = result.Id }, result);
|
|
91
|
+
|
|
92
|
+
var id = Guid.NewGuid();
|
|
93
|
+
return CreatedAtAction(nameof(GetById), new { id }, null);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// <summary>
|
|
97
|
+
/// Update {{nameCamel}}
|
|
98
|
+
/// </summary>
|
|
99
|
+
/// <param name="id">{{name}} ID</param>
|
|
100
|
+
/// <param name="request">Update request</param>
|
|
101
|
+
/// <param name="cancellationToken">Cancellation token</param>
|
|
102
|
+
[HttpPut("{id:guid}")]
|
|
103
|
+
[ProducesResponseType(204)]
|
|
104
|
+
[ProducesResponseType(404)]
|
|
105
|
+
[ProducesResponseType(400)]
|
|
106
|
+
public async Task<ActionResult> Update(
|
|
107
|
+
Guid id,
|
|
108
|
+
[FromBody] Update{{name}}Request request,
|
|
109
|
+
CancellationToken cancellationToken = default)
|
|
110
|
+
{
|
|
111
|
+
_logger.LogInformation("Updating {{nameCamel}} {Id}", id);
|
|
112
|
+
|
|
113
|
+
// TODO: Implement using service
|
|
114
|
+
// await _{{nameCamel}}Service.UpdateAsync(id, request, cancellationToken);
|
|
115
|
+
|
|
116
|
+
return NoContent();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/// <summary>
|
|
120
|
+
/// Delete {{nameCamel}}
|
|
121
|
+
/// </summary>
|
|
122
|
+
/// <param name="id">{{name}} ID</param>
|
|
123
|
+
/// <param name="cancellationToken">Cancellation token</param>
|
|
124
|
+
[HttpDelete("{id:guid}")]
|
|
125
|
+
[ProducesResponseType(204)]
|
|
126
|
+
[ProducesResponseType(404)]
|
|
127
|
+
public async Task<ActionResult> Delete(
|
|
128
|
+
Guid id,
|
|
129
|
+
CancellationToken cancellationToken = default)
|
|
130
|
+
{
|
|
131
|
+
_logger.LogInformation("Deleting {{nameCamel}} {Id}", id);
|
|
132
|
+
|
|
133
|
+
// TODO: Implement using service
|
|
134
|
+
// await _{{nameCamel}}Service.DeleteAsync(id, cancellationToken);
|
|
135
|
+
|
|
136
|
+
return NoContent();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// DTOs
|
|
142
|
+
// ============================================================================
|
|
143
|
+
|
|
144
|
+
/// <summary>
|
|
145
|
+
/// {{name}} data transfer object
|
|
146
|
+
/// </summary>
|
|
147
|
+
public record {{name}}Dto(
|
|
148
|
+
Guid Id,
|
|
149
|
+
DateTime CreatedAt,
|
|
150
|
+
DateTime? UpdatedAt
|
|
151
|
+
// TODO: Add additional properties
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
/// <summary>
|
|
155
|
+
/// Request to create a new {{nameCamel}}
|
|
156
|
+
/// </summary>
|
|
157
|
+
public record Create{{name}}Request(
|
|
158
|
+
// TODO: Add creation properties
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
/// <summary>
|
|
162
|
+
/// Request to update a {{nameCamel}}
|
|
163
|
+
/// </summary>
|
|
164
|
+
public record Update{{name}}Request(
|
|
165
|
+
// TODO: Add update properties
|
|
166
|
+
);
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.ComponentModel.DataAnnotations;
|
|
3
|
-
|
|
4
|
-
namespace {{namespace}};
|
|
5
|
-
|
|
6
|
-
/// <summary>
|
|
7
|
-
/// {{name}} entity{{#if baseEntity}} extending {{baseEntity}}{{/if}}
|
|
8
|
-
/// </summary>
|
|
9
|
-
public class {{name}}{{#if baseEntity}} : IHasId{{/if}}
|
|
10
|
-
{
|
|
11
|
-
{{#unless baseEntity}}
|
|
12
|
-
/// <summary>
|
|
13
|
-
/// Unique identifier
|
|
14
|
-
/// </summary>
|
|
15
|
-
[Key]
|
|
16
|
-
public Guid Id { get; set; } = Guid.NewGuid();
|
|
17
|
-
|
|
18
|
-
/// <summary>
|
|
19
|
-
/// Creation timestamp
|
|
20
|
-
/// </summary>
|
|
21
|
-
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
22
|
-
|
|
23
|
-
/// <summary>
|
|
24
|
-
/// Last update timestamp
|
|
25
|
-
/// </summary>
|
|
26
|
-
public DateTime? UpdatedAt { get; set; }
|
|
27
|
-
|
|
28
|
-
{{/unless}}
|
|
29
|
-
{{#if baseEntity}}
|
|
30
|
-
/// <summary>
|
|
31
|
-
/// Foreign key to {{baseEntity}}
|
|
32
|
-
/// </summary>
|
|
33
|
-
public Guid {{baseEntity}}Id { get; set; }
|
|
34
|
-
|
|
35
|
-
/// <summary>
|
|
36
|
-
/// Navigation property to {{baseEntity}}
|
|
37
|
-
/// </summary>
|
|
38
|
-
public virtual {{baseEntity}} {{baseEntity}} { get; set; } = null!;
|
|
39
|
-
|
|
40
|
-
{{/if}}
|
|
41
|
-
// TODO: Add {{name}} specific properties here
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// ============================================================================
|
|
45
|
-
// EF Core Configuration
|
|
46
|
-
// ============================================================================
|
|
47
|
-
namespace {{infrastructureNamespace}}.Persistence.Configurations;
|
|
48
|
-
|
|
49
|
-
using Microsoft.EntityFrameworkCore;
|
|
50
|
-
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
51
|
-
using {{domainNamespace}};
|
|
52
|
-
|
|
53
|
-
public class {{name}}Configuration : IEntityTypeConfiguration<{{name}}>
|
|
54
|
-
{
|
|
55
|
-
public void Configure(EntityTypeBuilder<{{name}}> builder)
|
|
56
|
-
{
|
|
57
|
-
// Table name with convention prefix
|
|
58
|
-
builder.ToTable("{{tablePrefix}}{{name}}s");
|
|
59
|
-
|
|
60
|
-
// Primary key
|
|
61
|
-
builder.HasKey(e => e.Id);
|
|
62
|
-
|
|
63
|
-
{{#if baseEntity}}
|
|
64
|
-
// Relationship to {{baseEntity}} (1:1)
|
|
65
|
-
builder.HasOne(e => e.{{baseEntity}})
|
|
66
|
-
.WithOne()
|
|
67
|
-
.HasForeignKey<{{name}}>(e => e.{{baseEntity}}Id)
|
|
68
|
-
.OnDelete(DeleteBehavior.Cascade);
|
|
69
|
-
|
|
70
|
-
// Index on foreign key
|
|
71
|
-
builder.HasIndex(e => e.{{baseEntity}}Id)
|
|
72
|
-
.IsUnique();
|
|
73
|
-
{{/if}}
|
|
74
|
-
|
|
75
|
-
// TODO: Add additional configuration
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ============================================================================
|
|
80
|
-
// DbContext Update (add to ApplicationDbContext.cs)
|
|
81
|
-
// ============================================================================
|
|
82
|
-
// public DbSet<{{name}}> {{name}}s => Set<{{name}}>();
|
|
83
|
-
|
|
84
|
-
// ============================================================================
|
|
85
|
-
// Migration Command
|
|
86
|
-
// ============================================================================
|
|
87
|
-
// dotnet ef migrations add $(date +%Y%m%d)_Core_XXX_Add{{name}}
|
|
1
|
+
using System;
|
|
2
|
+
using System.ComponentModel.DataAnnotations;
|
|
3
|
+
|
|
4
|
+
namespace {{namespace}};
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// {{name}} entity{{#if baseEntity}} extending {{baseEntity}}{{/if}}
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class {{name}}{{#if baseEntity}} : IHasId{{/if}}
|
|
10
|
+
{
|
|
11
|
+
{{#unless baseEntity}}
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Unique identifier
|
|
14
|
+
/// </summary>
|
|
15
|
+
[Key]
|
|
16
|
+
public Guid Id { get; set; } = Guid.NewGuid();
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
/// Creation timestamp
|
|
20
|
+
/// </summary>
|
|
21
|
+
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
/// Last update timestamp
|
|
25
|
+
/// </summary>
|
|
26
|
+
public DateTime? UpdatedAt { get; set; }
|
|
27
|
+
|
|
28
|
+
{{/unless}}
|
|
29
|
+
{{#if baseEntity}}
|
|
30
|
+
/// <summary>
|
|
31
|
+
/// Foreign key to {{baseEntity}}
|
|
32
|
+
/// </summary>
|
|
33
|
+
public Guid {{baseEntity}}Id { get; set; }
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
/// Navigation property to {{baseEntity}}
|
|
37
|
+
/// </summary>
|
|
38
|
+
public virtual {{baseEntity}} {{baseEntity}} { get; set; } = null!;
|
|
39
|
+
|
|
40
|
+
{{/if}}
|
|
41
|
+
// TODO: Add {{name}} specific properties here
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ============================================================================
|
|
45
|
+
// EF Core Configuration
|
|
46
|
+
// ============================================================================
|
|
47
|
+
namespace {{infrastructureNamespace}}.Persistence.Configurations;
|
|
48
|
+
|
|
49
|
+
using Microsoft.EntityFrameworkCore;
|
|
50
|
+
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
51
|
+
using {{domainNamespace}};
|
|
52
|
+
|
|
53
|
+
public class {{name}}Configuration : IEntityTypeConfiguration<{{name}}>
|
|
54
|
+
{
|
|
55
|
+
public void Configure(EntityTypeBuilder<{{name}}> builder)
|
|
56
|
+
{
|
|
57
|
+
// Table name with convention prefix
|
|
58
|
+
builder.ToTable("{{tablePrefix}}{{name}}s");
|
|
59
|
+
|
|
60
|
+
// Primary key
|
|
61
|
+
builder.HasKey(e => e.Id);
|
|
62
|
+
|
|
63
|
+
{{#if baseEntity}}
|
|
64
|
+
// Relationship to {{baseEntity}} (1:1)
|
|
65
|
+
builder.HasOne(e => e.{{baseEntity}})
|
|
66
|
+
.WithOne()
|
|
67
|
+
.HasForeignKey<{{name}}>(e => e.{{baseEntity}}Id)
|
|
68
|
+
.OnDelete(DeleteBehavior.Cascade);
|
|
69
|
+
|
|
70
|
+
// Index on foreign key
|
|
71
|
+
builder.HasIndex(e => e.{{baseEntity}}Id)
|
|
72
|
+
.IsUnique();
|
|
73
|
+
{{/if}}
|
|
74
|
+
|
|
75
|
+
// TODO: Add additional configuration
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// DbContext Update (add to ApplicationDbContext.cs)
|
|
81
|
+
// ============================================================================
|
|
82
|
+
// public DbSet<{{name}}> {{name}}s => Set<{{name}}>();
|
|
83
|
+
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Migration Command
|
|
86
|
+
// ============================================================================
|
|
87
|
+
// dotnet ef migrations add $(date +%Y%m%d)_Core_XXX_Add{{name}}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
using System;
|
|
2
|
-
using System.Threading;
|
|
3
|
-
using System.Threading.Tasks;
|
|
4
|
-
using System.Collections.Generic;
|
|
5
|
-
using Microsoft.Extensions.Logging;
|
|
6
|
-
|
|
7
|
-
namespace {{namespace}};
|
|
8
|
-
|
|
9
|
-
/// <summary>
|
|
10
|
-
/// Interface for {{name}} service operations
|
|
11
|
-
/// </summary>
|
|
12
|
-
public interface I{{name}}Service
|
|
13
|
-
{
|
|
14
|
-
{{#each methods}}
|
|
15
|
-
/// <summary>
|
|
16
|
-
/// {{this}} operation
|
|
17
|
-
/// </summary>
|
|
18
|
-
Task<object> {{this}}(CancellationToken cancellationToken = default);
|
|
19
|
-
|
|
20
|
-
{{/each}}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/// <summary>
|
|
24
|
-
/// Implementation of {{name}} service
|
|
25
|
-
/// </summary>
|
|
26
|
-
public class {{name}}Service : I{{name}}Service
|
|
27
|
-
{
|
|
28
|
-
private readonly ILogger<{{name}}Service> _logger;
|
|
29
|
-
|
|
30
|
-
public {{name}}Service(ILogger<{{name}}Service> logger)
|
|
31
|
-
{
|
|
32
|
-
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
{{#each methods}}
|
|
36
|
-
/// <inheritdoc />
|
|
37
|
-
public async Task<object> {{this}}(CancellationToken cancellationToken = default)
|
|
38
|
-
{
|
|
39
|
-
_logger.LogInformation("Executing {{this}} in {{../name}}Service");
|
|
40
|
-
|
|
41
|
-
// TODO: Implement {{this}} logic
|
|
42
|
-
await Task.CompletedTask;
|
|
43
|
-
|
|
44
|
-
throw new NotImplementedException("{{this}} is not yet implemented");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
{{/each}}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// ============================================================================
|
|
51
|
-
// Registration (add to DependencyInjection.cs)
|
|
52
|
-
// ============================================================================
|
|
53
|
-
// services.AddScoped<I{{name}}Service, {{name}}Service>();
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using Microsoft.Extensions.Logging;
|
|
6
|
+
|
|
7
|
+
namespace {{namespace}};
|
|
8
|
+
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// Interface for {{name}} service operations
|
|
11
|
+
/// </summary>
|
|
12
|
+
public interface I{{name}}Service
|
|
13
|
+
{
|
|
14
|
+
{{#each methods}}
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// {{this}} operation
|
|
17
|
+
/// </summary>
|
|
18
|
+
Task<object> {{this}}(CancellationToken cancellationToken = default);
|
|
19
|
+
|
|
20
|
+
{{/each}}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/// <summary>
|
|
24
|
+
/// Implementation of {{name}} service
|
|
25
|
+
/// </summary>
|
|
26
|
+
public class {{name}}Service : I{{name}}Service
|
|
27
|
+
{
|
|
28
|
+
private readonly ILogger<{{name}}Service> _logger;
|
|
29
|
+
|
|
30
|
+
public {{name}}Service(ILogger<{{name}}Service> logger)
|
|
31
|
+
{
|
|
32
|
+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
{{#each methods}}
|
|
36
|
+
/// <inheritdoc />
|
|
37
|
+
public async Task<object> {{this}}(CancellationToken cancellationToken = default)
|
|
38
|
+
{
|
|
39
|
+
_logger.LogInformation("Executing {{this}} in {{../name}}Service");
|
|
40
|
+
|
|
41
|
+
// TODO: Implement {{this}} logic
|
|
42
|
+
await Task.CompletedTask;
|
|
43
|
+
|
|
44
|
+
throw new NotImplementedException("{{this}} is not yet implemented");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
{{/each}}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// Registration (add to DependencyInjection.cs)
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// services.AddScoped<I{{name}}Service, {{name}}Service>();
|