|
|
@@ -111,7 +111,7 @@ public class @(Model.ClassName)Service : IDynamicApiController, ITransient
|
|
|
{
|
|
|
var entity = input.Adapt<@(Model.ClassName)>();
|
|
|
@foreach (var config in Model.TableUniqueList.Where(x => x.Columns.All(x1 => Model.TableField.Any(x2 => x2.WhetherAddUpdate == "Y" && x2.PropertyName == x1)))) {
|
|
|
- @:if (_@(Model.LowerClassName)Rep.AnyAsync(u => @(string.Join(" && ", config.Columns.Select(x => $"u.{x} != null && u.{x} == input.{x}"))))) throw Oops.Oh("@config.Message");
|
|
|
+ @:if (await _@(Model.LowerClassName)Rep.IsAnyAsync(u => @(string.Join(" && ", config.Columns.Select(x => $"u.{x} != null && u.{x} == input.{x}"))))) throw Oops.Oh("@(config.Message)已存在");
|
|
|
}
|
|
|
return await _@(Model.LowerClassName)Rep.InsertAsync(entity) ? entity.Id : 0;
|
|
|
}
|
|
|
@@ -158,7 +158,7 @@ public class @(Model.ClassName)Service : IDynamicApiController, ITransient
|
|
|
public async Task Update(Update@(Model.ClassName)Input input)
|
|
|
{
|
|
|
@foreach (var config in Model.TableUniqueList.Where(x => x.Columns.All(x1 => Model.TableField.Any(x2 => x2.WhetherAddUpdate == "Y" && x2.PropertyName == x1)))) {
|
|
|
- @:if (_@(Model.LowerClassName)Rep.AnyAsync(u => u.@(primaryKey.PropertyName) != input.@(primaryKey.PropertyName) && @(string.Join(" && ", config.Columns.Select(x => $"u.{x} != null && u.{x} == input.{x}"))))) throw Oops.Oh("@config.Message");
|
|
|
+ @:if (await _@(Model.LowerClassName)Rep.IsAnyAsync(u => u.@(primaryKey.PropertyName) != input.@(primaryKey.PropertyName) && @(string.Join(" && ", config.Columns.Select(x => $"u.{x} != null && u.{x} == input.{x}"))))) throw Oops.Oh("@(config.Message)已存在");
|
|
|
}
|
|
|
var entity = input.Adapt<@(Model.ClassName)>();
|
|
|
await _@(Model.LowerClassName)Rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
@@ -349,7 +349,7 @@ var definedObjects = new Dictionary<string, object>();
|
|
|
@:.SplitError(it => it.Item.@(column.PropertyName)?.Length > @(column.ColumnLength), "@(column.ColumnComment)长度不能超过@(column.ColumnLength)个字符")
|
|
|
}}
|
|
|
@foreach (var config in Model.TableUniqueList.Where(x => x.Columns.All(x1 => importFields.Any(x2 => x2.PropertyName == x1)))) {
|
|
|
- @:.WhereColumns(it => new { @(string.Join(", ", config.Columns.Select(x => $"it.{x}"))) }).SplitError(it => it.Any(), "@(config.Message)")
|
|
|
+ @:.WhereColumns(it => new { @(string.Join(", ", config.Columns.Select(x => $"it.{x}"))) }).SplitError(it => it.Any(), "@(config.Message)已存在")
|
|
|
}
|
|
|
@:.SplitInsert(_ => true)
|
|
|
@:.ToStorage();
|