Skip to content

Commit e4d71a5

Browse files
tknsnail
authored andcommitted
1
1 parent c15abdc commit e4d71a5

12 files changed

Lines changed: 172 additions & 93 deletions

File tree

src/backend/NetAdmin/NetAdmin.Domain/DbMaps/Sys/Sys_CodeTemplate.cs

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
using NetAdmin.Domain.Attributes;
2+
using NetAdmin.Domain.DbMaps.Dependency;
3+
using NetAdmin.Domain.DbMaps.Dependency.Fields;
4+
using NetAdmin.Domain.DbMaps.Sys;
5+
16
namespace NetAdmin.Domain.DbMaps.Sys;
27

38
/// <summary>
49
/// 代码模板表
510
/// </summary>
611
[Table(Name = Chars.FLG_DB_TABLE_NAME_PREFIX + nameof(Sys_CodeTemplate))]
7-
public record Sys_CodeTemplate : VersionEntity, IFieldSort, IFieldSummary, IFieldEnabled, IFieldOwner
12+
public record Sys_CodeTemplate : VersionEntity, IFieldSummary, IFieldOwner, IFieldSort, IFieldEnabled
813
{
914
/// <summary>
1015
/// 是否启用
@@ -15,34 +20,6 @@ public record Sys_CodeTemplate : VersionEntity, IFieldSort, IFieldSummary, IFiel
1520
[JsonIgnore]
1621
public virtual bool Enabled { get; init; }
1722

18-
/// <summary>
19-
/// 性别
20-
/// </summary>
21-
/// <example>Male</example>
22-
[Column]
23-
[CsvIgnore]
24-
[JsonIgnore]
25-
public virtual Genders? Gender { get; init; }
26-
27-
/// <summary>
28-
/// 唯一编码
29-
/// </summary>
30-
/// <example>123456</example>
31-
[Column(IsIdentity = false, IsPrimary = true, Position = 1)]
32-
[CsvIgnore]
33-
[JsonIgnore]
34-
[Snowflake]
35-
public override long Id { get; init; }
36-
37-
/// <summary>
38-
/// 名称
39-
/// </summary>
40-
/// <example>老王</example>
41-
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_31)]
42-
[CsvIgnore]
43-
[JsonIgnore]
44-
public virtual string Name { get; init; }
45-
4623
/// <summary>
4724
/// 归属用户
4825
/// </summary>
@@ -86,4 +63,32 @@ public record Sys_CodeTemplate : VersionEntity, IFieldSort, IFieldSummary, IFiel
8663
[CsvIgnore]
8764
[JsonIgnore]
8865
public virtual string Summary { get; init; }
66+
67+
/// <summary>
68+
/// 代码模板编号
69+
/// </summary>
70+
/// <example>123456</example>
71+
[Column(IsIdentity = false, IsPrimary = true, Position = 1)]
72+
[CsvIgnore]
73+
[JsonIgnore]
74+
[Snowflake]
75+
public override long Id { get; init; }
76+
77+
/// <summary>
78+
/// 名称
79+
/// </summary>
80+
/// <example>老王</example>
81+
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_31)]
82+
[CsvIgnore]
83+
[JsonIgnore]
84+
public virtual string Name { get; init; }
85+
86+
/// <summary>
87+
/// 性别
88+
/// </summary>
89+
/// <example>Male</example>
90+
[Column]
91+
[CsvIgnore]
92+
[JsonIgnore]
93+
public virtual Genders? Gender { get; init; }
8994
}
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using NetAdmin.Domain.DbMaps.Dependency.Fields;
2+
using NetAdmin.Domain.DbMaps.Sys;
3+
14
namespace NetAdmin.Domain.Dto.Sys.CodeTemplate;
25

36
/// <summary>
@@ -8,9 +11,13 @@ public record CreateCodeTemplateReq : Sys_CodeTemplate
811
/// <inheritdoc cref="IFieldEnabled.Enabled" />
912
public override bool Enabled { get; init; } = true;
1013

11-
/// <inheritdoc cref="Sys_CodeTemplate.Gender" />
14+
/// <inheritdoc cref="IFieldSort.Sort" />
1215
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
13-
public override Genders? Gender { get; init; }
16+
public override long Sort { get; init; }
17+
18+
/// <inheritdoc cref="IFieldSummary.Summary" />
19+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
20+
public override string Summary { get; init; }
1421

1522
/// <inheritdoc cref="Sys_CodeTemplate.Id" />
1623
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
@@ -20,11 +27,8 @@ public record CreateCodeTemplateReq : Sys_CodeTemplate
2027
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2128
public override string Name { get; init; }
2229

23-
/// <inheritdoc cref="IFieldSort.Sort" />
30+
/// <inheritdoc cref="Sys_CodeTemplate.Gender" />
2431
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
25-
public override long Sort { get; init; }
26-
27-
/// <inheritdoc cref="IFieldSummary.Summary" />
28-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
29-
public override string Summary { get; init; }
32+
[EnumDataType(typeof(Genders))]
33+
public override Genders? Gender { get; init; }
3034
}

src/backend/NetAdmin/NetAdmin.Domain/Dto/Sys/CodeTemplate/EditCodeTemplateReq.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using NetAdmin.Domain.DbMaps.Dependency.Fields;
2+
13
namespace NetAdmin.Domain.Dto.Sys.CodeTemplate;
24

35
/// <summary>
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
using NetAdmin.Domain.DbMaps.Dependency;
2+
using NetAdmin.Domain.DbMaps.Sys;
3+
14
namespace NetAdmin.Domain.Dto.Sys.CodeTemplate;
25

36
/// <summary>
47
/// 请求:查询代码模板
58
/// </summary>
69
public sealed record QueryCodeTemplateReq : Sys_CodeTemplate
710
{
8-
/// <inheritdoc cref="Sys_CodeTemplate.Id" />
11+
/// <inheritdoc cref="EntityBase{T}.Id" />
912
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
1013
public override long Id { get; init; }
1114
}
Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using NetAdmin.Domain.DbMaps.Dependency;
2+
using NetAdmin.Domain.DbMaps.Dependency.Fields;
3+
using NetAdmin.Domain.DbMaps.Sys;
14
using NetAdmin.Domain.Dto.Sys.User;
25

36
namespace NetAdmin.Domain.Dto.Sys.CodeTemplate;
@@ -7,10 +10,18 @@ namespace NetAdmin.Domain.Dto.Sys.CodeTemplate;
710
/// </summary>
811
public record QueryCodeTemplateRsp : Sys_CodeTemplate
912
{
13+
/// <inheritdoc cref="IFieldEnabled.Enabled" />
14+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
15+
public override bool Enabled { get; init; }
16+
1017
/// <inheritdoc cref="IFieldCreatedTime.CreatedTime" />
1118
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
1219
public override DateTime CreatedTime { get; init; }
1320

21+
/// <inheritdoc cref="IFieldModifiedTime.ModifiedTime" />
22+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
23+
public override DateTime? ModifiedTime { get; init; }
24+
1425
/// <inheritdoc cref="IFieldCreatedUser.CreatedUserId" />
1526
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1627
public override long? CreatedUserId { get; init; }
@@ -19,22 +30,6 @@ public record QueryCodeTemplateRsp : Sys_CodeTemplate
1930
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2031
public override string CreatedUserName { get; init; }
2132

22-
/// <inheritdoc cref="IFieldEnabled.Enabled" />
23-
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
24-
public override bool Enabled { get; init; }
25-
26-
/// <inheritdoc cref="Sys_CodeTemplate.Gender" />
27-
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
28-
public override Genders? Gender { get; init; }
29-
30-
/// <inheritdoc cref="Sys_CodeTemplate.Id" />
31-
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
32-
public override long Id { get; init; }
33-
34-
/// <inheritdoc cref="IFieldModifiedTime.ModifiedTime" />
35-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
36-
public override DateTime? ModifiedTime { get; init; }
37-
3833
/// <inheritdoc cref="IFieldModifiedUser.ModifiedUserId" />
3934
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4035
public override long? ModifiedUserId { get; init; }
@@ -43,10 +38,6 @@ public record QueryCodeTemplateRsp : Sys_CodeTemplate
4338
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
4439
public override string ModifiedUserName { get; init; }
4540

46-
/// <inheritdoc cref="Sys_CodeTemplate.Name" />
47-
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
48-
public override string Name { get; init; }
49-
5041
/// <inheritdoc cref="Sys_CodeTemplate.Owner" />
5142
public new virtual QueryUserRsp Owner { get; init; }
5243

@@ -69,4 +60,16 @@ public record QueryCodeTemplateRsp : Sys_CodeTemplate
6960
/// <inheritdoc cref="IFieldVersion.Version" />
7061
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
7162
public override long Version { get; init; }
63+
64+
/// <inheritdoc cref="Sys_CodeTemplate.Id" />
65+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
66+
public override long Id { get; init; }
67+
68+
/// <inheritdoc cref="Sys_CodeTemplate.Name" />
69+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
70+
public override string Name { get; init; }
71+
72+
/// <inheritdoc cref="Sys_CodeTemplate.Gender" />
73+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
74+
public override Genders? Gender { get; init; }
7275
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using NetAdmin.Domain.DbMaps.Dependency.Fields;
2+
3+
namespace NetAdmin.Domain.Dto.Sys.CodeTemplate;
4+
5+
/// <summary>
6+
/// 请求:设置代码模板启用状态
7+
/// </summary>
8+
public sealed record SetCodeTemplateEnabledReq : Sys_CodeTemplate
9+
{
10+
/// <inheritdoc cref="IFieldEnabled.Enabled" />
11+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
12+
public override bool Enabled { get; init; }
13+
14+
/// <inheritdoc cref="Sys_CodeTemplate.Id" />
15+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
16+
public override long Id { get; init; }
17+
18+
/// <inheritdoc cref="IFieldVersion.Version" />
19+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
20+
public override long Version { get; init; }
21+
}

src/backend/NetAdmin/NetAdmin.SysComponent.Application/Modules/Sys/ICodeTemplateModule.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ public interface ICodeTemplateModule : ICrudModule<CreateCodeTemplateReq, QueryC
99
, EditCodeTemplateReq // 编辑类型
1010
, QueryCodeTemplateReq, QueryCodeTemplateRsp // 查询类型
1111
, DelReq // 删除类型
12-
>;
12+
>
13+
{
14+
/// <summary>
15+
/// 设置代码模板启用状态
16+
/// </summary>
17+
Task<int> SetEnabledAsync(SetCodeTemplateEnabledReq req);
18+
}

src/backend/NetAdmin/NetAdmin.SysComponent.Application/Services/Sys/CodeTemplateService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ public async Task<IEnumerable<QueryCodeTemplateRsp>> QueryAsync(QueryReq<QueryCo
113113
return ret.Adapt<IEnumerable<QueryCodeTemplateRsp>>();
114114
}
115115

116+
/// <inheritdoc />
117+
public Task<int> SetEnabledAsync(SetCodeTemplateEnabledReq req)
118+
{
119+
req.ThrowIfInvalid();
120+
return UpdateAsync(req, [nameof(req.Enabled)]);
121+
}
122+
116123
private ISelect<Sys_CodeTemplate> QueryInternal(QueryReq<QueryCodeTemplateReq> req)
117124
{
118125
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);

src/backend/NetAdmin/NetAdmin.SysComponent.Cache/Sys/CodeTemplateCache.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@ public Task<IEnumerable<QueryCodeTemplateRsp>> QueryAsync(QueryReq<QueryCodeTemp
6565
{
6666
return Service.QueryAsync(req);
6767
}
68+
69+
/// <inheritdoc />
70+
public Task<int> SetEnabledAsync(SetCodeTemplateEnabledReq req)
71+
{
72+
return Service.SetEnabledAsync(req);
73+
}
6874
}

src/backend/NetAdmin/NetAdmin.SysComponent.Host/Controllers/Sys/CodeTemplateController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,12 @@ public Task<IEnumerable<QueryCodeTemplateRsp>> QueryAsync(QueryReq<QueryCodeTemp
9595
{
9696
return Cache.QueryAsync(req);
9797
}
98+
99+
/// <summary>
100+
/// 设置代码模板启用状态
101+
/// </summary>
102+
public Task<int> SetEnabledAsync(SetCodeTemplateEnabledReq req)
103+
{
104+
return Cache.SetEnabledAsync(req);
105+
}
98106
}

0 commit comments

Comments
 (0)