diff --git a/Templates/Controller.cshtml b/Templates/Controller.cshtml
new file mode 100644
index 0000000..df6c696
--- /dev/null
+++ b/Templates/Controller.cshtml
@@ -0,0 +1,263 @@
+@{
+ ModelData modelData = Model;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ ClassInfo classInfo= modelData.ClassInfos.FirstOrDefault();
+ //ClassInfo classInfo= modelData.ClassInfos.Where(x=>x.ClassName=="SecurityUserService").FirstOrDefault();
+}
+using CloudBuilder.Core.DatabaseAccessor;
+using CloudBuilder.Core.Policy;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using System.Transactions;
+using CloudBuilder.Core.Service;
+@{
+ if(classInfo.Usings!=null && classInfo.Usings.Length>0)
+ {
+ for (var i = 0; i < classInfo.Usings.Length; i++)
+ {
+ if(classInfo.Usings[i]=="CloudBuilder.Core.Service") continue;
+ using @classInfo.Usings[i];
+
+ }
+ }
+}
+
+namespace @namespaceObject.Namespace
+{
+[Authorize(AuthorizePolicy.PERMISSION)]
+[ApiController]
+[Route("[controller]/[action]")]
+public class @{@classInfo.ClassName.Replace("Service", "")}Controller : ControllerBase
+{
+private readonly IApplicationService service;
+private readonly @{@classInfo.InterfaceName} @classInfo.ClassName.StringToProtectedProerty();
+
+public @{@classInfo.ClassName.Replace("Service", "")}Controller(IApplicationService service, @{@classInfo.InterfaceName} @classInfo.ClassName.StringToProtectedProerty())
+{
+this.service = service;
+this.@classInfo.ClassName.StringToProtectedProerty()= @classInfo.ClassName.StringToProtectedProerty();
+}
+
+@{
+ if(classInfo.ClassMethodInfos!=null && classInfo.ClassMethodInfos.Length>0 && classInfo.ClassMethodInfos[0].Parameters!=null)
+ {
+ for (var j= 0; j< classInfo.ClassMethodInfos.Length; j++)
+ {
+ //没有参数的情况=======================================
+ if(classInfo.ClassMethodInfos[j].Parameters.Length==0)
+ {
+ if(classInfo.ClassMethodInfos[j].AuthorizeName!=null)
+ {
+ @classInfo.ClassMethodInfos[j].AuthorizeName
+
+ }
+ if(classInfo.ClassMethodInfos[j].PermissionOperate!=null)
+ {
+ @{ @string.Format(classInfo.ClassMethodInfos[j].PermissionOperate,"\""+@classInfo.ClassMethodInfos[j].PermissionOperateAttribute.Name+"\"", "\""+@classInfo.ClassMethodInfos[j].PermissionOperateAttribute.Operate.ToString()+"\"")
+ }
+ }
+ if(classInfo.ClassMethodInfos[j].HttpName!=null)
+ {
+ @classInfo.ClassMethodInfos[j].HttpName
+
+ }
+ if(classInfo.ClassMethodInfos[j].UnitOfWorkName!=null)
+ {
+ @classInfo.ClassMethodInfos[j].UnitOfWorkName
+
+ }
+ if(@classInfo.ClassMethodInfos[j].MethodReturnName=="Void")
+ {
+ //文本开始=================================================================================================================
+ public dynamic @{@classInfo.ClassMethodInfos[j].MethodName}()
+ {
+ try
+ {
+
+ @{ @classInfo.ClassName.StringToProtectedProerty()}.@{@classInfo.ClassMethodInfos[j].MethodName}();
+
+ return string.Empty;
+ }
+ catch (ValidatedException vex)
+ {
+ return vex;
+ }
+ catch (Exception ex)
+ {
+ return new ServiceErrorException(ex);
+ }
+ }
+
+
+ //文本结束=================================================================================================================
+ }
+ else
+ {
+ //文本开始=================================================================================================================
+ public dynamic @{@classInfo.ClassMethodInfos[j].MethodName}()
+ {
+ try
+ {
+
+ var result = @{@classInfo.ClassName.StringToProtectedProerty()}.@{@classInfo.ClassMethodInfos[j].MethodName}();
+ return result;
+ }
+ catch (ValidatedException vex)
+ {
+ return vex;
+ }
+ catch (Exception ex)
+ {
+ return new ServiceErrorException(ex);
+ }
+ }
+
+
+ //文本结束=================================================================================================================
+ }
+ }
+
+
+ //只有1个参数的情况============================================
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>0)
+ {
+ //超过1个参数的情况,如果是get,不能用组合对象,如果是post,要重新组合一个类========================================
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>1 && classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]")
+ {
+
+ public class @{@classInfo.ClassMethodInfos[j].MethodName}CompositionData
+ {
+
+
+ for (var ik = 0; ik < classInfo.ClassMethodInfos[j].Parameters.Length; ik++){
+ string parameterTypeName=classInfo.ClassMethodInfos[j].Parameters[ik].ParameterTypeName;
+ if(classInfo.ClassMethodInfos[j].Parameters[ik].IsValueType)
+ {
+ if(classInfo.ClassMethodInfos[j].Parameters[ik].ParameterTypeName=="String")
+ parameterTypeName="string";
+ if(classInfo.ClassMethodInfos[j].Parameters[ik].ParameterTypeName=="Boolean")
+ parameterTypeName="bool";
+ }
+ public @parameterTypeName @classInfo.ClassMethodInfos[j].Parameters[ik].ParameterName { get; set; }
+
+
+ }
+
+
+ }
+
+ }
+
+ if(classInfo.ClassMethodInfos[j].AuthorizeName!=null)
+ {
+ @classInfo.ClassMethodInfos[j].AuthorizeName
+
+ }
+ if(classInfo.ClassMethodInfos[j].PermissionOperate!=null)
+ {
+ @{ @string.Format(classInfo.ClassMethodInfos[j].PermissionOperate,"\""+@classInfo.ClassMethodInfos[j].PermissionOperateAttribute.Name+"\"","\""+@classInfo.ClassMethodInfos[j].PermissionOperateAttribute.Operate.ToString()+"\"")
+ }
+ }
+ if(classInfo.ClassMethodInfos[j].HttpName!=null)
+ {
+ @classInfo.ClassMethodInfos[j].HttpName
+
+ }
+ if(classInfo.ClassMethodInfos[j].UnitOfWorkName!=null)
+ {
+ @classInfo.ClassMethodInfos[j].UnitOfWorkName
+
+ }
+
+ if(@classInfo.ClassMethodInfos[j].MethodReturnName=="Void")
+ {
+ string parametersName=@classInfo.ClassMethodInfos[j].Parameters[0].ParameterTypeName.Replace("String", "string").Replace("Boolean", "bool")+" "+@classInfo.ClassMethodInfos[j].Parameters[0].ParameterName;
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>1 && classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]")
+ {
+ parametersName=@classInfo.ClassMethodInfos[j].MethodName+"CompositionData compositionData";
+ }
+ else if(classInfo.ClassMethodInfos[j].Parameters.Length>1){
+ parametersName=string.Empty;
+
+ }
+ //文本开始================================================
+ public dynamic @{@classInfo.ClassMethodInfos[j].MethodName}(@{@parametersName}){
+ try
+ {
+ @{ @classInfo.ClassName.StringToProtectedProerty()}.@{@classInfo.ClassMethodInfos[j].MethodName}(@{for (var i = 0; i < classInfo.ClassMethodInfos[j].Parameters.Length; i++){
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>1){
+ if(i>0){,}compositionData.@classInfo.ClassMethodInfos[j].Parameters[i].ParameterName
+ }
+ else{
+ @classInfo.ClassMethodInfos[j].Parameters[i].ParameterName
+ }
+ }});
+
+ return string.Empty;
+ }
+ catch (ValidatedException vex)
+ {
+ return vex;
+ }
+ catch (Exception ex)
+ {
+ return new ServiceErrorException(ex);
+ }
+ }
+
+
+ //文本结束===================================================
+ }
+ else
+ {
+ string parametersName=@classInfo.ClassMethodInfos[j].Parameters[0].ParameterTypeName.Replace("String", "string").Replace("Boolean", "bool")+" "+@classInfo.ClassMethodInfos[j].Parameters[0].ParameterName;
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>1 && classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]")
+ {
+ parametersName=@classInfo.ClassMethodInfos[j].MethodName+"CompositionData compositionData";
+ }
+ else if(classInfo.ClassMethodInfos[j].Parameters.Length>1)
+ {
+ parametersName=string.Empty;
+ for (var ikb = 0; ikb < classInfo.ClassMethodInfos[j].Parameters.Length; ikb++){
+ if(ikb>0)parametersName+=", ";
+ parametersName+=@classInfo.ClassMethodInfos[j].Parameters[ikb].ParameterTypeName.Replace("String", "string").Replace("Boolean", "bool")+" "+@classInfo.ClassMethodInfos[j].Parameters[ikb].ParameterName;
+ }
+ }
+ //文本开始================================================
+ public dynamic @{@classInfo.ClassMethodInfos[j].MethodName}(@{@parametersName})
+ {
+ try
+ {
+
+ var result = @{@classInfo.ClassName.StringToProtectedProerty()}.@{@classInfo.ClassMethodInfos[j].MethodName}(@{for (var i = 0; i < classInfo.ClassMethodInfos[j].Parameters.Length; i++){
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>1){
+ if(i>0){,}if(classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]"){compositionData.}@classInfo.ClassMethodInfos[j].Parameters[i].ParameterName
+ }
+ else{
+ @classInfo.ClassMethodInfos[j].Parameters[i].ParameterName
+ }
+ }});
+ return result;
+ }
+ catch (ValidatedException vex)
+ {
+ return vex;
+ }
+ catch (Exception ex)
+ {
+ return new ServiceErrorException(ex);
+ }
+ }
+
+
+ //文本结束===================================================
+ }
+ }
+ }
+ }
+//下面}为代码段结束=================================================================================================================
+}
+
+}
+}
\ No newline at end of file
diff --git a/Templates/IData.cshtml b/Templates/IData.cshtml
new file mode 100644
index 0000000..ee58c6f
--- /dev/null
+++ b/Templates/IData.cshtml
@@ -0,0 +1,82 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+using CloudBuilder.Core.DatabaseAccessor.Entity;
+using System.ComponentModel.DataAnnotations.Schema;
+namespace @namespaceObject.Namespace@{.Data}
+
+ {
+ [TypeScript]
+ public class @sysTableSchemas[0].TableName.StringToProerty()DisplayData
+ @if (@sysTableSchemas[0].Xtype.ToUpper().Trim() == "U")
+ {}
+ {
+
+ public @sysTableSchemas[0].TableName.StringToProerty()DisplayData()
+ {
+ }
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
+
+ public @sysTableSchemas[i].TypeOfName@{if(@sysTableSchemas[i].IsNullAble=="y"){?}} @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
+
+ }
+
+
+ public static @sysTableSchemas[0].TableName.StringToProerty()DisplayData GetInstance()
+ {
+ return new @sysTableSchemas[0].TableName.StringToProerty()DisplayData();
+ }
+
+ public virtual void CopyFrom(@sysTableSchemas[0].TableName.StringToProerty()DisplayData source)
+ {
+ CopyFrom(source, true);
+ }
+
+ public virtual void CopyFrom(@sysTableSchemas[0].TableName.StringToProerty()DisplayData source, bool includeSystemFields)
+ {
+ if (source == null)
+ {
+ throw new NullReferenceException("Source entity is null.");
+ }
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName != "created_datetime" || @sysTableSchemas[i].FieldName != "created_by"
+ || @sysTableSchemas[i].FieldName != "updated_datetime" || @sysTableSchemas[i].FieldName != "updated_by")
+ {
+ this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
+
+ }
+ }
+
+ if (includeSystemFields)
+ {
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName == "created_datetime" || @sysTableSchemas[i].FieldName == "created_by"
+ || @sysTableSchemas[i].FieldName == "updated_datetime" || @sysTableSchemas[i].FieldName == "updated_by")
+ {
+ this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
+
+ }
+
+ }
+ }
+ }
+
+ public @sysTableSchemas[0].TableName.StringToProerty()DisplayData Clone()
+ {
+ @sysTableSchemas[0].TableName.StringToProerty()DisplayData result = new @sysTableSchemas[0].TableName.StringToProerty()DisplayData ();
+ result.CopyFrom(this);
+
+ return result;
+ }
+
+ }
+}
+
diff --git a/Templates/IDisplayData.cshtml b/Templates/IDisplayData.cshtml
new file mode 100644
index 0000000..a171f2e
--- /dev/null
+++ b/Templates/IDisplayData.cshtml
@@ -0,0 +1,31 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+using CloudBuilder.Core.DatabaseAccessor.Entity;
+using System.ComponentModel.DataAnnotations.Schema;
+namespace @namespaceObject.Namespace@{.Data}
+
+ {
+ ///
+ /// 排除实体类标记
+ ///
+ [NotMapped]
+ [TypeScript]
+ public class @sysTableSchemas[0].TableName.StringToProerty()DisplayData:@sysTableSchemas[0].TableName.StringToProerty()Entity
+ @if (@sysTableSchemas[0].Xtype.ToUpper().Trim() == "U")
+ {}
+ {
+
+ public @sysTableSchemas[0].TableName.StringToProerty()DisplayData()
+ {
+ }
+ public @sysTableSchemas[0].TableName.StringToProerty()DisplayData(@sysTableSchemas[0].TableName.StringToProerty()Entity entity)
+ {
+ CopyFrom(entity);
+ }
+
+ }
+}
+
diff --git a/Templates/IDto.cshtml b/Templates/IDto.cshtml
new file mode 100644
index 0000000..b0aa509
--- /dev/null
+++ b/Templates/IDto.cshtml
@@ -0,0 +1,81 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+using CloudBuilder.Core.DatabaseAccessor.Entity;
+using System.ComponentModel.DataAnnotations.Schema;
+namespace @namespaceObject.Namespace@{.Data}
+
+ {
+ public class @sysTableSchemas[0].TableName.StringToProerty()DisplayData
+ @if (@sysTableSchemas[0].Xtype.ToUpper().Trim() == "U")
+ {}
+ {
+
+ public @sysTableSchemas[0].TableName.StringToProerty()DisplayData()
+ {
+ }
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
+
+ public @sysTableSchemas[i].TypeOfName@{if(@sysTableSchemas[i].IsNullAble=="y"){?}} @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
+
+ }
+
+
+ public static @sysTableSchemas[0].TableName.StringToProerty()DisplayData GetInstance()
+ {
+ return new @sysTableSchemas[0].TableName.StringToProerty()DisplayData();
+ }
+
+ public virtual void CopyFrom(@sysTableSchemas[0].TableName.StringToProerty()DisplayData source)
+ {
+ CopyFrom(source, true);
+ }
+
+ public virtual void CopyFrom(@sysTableSchemas[0].TableName.StringToProerty()DisplayData source, bool includeSystemFields)
+ {
+ if (source == null)
+ {
+ throw new NullReferenceException("Source entity is null.");
+ }
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName != "created_datetime" || @sysTableSchemas[i].FieldName != "created_by"
+ || @sysTableSchemas[i].FieldName != "updated_datetime" || @sysTableSchemas[i].FieldName != "updated_by")
+ {
+ this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
+
+ }
+ }
+
+ if (includeSystemFields)
+ {
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName == "created_datetime" || @sysTableSchemas[i].FieldName == "created_by"
+ || @sysTableSchemas[i].FieldName == "updated_datetime" || @sysTableSchemas[i].FieldName == "updated_by")
+ {
+ this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
+
+ }
+
+ }
+ }
+ }
+
+ public @sysTableSchemas[0].TableName.StringToProerty()DisplayData Clone()
+ {
+ @sysTableSchemas[0].TableName.StringToProerty()DisplayData result = new @sysTableSchemas[0].TableName.StringToProerty()DisplayData ();
+ result.CopyFrom(this);
+
+ return result;
+ }
+
+ }
+}
+
diff --git a/Templates/IEntity.cshtml b/Templates/IEntity.cshtml
new file mode 100644
index 0000000..690bd77
--- /dev/null
+++ b/Templates/IEntity.cshtml
@@ -0,0 +1,186 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+using CloudBuilder.Core.Authorization;
+using CloudBuilder.Core.DatabaseAccessor.Entity;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+@{
+ string entityBase = string.Format("EntityBase<{0}>", @modelData.KeyType);
+ if (@modelData.KeyCount > 1)
+ {
+ entityBase = string.Format("EntityBase<{0}>", @modelData.KeyType);
+ }
+ else if (@sysTableSchemas[0].Xtype.ToUpper().Trim() != "U")
+ {
+ entityBase = "ViewEntityBase";
+ }
+}
+namespace @namespaceObject.Namespace@{.Entity}
+
+ {
+ [TypeScript]
+ [Table("@sysTableSchemas[0].TableName")]
+ public class @sysTableSchemas[0].TableName.StringToProerty()Entity : @entityBase
+ @if (@sysTableSchemas[0].Xtype.ToUpper().Trim() == "U")
+ {}
+ {
+
+ public @sysTableSchemas[0].TableName.StringToProerty()Entity()
+ {
+ }
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ROW_VERSION")
+ {
+ [Column("row_version")]
+ [Timestamp]
+ public byte[]? RowVersion { get; set; }
+
+ continue;
+ }
+
+ if (@sysTableSchemas[i].Pk > 0 && @modelData.KeyCount < 2)
+ {
+ [Key]
+
+ }
+ if (@sysTableSchemas[i].IsIdentity > 0)
+ {
+ [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
+
+ }
+ if (@sysTableSchemas[i].TypeName == "decimal")
+ {
+ [Column("@sysTableSchemas[i].FieldName",TypeName = "@sysTableSchemas[i].TypeName(@sysTableSchemas[i].MaxLength,@sysTableSchemas[i].Scale)")]
+
+ }
+ else
+ {
+ [Column("@sysTableSchemas[i].FieldName")]
+
+ }
+ if (@sysTableSchemas[i].TypeOfName == "string")
+ {
+ public @sysTableSchemas[i].TypeOfName@{if(@sysTableSchemas[i].IsNullAble=="y"){?}} @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
+
+ }
+ else
+ {
+ public @sysTableSchemas[i].TypeOfName @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
+
+ }
+ }
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ public const string @sysTableSchemas[i].FieldName.ToUpper() = "@sysTableSchemas[i].FieldName.StringToProerty()";
+
+ }
+
+ public const string DB_NAME_@sysTableSchemas[0].TableName.ToUpper() = "@sysTableSchemas[0].TableName";
+ @{
+ string fs = "";
+ }
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
+ fs += @sysTableSchemas[i].FieldName + ",";
+ }
+ @{
+ fs = fs.Substring(0, fs.Length - 1);
+ } public const string DB_NAME_FIELDS="@(fs)";
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ public const string DB_@sysTableSchemas[i].FieldName.ToUpper() = "@sysTableSchemas[i].FieldName";
+
+ }
+
+
+ public static @sysTableSchemas[0].TableName.StringToProerty()Entity GetInstance()
+ {
+ return new @sysTableSchemas[0].TableName.StringToProerty()Entity();
+ }
+
+ public virtual void CopyFrom(@sysTableSchemas[0].TableName.StringToProerty()Entity source)
+ {
+ CopyFrom(source, true);
+ }
+
+ public virtual void CopyFrom(@sysTableSchemas[0].TableName.StringToProerty()Entity source, bool includeSystemFields)
+ {
+ if (source == null)
+ {
+ throw new NullReferenceException("Source entity is null.");
+ }
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName != "created_datetime" || @sysTableSchemas[i].FieldName != "created_by"
+ || @sysTableSchemas[i].FieldName != "updated_datetime" || @sysTableSchemas[i].FieldName != "updated_by")
+ {
+ this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
+
+ }
+ }
+
+ if (includeSystemFields)
+ {
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName == "created_datetime" || @sysTableSchemas[i].FieldName == "created_by"
+ || @sysTableSchemas[i].FieldName == "updated_datetime" || @sysTableSchemas[i].FieldName == "updated_by")
+ {
+ this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
+
+ }
+
+ }
+ }
+ }
+
+ public override string GetSelectFrom()
+ {
+ return $" select {DB_NAME_FIELDS} from { DB_NAME_@sysTableSchemas[0].TableName.ToUpper()} with(nolock) ";
+ }
+
+ public override string GetSelectCountFrom(string sqlWhere)
+ {
+ return $" select count(*) from { DB_NAME_@sysTableSchemas[0].TableName.ToUpper()} with(nolock) where 1=1 {sqlWhere}";
+ }
+
+ public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
+ {
+ if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].Pk > 0)
+ {
+ if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_@sysTableSchemas[i].FieldName.ToUpper() ;
+ break;
+ }
+ }
+
+ @if(sysTableSchemas.Sum(x=>x.Pk)==0)
+ {
+ if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_@sysTableSchemas[0].FieldName.ToUpper() ;
+ }
+ string top = limit > 0 ? $"top {limit}" : "";
+ return $" select {top} {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_@sysTableSchemas[0].TableName.ToUpper()} with(nolock) where 1=1 {sqlWhere} ) a where num> {limit * (start - 1)}";
+ }
+
+ public @sysTableSchemas[0].TableName.StringToProerty()Entity Clone()
+ {
+ @sysTableSchemas[0].TableName.StringToProerty()Entity result = new @sysTableSchemas[0].TableName.StringToProerty()Entity();
+ result.CopyFrom(this);
+
+ return result;
+ }
+
+ }
+}
diff --git a/Templates/IEntityKey.cshtml b/Templates/IEntityKey.cshtml
new file mode 100644
index 0000000..bb015e3
--- /dev/null
+++ b/Templates/IEntityKey.cshtml
@@ -0,0 +1,72 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+using CloudBuilder.Core.Authorization;
+namespace @namespaceObject.Namespace
+{
+ [TypeScript]
+ public class @sysTableSchemas[0].TableName.StringToProerty()EntityKey
+ {
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].Pk > 0)
+ {
+ public @sysTableSchemas[i].TypeOfName @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
+
+ }
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (this == obj) return true;
+
+ @sysTableSchemas[0].TableName.StringToProerty()EntityKey pkey = obj as @sysTableSchemas[0].TableName.StringToProerty()EntityKey;
+ if (pkey == null) return false;
+
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].Pk > 0)
+ {
+ if (@sysTableSchemas[i].FieldName.StringToProerty() != pkey.@sysTableSchemas[i].FieldName.StringToProerty()) return false;
+
+ }
+ }
+
+ return true;
+ }
+
+
+ public override string ToString()
+ {
+ string declareSql="";
+ @{int j = 0;}
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].Pk > 0)
+ {
+ declareSql=declareSql+$"declare @@__tkey_@sysTableSchemas[i].FieldName.StringToProerty()_@j.ToString() varchar(50) select @@__tkey_@sysTableSchemas[i].FieldName.StringToProerty()_@j.ToString() ='{@sysTableSchemas[i].FieldName.StringToProerty()}'; " ;
+ j++;
+ }
+ }
+
+ return declareSql;
+ }
+ }
+ }
+ /* @if (modelData.KeyCount > 0)
+ {builder.Entity<@sysTableSchemas[0].TableName.StringToProerty()Entity>().HasKey(c => new {int k = 0;
+ for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].Pk > 0)
+ {
+ k++;
+ c.@sysTableSchemas[i].FieldName.StringToProerty()if (modelData.KeyCount != k)
+ {,}
+
+ }
+ }
+ });
+}
+ */
diff --git a/Templates/IService.cshtml b/Templates/IService.cshtml
new file mode 100644
index 0000000..600c218
--- /dev/null
+++ b/Templates/IService.cshtml
@@ -0,0 +1,17 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+
+using @namespaceObject.Assembly.ToString()@{.Entity};
+using @namespaceObject.Assembly.ToString()@{.SearchCriteria};
+using CloudBuilder.Core.Service;
+
+namespace @namespaceObject.Assembly.ToString()@{.Service}
+
+{
+ public interface @{I}@sysTableSchemas[0].TableName.StringToProerty()Service :IServiceBase<@sysTableSchemas[0].TableName.StringToProerty()Entity, @modelData.KeyType ,@sysTableSchemas[0].TableName.StringToProerty()SearchCriteria>
+ {
+ }
+}
diff --git a/Templates/Permission.auto.cshtml b/Templates/Permission.auto.cshtml
new file mode 100644
index 0000000..881e11c
--- /dev/null
+++ b/Templates/Permission.auto.cshtml
@@ -0,0 +1,15 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+namespace @namespaceObject.Namespace@{.Policy}
+
+{
+ public partial class @namespaceObject.Assembly.Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy
+ {
+ //***BEGIN***
+ public const string @sysTableSchemas[0].TableName.StringToProerty() = "@sysTableSchemas[0].TableName.StringToProerty()";
+ //***END***
+ }
+}
\ No newline at end of file
diff --git a/Templates/Permission.cshtml b/Templates/Permission.cshtml
new file mode 100644
index 0000000..6c514ca
--- /dev/null
+++ b/Templates/Permission.cshtml
@@ -0,0 +1,7 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+public const string @sysTableSchemas[0].TableName.StringToProerty() = "@sysTableSchemas[0].TableName.StringToProerty()";
+
\ No newline at end of file
diff --git a/Templates/RegistEntity.Key.cshtml b/Templates/RegistEntity.Key.cshtml
new file mode 100644
index 0000000..de0c952
--- /dev/null
+++ b/Templates/RegistEntity.Key.cshtml
@@ -0,0 +1,26 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+@if (modelData.KeyCount > 1)
+{
+builder.Entity<@sysTableSchemas[0].TableName.StringToProerty()Entity>().HasKey(c => new {int k = 0;
+ for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].Pk > 0)
+ {
+ k++;
+ c.@sysTableSchemas[i].FieldName.StringToProerty()if (modelData.KeyCount != k)
+ {,}
+
+ }
+}
+});
+
+}
+else @if (modelData.KeyCount == 0)
+{
+builder.Entity<@sysTableSchemas[0].TableName.StringToProerty()Entity>(eb => { eb.HasNoKey(); });
+
+}
\ No newline at end of file
diff --git a/Templates/RegistEntity.cshtml b/Templates/RegistEntity.cshtml
new file mode 100644
index 0000000..c0567fd
--- /dev/null
+++ b/Templates/RegistEntity.cshtml
@@ -0,0 +1,47 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+using CloudBuilder.Core.DependencyInjection.EFCore;
+using Microsoft.EntityFrameworkCore;
+using System.Reflection;
+
+namespace @namespaceObject.Namespace@{.Entity}
+
+{
+ public class @namespaceObject.Namespace.Replace(".","")RegistEntity : IMasterRegistEntityType
+ {
+ ///
+ ///注入模块内的所有实体类
+ ///
+ ///
+ public void RegistEntity(ModelBuilder builder)
+ {
+ string _assemblyName = Assembly.GetExecutingAssembly().GetName().Name;
+ //注入所有Entity实体类
+ AddEntityType(builder, _assemblyName);
+ //如果Entity实体类不是单一主键,要单独重写注入
+ RegistKeys(builder);
+ }
+
+ public void AddEntityType(ModelBuilder builder, string _assemblyName)
+ {
+ RegistEntityHelper.AddMasterEntityType(builder, _assemblyName);
+ }
+
+ ///
+ ///如果存在多个主键的,要在RegistKeys方法注入
+ ///builder.Entity().HasKey(c => new { c.TableName, c.FieldName });
+ ///builder.Entity(eb => { eb.HasNoKey(); });
+ ///
+ ///
+ public void RegistKeys(ModelBuilder builder)
+ {
+ //***BEGIN***
+
+ //***END***
+ }
+ }
+}
+
diff --git a/Templates/Request.cshtml b/Templates/Request.cshtml
new file mode 100644
index 0000000..579d38f
--- /dev/null
+++ b/Templates/Request.cshtml
@@ -0,0 +1,169 @@
+@{
+ ModelData modelData = Model;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ ClassInfo classInfo= modelData.ClassInfos.FirstOrDefault();
+ //ClassInfo classInfo= modelData.ClassInfos.Where(x=>x.ClassName=="SecurityUserService").FirstOrDefault();
+}
+using CloudBuilder.Core.DependencyInjection.Request;
+using CloudBuilder.Core.Request;
+using CloudBuilder.Core.Service;
+using Microsoft.Extensions.DependencyInjection;
+@{
+ if(classInfo.Usings!=null && classInfo.Usings.Length>0)
+ {
+ for (var i = 0; i < classInfo.Usings.Length; i++)
+ {
+ if(classInfo.Usings[i]=="CloudBuilder.Core.Service") continue;
+ using @classInfo.Usings[i];
+
+ }
+ }
+}
+
+namespace @namespaceObject.Namespace
+{
+
+public class @{@classInfo.ClassName.Replace("Service", "")}Request : IRequest
+{
+
+private readonly IServiceRequest serviceRequest;
+public @{@classInfo.ClassName.Replace("Service", "")}Request(IServiceRequest serviceRequest)
+{
+this.serviceRequest = serviceRequest;
+}
+
+@{
+ if(classInfo.ClassMethodInfos!=null && classInfo.ClassMethodInfos.Length>0 && classInfo.ClassMethodInfos[0].Parameters!=null)
+ {
+ for (var j= 0; j< classInfo.ClassMethodInfos.Length; j++)
+ {
+ string methodReturnName="void ";
+ if(classInfo.ClassMethodInfos[j].MethodReturnName!="Void")
+ {
+ methodReturnName=" "+classInfo.ClassMethodInfos[j].MethodReturnName.Replace("String", "string").Replace("Boolean", "bool")+" ";
+ }
+ //没有参数的情况=======================================
+ if(classInfo.ClassMethodInfos[j].Parameters.Length==0)
+ {
+ //文本开始=================================================================================================================
+ public @{ @methodReturnName @classInfo.ClassMethodInfos[j].MethodName }()
+ {
+ @{
+ //[HttpGet]一定要有返回值,否则使用[HttpPost]
+ if(classInfo.ClassMethodInfos[j].HttpName=="[HttpGet]"){
+ return Task.Run(() => serviceRequest.GetAsync<@{@classInfo.ClassMethodInfos[j].MethodReturnName.Replace("String", "string").Replace("Boolean", "bool")}>("/@{@classInfo.ClassName.Replace("Service", "")}/@{@classInfo.ClassMethodInfos[j].MethodName}")).GetAwaiter().GetResult();
+ }
+ else{
+ //[HttpPost]可以有无返回值
+ if(classInfo.ClassMethodInfos[j].MethodReturnName!="Void"){return } Task.Run(() => serviceRequest.@{if(classInfo.ClassMethodInfos[j].MethodReturnName!="Void"){PostAsJsonAsync<@{@classInfo.ClassMethodInfos[j].MethodReturnName.Replace("String", "string").Replace("Boolean", "bool")}> }else{PostAsync}}("/@{@classInfo.ClassName.Replace("Service", "")}/@{@classInfo.ClassMethodInfos[j].MethodName}")).GetAwaiter().GetResult();
+ }
+ }
+ }
+
+
+ //文本结束=================================================================================================================
+ }
+
+
+ //只有1个参数的情况============================================
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>0)
+ {
+ //超过1个参数的情况,如果是get,不能用组合对象,如果是post,要重新组合一个类========================================
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>1 && classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]")
+ {
+
+ public class @{@classInfo.ClassMethodInfos[j].MethodName}CompositionData@{@classInfo.ClassMethodInfos[j].Parameters.Length}
+ {
+
+
+ for (var ik = 0; ik < classInfo.ClassMethodInfos[j].Parameters.Length; ik++){
+ string parameterTypeName=classInfo.ClassMethodInfos[j].Parameters[ik].ParameterTypeName;
+ if(classInfo.ClassMethodInfos[j].Parameters[ik].IsValueType)
+ {
+ if(classInfo.ClassMethodInfos[j].Parameters[ik].ParameterTypeName=="String")
+ parameterTypeName="string";
+ if(classInfo.ClassMethodInfos[j].Parameters[ik].ParameterTypeName=="Boolean")
+ parameterTypeName="bool";
+ }
+ public @parameterTypeName @classInfo.ClassMethodInfos[j].Parameters[ik].ParameterName { get; set; }
+
+
+ }
+
+
+ }
+
+ }
+
+
+ string parametersName=@classInfo.ClassMethodInfos[j].Parameters[0].ParameterTypeName.Replace("String", "string").Replace("Boolean", "bool")+" "+@classInfo.ClassMethodInfos[j].Parameters[0].ParameterName;
+ string content=string.Empty;
+ //如果是[HttpGet],一定是值参数,统一使用组合参数
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>0 && classInfo.ClassMethodInfos[j].HttpName=="[HttpGet]")
+ {
+ content += "var compositionData = new Dictionary();\t\r";
+
+ for (var iac = 0; iac < classInfo.ClassMethodInfos[j].Parameters.Length; iac++)
+ {
+ content += "compositionData.Add(\"" + @classInfo.ClassMethodInfos[j].Parameters[iac].ParameterName + "\", " + @classInfo.ClassMethodInfos[j].Parameters[iac].ParameterName + ".ToString());\t\r";
+ }
+ content += "return Task.Run(() => serviceRequest.GetWithQueryAsync<"+@classInfo.ClassMethodInfos[j].MethodReturnName.Replace("String", "string").Replace("Boolean", "bool")+">(\"/"+@classInfo.ClassName.Replace("Service", "")+"/"+@classInfo.ClassMethodInfos[j].MethodName+"\", compositionData)).GetAwaiter().GetResult();";
+ }
+ else if(classInfo.ClassMethodInfos[j].Parameters.Length>0 && classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]")
+ {
+ string returnValue=string.Empty;
+ if(classInfo.ClassMethodInfos[j].MethodReturnName!="Void")returnValue="return";
+
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>1)
+ {
+ string CompositionData=classInfo.ClassMethodInfos[j].MethodName+"CompositionData"+classInfo.ClassMethodInfos[j].Parameters.Length;
+ content += "var compositionData = new "+CompositionData+"{\t\r";
+ for (var ikp = 0; ikp < classInfo.ClassMethodInfos[j].Parameters.Length; ikp++)
+ {
+ if(ikp>0) content += ",\t\r";
+ content += @classInfo.ClassMethodInfos[j].Parameters[ikp].ParameterName+" = "+@classInfo.ClassMethodInfos[j].Parameters[ikp].ParameterName;
+ }
+ content += " };\t\r";
+ string rv=classInfo.ClassMethodInfos[j].MethodReturnName.Replace("String", "string").Replace("Boolean", "bool").Replace("Void", "dynamic");
+ content += returnValue+" Task.Run(() => serviceRequest.PostAsJsonAsync<"+CompositionData+", "+rv+">(\"/"+@classInfo.ClassName.Replace("Service", "")+"/"+@classInfo.ClassMethodInfos[j].MethodName+"\", compositionData)).GetAwaiter().GetResult();";
+ }
+ else
+ {
+ string post="PostAsync";
+ if(classInfo.ClassMethodInfos[j].MethodReturnName!="Void")post="PostAsJsonAsync"+string.Format("<{1},{0}>",classInfo.ClassMethodInfos[j].MethodReturnName.Replace("String", "string").Replace("Boolean", "bool"),@classInfo.ClassMethodInfos[j].Parameters[0].ParameterTypeName.Replace("String", "string").Replace("Boolean", "bool"));
+ if(!classInfo.ClassMethodInfos[j].Parameters[0].IsValueType && classInfo.ClassMethodInfos[j].MethodReturnName=="Void")post="PostAsJsonAsync"+string.Format("<{0},dynamic>",@classInfo.ClassMethodInfos[j].Parameters[0].ParameterTypeName.Replace("String", "string").Replace("Boolean", "bool"));
+ if(classInfo.ClassMethodInfos[j].Parameters[0].IsValueType)
+ {
+ if(classInfo.ClassMethodInfos[j].MethodReturnName!="Void"){post="PostAsJsonAsync"+string.Format("<{0}>",classInfo.ClassMethodInfos[j].MethodReturnName.Replace("String", "string").Replace("Boolean", "bool"));}
+ content += returnValue+" Task.Run(() => serviceRequest."+post+"(\"/"+@classInfo.ClassName.Replace("Service", "")+"/"+@classInfo.ClassMethodInfos[j].MethodName+"?"+@classInfo.ClassMethodInfos[j].Parameters[0].ParameterName+"=\" + "+@classInfo.ClassMethodInfos[j].Parameters[0].ParameterName+".ToString())).GetAwaiter().GetResult();";
+ }
+ else{
+ content += returnValue+" Task.Run(() => serviceRequest."+post+"(\"/"+@classInfo.ClassName.Replace("Service", "")+"/"+@classInfo.ClassMethodInfos[j].MethodName+"\" , "+@classInfo.ClassMethodInfos[j].Parameters[0].ParameterName+")).GetAwaiter().GetResult();";
+ }
+ }
+
+ }
+
+
+ parametersName=string.Empty;
+ for (var ikb = 0; ikb < classInfo.ClassMethodInfos[j].Parameters.Length; ikb++){
+ if(ikb>0)parametersName+=", ";
+ parametersName+=@classInfo.ClassMethodInfos[j].Parameters[ikb].ParameterTypeName.Replace("String", "string").Replace("Boolean", "bool")+" "+@classInfo.ClassMethodInfos[j].Parameters[ikb].ParameterName;
+ }
+ //文本开始================================================
+ public @{@methodReturnName @classInfo.ClassMethodInfos[j].MethodName}(@{@parametersName})
+ {
+ @{@content.ToString()}
+ }
+
+
+ //文本结束===================================================
+ }
+ }
+ }
+//下面}为代码段结束=================================================================================================================
+}
+
+}
+}
\ No newline at end of file
diff --git a/Templates/SearchCriteria.cshtml b/Templates/SearchCriteria.cshtml
new file mode 100644
index 0000000..7ab8c28
--- /dev/null
+++ b/Templates/SearchCriteria.cshtml
@@ -0,0 +1,16 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+using CloudBuilder.Core.Authorization;
+using CloudBuilder.Core.Service;
+namespace @namespaceObject.Namespace@{.SearchCriteria}
+
+{
+ [TypeScript]
+ public class @sysTableSchemas[0].TableName.StringToProerty()SearchCriteria: AbstractSearchCriteria
+ {
+
+ }
+}
diff --git a/Templates/Service.cshtml b/Templates/Service.cshtml
new file mode 100644
index 0000000..927e70f
--- /dev/null
+++ b/Templates/Service.cshtml
@@ -0,0 +1,141 @@
+@{
+ ModelData modelData = Model;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+}
+using CloudBuilder.Core.DatabaseAccessor.Entity;
+using Microsoft.AspNetCore.Authorization;
+using CloudBuilder.Core.DatabaseAccessor;
+@{
+ using @namespaceObject.Assembly.ToString().Entity;
+ using @namespaceObject.Assembly.ToString().Policy;
+ using @namespaceObject.Assembly.ToString().SearchCriteria;
+}
+
+namespace @namespaceObject.Assembly.ToString()@{.Service}
+
+{
+ public class @sysTableSchemas[0].TableName.StringToProerty()Service : I@{@sysTableSchemas[0].TableName.StringToProerty()}Service
+ {
+ private readonly IApplicationService service;
+
+ private IRepository<@{@sysTableSchemas[0].TableName.StringToProerty()}Entity> repository;
+ public @{@sysTableSchemas[0].TableName.StringToProerty()}Service(IApplicationService service)
+ {
+ this.service = service;
+ repository = service.GetRepository>();
+ }
+ @if (@modelData.KeyCount < 2)
+ {
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
+
+ if (@sysTableSchemas[i].Pk > 0 && @modelData.KeyCount < 2)
+ {
+
+ [PermissionOperate(name: @namespaceObject.Assembly.ToString().Replace(".Service", "").Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy.@{@sysTableSchemas[0].TableName.StringToProerty()}, operate: Operate.Find)]
+ public @{@sysTableSchemas[0].TableName.StringToProerty()}Entity FindByKey(@modelData.KeyType key)
+ {
+ return repository.DetachedEntities.Where(x => x.@{ @sysTableSchemas[i].FieldName.StringToProerty()} == key).FirstOrDefault()!;
+ }
+
+ }
+ }
+ }
+ else if (@modelData.KeyCount > 1)
+ {
+
+ [PermissionOperate(name: @namespaceObject.Assembly.ToString().Replace(".Service", "").Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy.@{@sysTableSchemas[0].TableName.StringToProerty()}, operate: Operate.Find)]
+ public @{@sysTableSchemas[0].TableName.StringToProerty()}Entity FindByKey(@{@sysTableSchemas[0].TableName.StringToProerty()}EntityKey key)
+ {
+ return repository.DetachedEntities.Where(x => 1==1
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
+
+ if (@sysTableSchemas[i].Pk > 0)
+ {
+
+ && x.@{ @sysTableSchemas[i].FieldName.StringToProerty()} == key.@{ @sysTableSchemas[i].FieldName.StringToProerty()}
+
+ }
+ }
+
+ ).FirstOrDefault()!;
+ }
+
+ }
+
+ //[PermissionOperate(name: @namespaceObject.Assembly.ToString().Replace(".Service", "").Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy.@{@sysTableSchemas[0].TableName.StringToProerty()}, operate: Operate.Find)]
+ public dynamic FindBySearchCriteria(@{@sysTableSchemas[0].TableName.StringToProerty()}SearchCriteria criteria)
+ {
+ throw new NotImplementedException();
+ }
+
+ //[PermissionOperate(name: @namespaceObject.Assembly.ToString().Replace(".Service", "").Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy.@{@sysTableSchemas[0].TableName.StringToProerty()}, operate: Operate.Print)]
+ public dynamic PrintBySearchCriteria(@{@sysTableSchemas[0].TableName.StringToProerty()}SearchCriteria criteria)
+ {
+ throw new NotImplementedException();
+ }
+
+ [PermissionOperate(name: @namespaceObject.Assembly.ToString().Replace(".Service", "").Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy.@{@sysTableSchemas[0].TableName.StringToProerty()}, operate: Operate.Insert)]
+ [UnitOfWork]
+ public @{@sysTableSchemas[0].TableName.StringToProerty()}Entity Insert(@{@sysTableSchemas[0].TableName.StringToProerty()}Entity data)
+ {
+ throw new NotImplementedException();
+ }
+
+ [PermissionOperate(name: @namespaceObject.Assembly.ToString().Replace(".Service", "").Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy.@{@sysTableSchemas[0].TableName.StringToProerty()}, operate: Operate.Update)]
+ [UnitOfWork]
+ public @{@sysTableSchemas[0].TableName.StringToProerty()}Entity Update(@{@sysTableSchemas[0].TableName.StringToProerty()}Entity data)
+ {
+ throw new NotImplementedException();
+ }
+
+ @if (@modelData.KeyCount < 2)
+ {
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
+
+ if (@sysTableSchemas[i].Pk > 0 && @modelData.KeyCount < 2)
+ {
+
+ [PermissionOperate(name: @namespaceObject.Assembly.ToString().Replace(".Service", "").Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy.@{@sysTableSchemas[0].TableName.StringToProerty()}, operate: Operate.Delete)]
+ [UnitOfWork]
+ public void Delete(@modelData.KeyType key)
+ {
+ var ent= repository.DetachedEntities.Where(x => x.@{ @sysTableSchemas[i].FieldName.StringToProerty()} == key).FirstOrDefault()!;
+ if (ent != null) { repository.DeleteNow(ent); }
+ }
+
+ }
+ }
+ }
+ else if (@modelData.KeyCount > 1)
+ {
+
+ [PermissionOperate(name: @namespaceObject.Assembly.ToString().Replace(".Service", "").Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy.@{@sysTableSchemas[0].TableName.StringToProerty()}, operate: Operate.Delete)]
+ public void Delete(@{@sysTableSchemas[0].TableName.StringToProerty()}EntityKey key)
+ {
+ @sysTableSchemas[0].TableName.StringToProerty()Entity ent = repository.DetachedEntities.Where(x => 1==1
+ @for (var i = 0; i < sysTableSchemas.Length; i++)
+ {
+ if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
+
+ if (@sysTableSchemas[i].Pk > 0)
+ {
+
+ && x.@{ @sysTableSchemas[i].FieldName.StringToProerty()} == key.@{ @sysTableSchemas[i].FieldName.StringToProerty()}
+
+ }
+ }
+
+ ).FirstOrDefault()!;
+ if (ent != null) { repository.DeleteNow(ent); }
+ }
+
+ }
+ }
+}
diff --git a/Templates/TypeScript.cshtml b/Templates/TypeScript.cshtml
new file mode 100644
index 0000000..8a5af3c
--- /dev/null
+++ b/Templates/TypeScript.cshtml
@@ -0,0 +1,115 @@
+@{
+ ModelData modelData = Model;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ ClassInfo classInfo= modelData.ClassInfos.FirstOrDefault();
+ //ClassInfo classInfo= modelData.ClassInfos.Where(x=>x.ClassName=="SecurityUserSearchCriteria").FirstOrDefault();
+}
+@{
+ if(classInfo.Usings!=null && classInfo.Usings.Length>0)
+ {
+ for (var i = 0; i < classInfo.Usings.Length; i++)
+ {
+ import { @classInfo.Usings[i].StringToProerty() } from "./@classInfo.Usings[i].StringToProtectedProerty()";
+
+ }
+ }
+}
+@{
+ string implementTypeName=string.IsNullOrEmpty(classInfo.ImplementTypeName)?"":" extends "+classInfo.ImplementTypeName;
+ if(!string.IsNullOrEmpty(implementTypeName))
+ {
+ import { @classInfo.ImplementTypeName.StringToProerty() } from "./@classInfo.ImplementTypeName.StringToProtectedProerty()";
+
+ }
+}
+export class @classInfo.ClassName @implementTypeName
+{
+@{
+ if(classInfo.ClassProperties!=null && classInfo.ClassProperties.Length>0)
+ {
+ for (var j= 0; j< classInfo.ClassProperties.Length; j++)
+ {
+ if(classInfo.ClassProperties[j].PropertyTypeName=="Nullable`1")
+ {
+ public @classInfo.ClassProperties[j].PropertyName?: Date= null!;
+
+ }
+ else if(classInfo.ClassProperties[j].PropertyTypeName.ToLower()=="datetime")
+ {
+ public @classInfo.ClassProperties[j].PropertyName: Date = new Date();
+
+ }
+ else if(classInfo.ClassProperties[j].PropertyTypeName=="Boolean")
+ {
+ public @classInfo.ClassProperties[j].PropertyName: boolean =false;
+
+ }
+ else if(classInfo.ClassProperties[j].PropertyTypeName=="String")
+ {
+ public @classInfo.ClassProperties[j].PropertyName: string = "";
+
+ }
+ else if(classInfo.ClassProperties[j].PropertyTypeName=="Int32" || classInfo.ClassProperties[j].PropertyTypeName=="Int64" || classInfo.ClassProperties[j].PropertyTypeName=="Int16" || classInfo.ClassProperties[j].PropertyTypeName=="Long" || classInfo.ClassProperties[j].PropertyTypeName.ToLower()=="decimal")
+ {
+ public @classInfo.ClassProperties[j].PropertyName: number = 0;
+
+ }
+ else if(classInfo.ClassProperties[j].PropertyTypeName=="Int32[]" || classInfo.ClassProperties[j].PropertyTypeName=="Int64[]" || classInfo.ClassProperties[j].PropertyTypeName=="Int16[]" || classInfo.ClassProperties[j].PropertyTypeName=="Long[]" || classInfo.ClassProperties[j].PropertyTypeName.ToLower()=="decimal[]")
+ {
+ public @classInfo.ClassProperties[j].PropertyName: number[] = [];
+
+ }
+ else if(classInfo.ClassProperties[j].PropertyTypeName.Contains("String[]"))
+ {
+ public @classInfo.ClassProperties[j].PropertyName: string[]= [];
+
+ }
+ else if(!classInfo.ClassProperties[j].IsValueType && classInfo.ClassProperties[j].PropertyTypeName.Contains("[]"))
+ {
+ public @classInfo.ClassProperties[j].PropertyName: @classInfo.ClassProperties[j].PropertyTypeName.StringToProerty() = [];
+
+ }
+ else if(classInfo.ClassProperties[j].PropertyTypeName=="any")
+ {
+ public @classInfo.ClassProperties[j].PropertyName: any;
+
+ }
+ else if(!classInfo.ClassProperties[j].IsValueType)
+ {
+ public @classInfo.ClassProperties[j].PropertyName: @classInfo.ClassProperties[j].PropertyTypeName.StringToProerty() = new @{@classInfo.ClassProperties[j].PropertyTypeName.StringToProerty() }();
+
+ }
+ else
+ {
+ public @classInfo.ClassProperties[j].PropertyName: any ={}
+
+ }
+ }
+ }
+ }
+
+@{
+ if(classInfo.ClassFields!=null && classInfo.ClassFields.Length>0)
+ {
+ for (var j= 0; j< classInfo.ClassFields.Length; j++)
+ {
+ if(classInfo.ClassFields[j].FieldTypeName =="String")
+ {
+ static readonly @classInfo.ClassFields[j].FieldName : string ='@classInfo.ClassFields[j].FieldValue';
+
+ }
+ if(classInfo.ClassFields[j].FieldTypeName =="Boolean")
+ {
+ static readonly @classInfo.ClassFields[j].FieldName : Boolean ='@classInfo.ClassFields[j].FieldValue';
+
+ }
+ else if(classInfo.ClassFields[j].FieldTypeName =="Int32" || classInfo.ClassFields[j].FieldTypeName =="Int64" || classInfo.ClassFields[j].FieldTypeName =="Int16" || classInfo.ClassFields[j].FieldTypeName =="Long" || classInfo.ClassFields[j].FieldTypeName .ToLower()=="decimal")
+ {
+ static readonly @classInfo.ClassFields[j].FieldName: number =@classInfo.ClassFields[j].FieldValue;
+
+ }
+ }
+ }
+ }
+}
diff --git a/Templates/TypeScriptService.cshtml b/Templates/TypeScriptService.cshtml
new file mode 100644
index 0000000..8c244b8
--- /dev/null
+++ b/Templates/TypeScriptService.cshtml
@@ -0,0 +1,147 @@
+@{
+ ModelData modelData = Model;
+ NamespaceObject namespaceObject = modelData.NamespaceObject;
+ SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
+ ClassInfo classInfo= modelData.ClassInfos.FirstOrDefault();
+ //ClassInfo classInfo= modelData.ClassInfos.Where(x=>x.ClassName=="SecurityUserService").FirstOrDefault();
+}
+@if(classInfo.IsDownload)
+{
+ import { request,download } from "@@/utils/request";
+
+}
+else
+{
+ import { request } from "@@/utils/request";
+
+}
+@{
+List l=new List();
+if(classInfo.ClassMethodInfos!=null && classInfo.ClassMethodInfos.Length>0 && classInfo.ClassMethodInfos[0].Parameters!=null)
+{
+ for (var j= 0; j< classInfo.ClassMethodInfos.Length; j++)
+ {
+ for (var i = 0; i < classInfo.ClassMethodInfos[j].Parameters.Length; i++)
+ {
+ if(!classInfo.ClassMethodInfos[j].Parameters[i].IsValueType)
+ {
+ if (!l.Contains(classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName.Replace("[]", "")))
+ {
+ l.Add(classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName.Replace("[]", ""));
+ }
+ }
+ }
+ if("dynamic" !=classInfo.ClassMethodInfos[j].MethodReturnName)
+ {
+ if(classInfo.ClassMethodInfos[j].IsValueType) continue;
+ if (l.Contains(classInfo.ClassMethodInfos[j].MethodReturnName.Replace("[]", ""))) continue;
+ l.Add(classInfo.ClassMethodInfos[j].MethodReturnName.Replace("[]", ""));
+ }
+ }
+ }
+ foreach (string s in l)
+ {
+ if(s.StringToProtectedProerty()=="string") continue;
+ if(s.StringToProtectedProerty()=="byte") continue;
+ import type { @s } from "@@/data/auto/@s.StringToProtectedProerty()";
+
+
+ }
+
+}
+
+class @{@classInfo.ClassName}{
+@{
+
+if(classInfo.ClassMethodInfos!=null && classInfo.ClassMethodInfos.Length>0 && classInfo.ClassMethodInfos[0].Parameters!=null)
+{
+ for (var j= 0; j< classInfo.ClassMethodInfos.Length; j++)
+ {
+ string methodReturnName=classInfo.ClassMethodInfos[j].MethodReturnName;
+ if(classInfo.ClassMethodInfos[j].IsValueType)
+ {
+ if(classInfo.ClassMethodInfos[j].MethodReturnName=="String")
+ methodReturnName="string";
+ else if(classInfo.ClassMethodInfos[j].MethodReturnName=="Int32" || classInfo.ClassMethodInfos[j].MethodReturnName=="Int64" || classInfo.ClassMethodInfos[j].MethodReturnName=="Int16" || classInfo.ClassMethodInfos[j].MethodReturnName=="Long" || classInfo.ClassMethodInfos[j].MethodReturnName=="decimal" )
+ methodReturnName="number";
+ else if(classInfo.ClassMethodInfos[j].MethodReturnName=="String[]")
+ methodReturnName="string[]";
+ else if(classInfo.ClassMethodInfos[j].MethodReturnName=="Int32[]" || classInfo.ClassMethodInfos[j].MethodReturnName=="Int64[]" || classInfo.ClassMethodInfos[j].MethodReturnName=="Int16[]" || classInfo.ClassMethodInfos[j].MethodReturnName=="Long[]" || classInfo.ClassMethodInfos[j].MethodReturnName=="decimal[]" )
+ methodReturnName="number[]";
+ else methodReturnName="any";
+ }
+
+ if(classInfo.ClassMethodInfos[j].Parameters.Length==0)
+ {
+
+ async @{@classInfo.ClassMethodInfos[j].MethodName}() {
+ return request<@methodReturnName.Replace("dynamic", "any")>(
+ {
+ url: "/@{@classInfo.ClassName.Replace("Service", "")}/@{@classInfo.ClassMethodInfos[j].MethodName}",
+ method: "@{if(classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]"){post}else{get} }",
+ }
+ )
+ };
+
+ }
+
+
+ for (var i = 0; i < classInfo.ClassMethodInfos[j].Parameters.Length; i++)
+ {
+ string parameterTypeName=classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName;
+ string url="\"";
+ if(classInfo.ClassMethodInfos[j].Parameters[i].IsValueType)
+ {
+ url="?"+classInfo.ClassMethodInfos[j].Parameters[i].ParameterName+"=\"+data";
+ if(classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="String")
+ parameterTypeName="string";
+ else if(classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="Int32" || classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="Int64" || classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="Int16" || classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="Long" || classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="decimal" )
+ parameterTypeName="number";
+ else if(classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="String[]")
+ parameterTypeName="string[]";
+ else if(classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="Int32[]" || classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="Int64[]" || classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="Int16[]" || classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="Long[]" || classInfo.ClassMethodInfos[j].Parameters[i].ParameterTypeName=="decimal[]" )
+ parameterTypeName="number[]";
+ else parameterTypeName="any";
+ }
+ if(classInfo.ClassMethodInfos[j].Parameters.Length>1) {url="\"";parameterTypeName="any";}
+ if(i>0) {continue;}
+
+
+ async @{@classInfo.ClassMethodInfos[j].MethodName}(data: @parameterTypeName) {
+ @{
+ bool isPrintBy=false;
+ bool isDownloadFile=false;
+ if(classInfo.ClassMethodInfos[j].MethodName.StartsWith("PrintBy"))
+ {
+ isPrintBy=true;
+ }
+ if(classInfo.ClassMethodInfos[j].MethodName.StartsWith("DownloadFile"))
+ {
+ isDownloadFile=true;
+ }
+
+ }
+ return @{if(isPrintBy){download}else{ request<@{@methodReturnName.Replace("dynamic", "any")}>}}(
+ {
+ url: "/@{@classInfo.ClassName.Replace("Service", "")}/@{@classInfo.ClassMethodInfos[j].MethodName}@url,
+ method: "@{if(classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]"){post}else{get} }",
+ data,
+ @{if(isDownloadFile){ responseType: "arraybuffer",
+ }else{ }
+ }
+ @{if(isPrintBy){ filename:'@classInfo.ClassName.Replace("Service","")'
+ }else{ }
+ }
+ }
+ )
+ };
+
+ }
+ }
+ }
+}
+
+}
+
+const @{@classInfo.ClassName.StringToProtectedProerty()}= new @{@classInfo.ClassName}();
+export default @{@classInfo.ClassName.StringToProtectedProerty()};
\ No newline at end of file