ow
This commit is contained in:
parent
d09c6b65b1
commit
61714e0a91
263
Templates/Controller.cshtml
Normal file
263
Templates/Controller.cshtml
Normal file
@ -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;
|
||||
<text>using @classInfo.Usings[i];
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
<text> @classInfo.ClassMethodInfos[j].AuthorizeName
|
||||
</text>
|
||||
}
|
||||
if(classInfo.ClassMethodInfos[j].PermissionOperate!=null)
|
||||
{
|
||||
@{<text> @string.Format(classInfo.ClassMethodInfos[j].PermissionOperate,"\""+@classInfo.ClassMethodInfos[j].PermissionOperateAttribute.Name+"\"", "\""+@classInfo.ClassMethodInfos[j].PermissionOperateAttribute.Operate.ToString()+"\"")
|
||||
</text>}
|
||||
}
|
||||
if(classInfo.ClassMethodInfos[j].HttpName!=null)
|
||||
{
|
||||
<text> @classInfo.ClassMethodInfos[j].HttpName
|
||||
</text>
|
||||
}
|
||||
if(classInfo.ClassMethodInfos[j].UnitOfWorkName!=null)
|
||||
{
|
||||
<text> @classInfo.ClassMethodInfos[j].UnitOfWorkName
|
||||
</text>
|
||||
}
|
||||
if(@classInfo.ClassMethodInfos[j].MethodReturnName=="Void")
|
||||
{
|
||||
//文本开始=================================================================================================================
|
||||
<text> public dynamic @{@classInfo.ClassMethodInfos[j].MethodName}()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@{<text> </text>@classInfo.ClassName.StringToProtectedProerty()}.@{@classInfo.ClassMethodInfos[j].MethodName}();
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
</text>
|
||||
//文本结束=================================================================================================================
|
||||
}
|
||||
else
|
||||
{
|
||||
//文本开始=================================================================================================================
|
||||
<text> 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);
|
||||
}
|
||||
}
|
||||
|
||||
</text>
|
||||
//文本结束=================================================================================================================
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//只有1个参数的情况============================================
|
||||
if(classInfo.ClassMethodInfos[j].Parameters.Length>0)
|
||||
{
|
||||
//超过1个参数的情况,如果是get,不能用组合对象,如果是post,要重新组合一个类========================================
|
||||
if(classInfo.ClassMethodInfos[j].Parameters.Length>1 && classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]")
|
||||
{
|
||||
<text>
|
||||
public class @{@classInfo.ClassMethodInfos[j].MethodName}CompositionData
|
||||
{
|
||||
</text>
|
||||
|
||||
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";
|
||||
}
|
||||
<text> public @parameterTypeName @classInfo.ClassMethodInfos[j].Parameters[ik].ParameterName { get; set; }
|
||||
</text>
|
||||
|
||||
}
|
||||
|
||||
<text>
|
||||
}
|
||||
</text>
|
||||
}
|
||||
|
||||
if(classInfo.ClassMethodInfos[j].AuthorizeName!=null)
|
||||
{
|
||||
<text> @classInfo.ClassMethodInfos[j].AuthorizeName
|
||||
</text>
|
||||
}
|
||||
if(classInfo.ClassMethodInfos[j].PermissionOperate!=null)
|
||||
{
|
||||
@{<text> @string.Format(classInfo.ClassMethodInfos[j].PermissionOperate,"\""+@classInfo.ClassMethodInfos[j].PermissionOperateAttribute.Name+"\"","\""+@classInfo.ClassMethodInfos[j].PermissionOperateAttribute.Operate.ToString()+"\"")
|
||||
</text>}
|
||||
}
|
||||
if(classInfo.ClassMethodInfos[j].HttpName!=null)
|
||||
{
|
||||
<text> @classInfo.ClassMethodInfos[j].HttpName
|
||||
</text>
|
||||
}
|
||||
if(classInfo.ClassMethodInfos[j].UnitOfWorkName!=null)
|
||||
{
|
||||
<text> @classInfo.ClassMethodInfos[j].UnitOfWorkName
|
||||
</text>
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
//文本开始================================================
|
||||
<text> public dynamic @{@classInfo.ClassMethodInfos[j].MethodName}(@{@parametersName})</text><text>{
|
||||
try
|
||||
{
|
||||
@{<text> </text>@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){<text>,</text>}<text>compositionData.@classInfo.ClassMethodInfos[j].Parameters[i].ParameterName</text>
|
||||
}
|
||||
else{
|
||||
<text>@classInfo.ClassMethodInfos[j].Parameters[i].ParameterName</text>
|
||||
}
|
||||
}});
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
</text>
|
||||
//文本结束===================================================
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
//文本开始================================================
|
||||
<text> public dynamic @{@classInfo.ClassMethodInfos[j].MethodName}(@{@parametersName})</text><text>
|
||||
{
|
||||
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){<text>,</text>}if(classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]"){<text>compositionData.</text>}<text>@classInfo.ClassMethodInfos[j].Parameters[i].ParameterName</text>
|
||||
}
|
||||
else{
|
||||
<text>@classInfo.ClassMethodInfos[j].Parameters[i].ParameterName</text>
|
||||
}
|
||||
}});
|
||||
return result;
|
||||
}
|
||||
catch (ValidatedException vex)
|
||||
{
|
||||
return vex;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ServiceErrorException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
</text>
|
||||
//文本结束===================================================
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//下面}为代码段结束=================================================================================================================
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
82
Templates/IData.cshtml
Normal file
82
Templates/IData.cshtml
Normal file
@ -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@{<text>.Data</text>}
|
||||
|
||||
{
|
||||
[TypeScript]
|
||||
public class @sysTableSchemas[0].TableName.StringToProerty()DisplayData
|
||||
@if (@sysTableSchemas[0].Xtype.ToUpper().Trim() == "U")
|
||||
{<text></text>}
|
||||
{
|
||||
|
||||
public @sysTableSchemas[0].TableName.StringToProerty()DisplayData()
|
||||
{
|
||||
}
|
||||
|
||||
@for (var i = 0; i < sysTableSchemas.Length; i++)
|
||||
{
|
||||
if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
|
||||
|
||||
<text> public @sysTableSchemas[i].TypeOfName@{if(@sysTableSchemas[i].IsNullAble=="y"){<text>?</text>}} @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
|
||||
</text>
|
||||
}
|
||||
|
||||
|
||||
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")
|
||||
{
|
||||
<text> this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
|
||||
</text>
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
{
|
||||
<text> this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
|
||||
</text>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public @sysTableSchemas[0].TableName.StringToProerty()DisplayData Clone()
|
||||
{
|
||||
@sysTableSchemas[0].TableName.StringToProerty()DisplayData result = new @sysTableSchemas[0].TableName.StringToProerty()DisplayData ();
|
||||
result.CopyFrom(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
31
Templates/IDisplayData.cshtml
Normal file
31
Templates/IDisplayData.cshtml
Normal file
@ -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@{<text>.Data</text>}
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// 排除实体类标记
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
[TypeScript]
|
||||
public class @sysTableSchemas[0].TableName.StringToProerty()DisplayData:@sysTableSchemas[0].TableName.StringToProerty()Entity
|
||||
@if (@sysTableSchemas[0].Xtype.ToUpper().Trim() == "U")
|
||||
{<text></text>}
|
||||
{
|
||||
|
||||
public @sysTableSchemas[0].TableName.StringToProerty()DisplayData()
|
||||
{
|
||||
}
|
||||
public @sysTableSchemas[0].TableName.StringToProerty()DisplayData(@sysTableSchemas[0].TableName.StringToProerty()Entity entity)
|
||||
{
|
||||
CopyFrom(entity);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
81
Templates/IDto.cshtml
Normal file
81
Templates/IDto.cshtml
Normal file
@ -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@{<text>.Data</text>}
|
||||
|
||||
{
|
||||
public class @sysTableSchemas[0].TableName.StringToProerty()DisplayData
|
||||
@if (@sysTableSchemas[0].Xtype.ToUpper().Trim() == "U")
|
||||
{<text></text>}
|
||||
{
|
||||
|
||||
public @sysTableSchemas[0].TableName.StringToProerty()DisplayData()
|
||||
{
|
||||
}
|
||||
|
||||
@for (var i = 0; i < sysTableSchemas.Length; i++)
|
||||
{
|
||||
if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
|
||||
|
||||
<text> public @sysTableSchemas[i].TypeOfName@{if(@sysTableSchemas[i].IsNullAble=="y"){<text>?</text>}} @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
|
||||
</text>
|
||||
}
|
||||
|
||||
|
||||
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")
|
||||
{
|
||||
<text> this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
|
||||
</text>
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
{
|
||||
<text> this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
|
||||
</text>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public @sysTableSchemas[0].TableName.StringToProerty()DisplayData Clone()
|
||||
{
|
||||
@sysTableSchemas[0].TableName.StringToProerty()DisplayData result = new @sysTableSchemas[0].TableName.StringToProerty()DisplayData ();
|
||||
result.CopyFrom(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
186
Templates/IEntity.cshtml
Normal file
186
Templates/IEntity.cshtml
Normal file
@ -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@{<text>.Entity</text>}
|
||||
|
||||
{
|
||||
[TypeScript]
|
||||
[Table("@sysTableSchemas[0].TableName")]
|
||||
public class @sysTableSchemas[0].TableName.StringToProerty()Entity : @entityBase
|
||||
@if (@sysTableSchemas[0].Xtype.ToUpper().Trim() == "U")
|
||||
{<text></text>}
|
||||
{
|
||||
|
||||
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")
|
||||
{
|
||||
<text> [Column("row_version")]
|
||||
[Timestamp]
|
||||
public byte[]? RowVersion { get; set; }
|
||||
</text>
|
||||
continue;
|
||||
}
|
||||
|
||||
if (@sysTableSchemas[i].Pk > 0 && @modelData.KeyCount < 2)
|
||||
{
|
||||
<text> [Key]
|
||||
</text>
|
||||
}
|
||||
if (@sysTableSchemas[i].IsIdentity > 0)
|
||||
{
|
||||
<text> [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
</text>
|
||||
}
|
||||
if (@sysTableSchemas[i].TypeName == "decimal")
|
||||
{
|
||||
<text> [Column("@sysTableSchemas[i].FieldName",TypeName = "@sysTableSchemas[i].TypeName</text><text>(@sysTableSchemas[i].MaxLength,@sysTableSchemas[i].Scale)")]
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text> [Column("@sysTableSchemas[i].FieldName")]
|
||||
</text>
|
||||
}
|
||||
if (@sysTableSchemas[i].TypeOfName == "string")
|
||||
{
|
||||
<text> public @sysTableSchemas[i].TypeOfName@{if(@sysTableSchemas[i].IsNullAble=="y"){<text>?</text>}} @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text> public @sysTableSchemas[i].TypeOfName @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
|
||||
</text>
|
||||
}
|
||||
}
|
||||
|
||||
@for (var i = 0; i < sysTableSchemas.Length; i++)
|
||||
{
|
||||
<text> public const string @sysTableSchemas[i].FieldName.ToUpper() = "@sysTableSchemas[i].FieldName.StringToProerty()";
|
||||
</text>
|
||||
}
|
||||
|
||||
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++)
|
||||
{
|
||||
<text> public const string DB_@sysTableSchemas[i].FieldName.ToUpper() = "@sysTableSchemas[i].FieldName";
|
||||
</text>
|
||||
}
|
||||
|
||||
|
||||
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")
|
||||
{
|
||||
<text> this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
|
||||
</text>
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
{
|
||||
<text> this.@sysTableSchemas[i].FieldName.StringToProerty() = source.@sysTableSchemas[i].FieldName.StringToProerty();
|
||||
</text>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
<text> if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_@sysTableSchemas[i].FieldName.ToUpper() ; </text>
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@if(sysTableSchemas.Sum(x=>x.Pk)==0)
|
||||
{
|
||||
<text> if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_@sysTableSchemas[0].FieldName.ToUpper() ; </text>
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
72
Templates/IEntityKey.cshtml
Normal file
72
Templates/IEntityKey.cshtml
Normal file
@ -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)
|
||||
{
|
||||
<text> public @sysTableSchemas[i].TypeOfName @sysTableSchemas[i].FieldName.StringToProerty() { get; set; }
|
||||
</text>
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
<text> if (@sysTableSchemas[i].FieldName.StringToProerty() != pkey.@sysTableSchemas[i].FieldName.StringToProerty()) return false;
|
||||
</text>
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string declareSql="";
|
||||
@{int j = 0;}
|
||||
@for (var i = 0; i < sysTableSchemas.Length; i++)
|
||||
{
|
||||
if (@sysTableSchemas[i].Pk > 0)
|
||||
{
|
||||
<text> declareSql=declareSql+$"declare @@__tkey_@sysTableSchemas[i].FieldName.StringToProerty()_@j.ToString() varchar(50) select @@__tkey_@sysTableSchemas[i].FieldName.StringToProerty()_@j.ToString() ='{@sysTableSchemas[i].FieldName.StringToProerty()}'; " ;</text>
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
return declareSql;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* @if (modelData.KeyCount > 0)
|
||||
{<text>builder.Entity<@sysTableSchemas[0].TableName.StringToProerty()Entity>().HasKey(c => new {</text>int k = 0;
|
||||
for (var i = 0; i < sysTableSchemas.Length; i++)
|
||||
{
|
||||
if (@sysTableSchemas[i].Pk > 0)
|
||||
{
|
||||
k++;
|
||||
<text> c.@sysTableSchemas[i].FieldName.StringToProerty()</text>if (modelData.KeyCount != k)
|
||||
{<text>,</text>}
|
||||
|
||||
}
|
||||
}
|
||||
<text>});</text>
|
||||
}
|
||||
*/
|
||||
17
Templates/IService.cshtml
Normal file
17
Templates/IService.cshtml
Normal file
@ -0,0 +1,17 @@
|
||||
@{
|
||||
ModelData modelData = Model;
|
||||
SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
|
||||
NamespaceObject namespaceObject = modelData.NamespaceObject;
|
||||
}
|
||||
|
||||
using @namespaceObject.Assembly.ToString()@{<text>.Entity</text>};
|
||||
using @namespaceObject.Assembly.ToString()@{<text>.SearchCriteria</text>};
|
||||
using CloudBuilder.Core.Service;
|
||||
|
||||
namespace @namespaceObject.Assembly.ToString()@{<text>.Service</text>}
|
||||
|
||||
{
|
||||
public interface @{<text>I</text>}@sysTableSchemas[0].TableName.StringToProerty()Service :IServiceBase<@sysTableSchemas[0].TableName.StringToProerty()Entity, @modelData.KeyType ,@sysTableSchemas[0].TableName.StringToProerty()SearchCriteria>
|
||||
{
|
||||
}
|
||||
}
|
||||
15
Templates/Permission.auto.cshtml
Normal file
15
Templates/Permission.auto.cshtml
Normal file
@ -0,0 +1,15 @@
|
||||
@{
|
||||
ModelData modelData = Model;
|
||||
SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
|
||||
NamespaceObject namespaceObject = modelData.NamespaceObject;
|
||||
}
|
||||
namespace @namespaceObject.Namespace@{<text>.Policy</text>}
|
||||
|
||||
{
|
||||
public partial class @namespaceObject.Assembly.Replace("CloudBuilder.", "").Replace(".", "")PermissionPolicy
|
||||
{
|
||||
//***BEGIN***
|
||||
public const string @sysTableSchemas[0].TableName.StringToProerty() = "@sysTableSchemas[0].TableName.StringToProerty()";
|
||||
//***END***
|
||||
}
|
||||
}
|
||||
7
Templates/Permission.cshtml
Normal file
7
Templates/Permission.cshtml
Normal file
@ -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()";
|
||||
|
||||
26
Templates/RegistEntity.Key.cshtml
Normal file
26
Templates/RegistEntity.Key.cshtml
Normal file
@ -0,0 +1,26 @@
|
||||
@{
|
||||
ModelData modelData = Model;
|
||||
SysTableSchemaViewEntity[] sysTableSchemas = modelData.sysTableSchemas;
|
||||
NamespaceObject namespaceObject = modelData.NamespaceObject;
|
||||
}
|
||||
@if (modelData.KeyCount > 1)
|
||||
{
|
||||
<text>builder.Entity<@sysTableSchemas[0].TableName.StringToProerty()Entity>().HasKey(c => new {</text>int k = 0;
|
||||
for (var i = 0; i < sysTableSchemas.Length; i++)
|
||||
{
|
||||
if (@sysTableSchemas[i].Pk > 0)
|
||||
{
|
||||
k++;
|
||||
<text>c.@sysTableSchemas[i].FieldName.StringToProerty()</text>if (modelData.KeyCount != k)
|
||||
{<text>,</text>}
|
||||
|
||||
}
|
||||
}
|
||||
<text>});
|
||||
</text>
|
||||
}
|
||||
else @if (modelData.KeyCount == 0)
|
||||
{
|
||||
<text>builder.Entity<@sysTableSchemas[0].TableName.StringToProerty()Entity>(eb => { eb.HasNoKey(); });
|
||||
</text>
|
||||
}
|
||||
47
Templates/RegistEntity.cshtml
Normal file
47
Templates/RegistEntity.cshtml
Normal file
@ -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@{<text>.Entity</text>}
|
||||
|
||||
{
|
||||
public class @namespaceObject.Namespace.Replace(".","")RegistEntity : IMasterRegistEntityType<ModelBuilder>
|
||||
{
|
||||
///<summary>
|
||||
///注入模块内的所有实体类
|
||||
///</summary>
|
||||
///<param name="builder"></param>
|
||||
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);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///如果存在多个主键的,要在RegistKeys方法注入
|
||||
///builder.Entity<xxxxxxEntity>().HasKey(c => new { c.TableName, c.FieldName });
|
||||
///builder.Entity<xxxxxxEntity>(eb => { eb.HasNoKey(); });
|
||||
///</summary>
|
||||
///<param name="builder"></param>
|
||||
public void RegistKeys(ModelBuilder builder)
|
||||
{
|
||||
//***BEGIN***
|
||||
|
||||
//***END***
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
169
Templates/Request.cshtml
Normal file
169
Templates/Request.cshtml
Normal file
@ -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;
|
||||
<text>using @classInfo.Usings[i];
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
//文本开始=================================================================================================================
|
||||
<text> public @{ @methodReturnName @classInfo.ClassMethodInfos[j].MethodName }()
|
||||
{
|
||||
@{
|
||||
//[HttpGet]一定要有返回值,否则使用[HttpPost]
|
||||
if(classInfo.ClassMethodInfos[j].HttpName=="[HttpGet]"){
|
||||
<text>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();</text>
|
||||
}
|
||||
else{
|
||||
//[HttpPost]可以有无返回值
|
||||
if(classInfo.ClassMethodInfos[j].MethodReturnName!="Void"){<text>return </text>}<text> Task.Run(() => serviceRequest.@{if(classInfo.ClassMethodInfos[j].MethodReturnName!="Void"){<text>PostAsJsonAsync<@{@classInfo.ClassMethodInfos[j].MethodReturnName.Replace("String", "string").Replace("Boolean", "bool")}> </text>}else{<text>PostAsync</text>}}("/@{@classInfo.ClassName.Replace("Service", "")}/@{@classInfo.ClassMethodInfos[j].MethodName}")).GetAwaiter().GetResult();</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</text>
|
||||
//文本结束=================================================================================================================
|
||||
}
|
||||
|
||||
|
||||
//只有1个参数的情况============================================
|
||||
if(classInfo.ClassMethodInfos[j].Parameters.Length>0)
|
||||
{
|
||||
//超过1个参数的情况,如果是get,不能用组合对象,如果是post,要重新组合一个类========================================
|
||||
if(classInfo.ClassMethodInfos[j].Parameters.Length>1 && classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]")
|
||||
{
|
||||
<text>
|
||||
public class @{@classInfo.ClassMethodInfos[j].MethodName}CompositionData@{@classInfo.ClassMethodInfos[j].Parameters.Length}
|
||||
{
|
||||
</text>
|
||||
|
||||
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";
|
||||
}
|
||||
<text> public @parameterTypeName @classInfo.ClassMethodInfos[j].Parameters[ik].ParameterName { get; set; }
|
||||
</text>
|
||||
|
||||
}
|
||||
|
||||
<text>
|
||||
}
|
||||
</text>
|
||||
}
|
||||
|
||||
|
||||
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<string, string>();\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;
|
||||
}
|
||||
//文本开始================================================
|
||||
<text> public @{@methodReturnName @classInfo.ClassMethodInfos[j].MethodName}(@{@parametersName})</text><text>
|
||||
{
|
||||
@{@content.ToString()}
|
||||
}
|
||||
|
||||
</text>
|
||||
//文本结束===================================================
|
||||
}
|
||||
}
|
||||
}
|
||||
//下面}为代码段结束=================================================================================================================
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
16
Templates/SearchCriteria.cshtml
Normal file
16
Templates/SearchCriteria.cshtml
Normal file
@ -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@{<text>.SearchCriteria</text>}
|
||||
|
||||
{
|
||||
[TypeScript]
|
||||
public class @sysTableSchemas[0].TableName.StringToProerty()SearchCriteria: AbstractSearchCriteria
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
141
Templates/Service.cshtml
Normal file
141
Templates/Service.cshtml
Normal file
@ -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;
|
||||
@{
|
||||
<text>using </text>@namespaceObject.Assembly.ToString()<text>.Entity;</text>
|
||||
<text>using </text>@namespaceObject.Assembly.ToString()<text>.Policy;</text>
|
||||
<text>using </text>@namespaceObject.Assembly.ToString()<text>.SearchCriteria;</text>
|
||||
}
|
||||
|
||||
namespace @namespaceObject.Assembly.ToString()@{<text>.Service</text>}
|
||||
|
||||
{
|
||||
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<IRepository<@{@sysTableSchemas[0].TableName.StringToProerty()}Entity>>();
|
||||
}
|
||||
@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)
|
||||
{
|
||||
<text>
|
||||
[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()!;
|
||||
}
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (@modelData.KeyCount > 1)
|
||||
{
|
||||
<text>
|
||||
[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</text>
|
||||
@for (var i = 0; i < sysTableSchemas.Length; i++)
|
||||
{
|
||||
if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
|
||||
|
||||
if (@sysTableSchemas[i].Pk > 0)
|
||||
{
|
||||
<text>
|
||||
&& x.@{ @sysTableSchemas[i].FieldName.StringToProerty()} == key.@{ @sysTableSchemas[i].FieldName.StringToProerty()}
|
||||
</text>
|
||||
}
|
||||
}
|
||||
<text>
|
||||
).FirstOrDefault()!;
|
||||
}
|
||||
</text>
|
||||
}
|
||||
|
||||
//[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)
|
||||
{
|
||||
<text>
|
||||
[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); }
|
||||
}
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (@modelData.KeyCount > 1)
|
||||
{
|
||||
<text>
|
||||
[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</text>
|
||||
@for (var i = 0; i < sysTableSchemas.Length; i++)
|
||||
{
|
||||
if (@sysTableSchemas[i].FieldName.ToUpper() == "ID") { continue; }
|
||||
|
||||
if (@sysTableSchemas[i].Pk > 0)
|
||||
{
|
||||
<text>
|
||||
&& x.@{ @sysTableSchemas[i].FieldName.StringToProerty()} == key.@{ @sysTableSchemas[i].FieldName.StringToProerty()}
|
||||
</text>
|
||||
}
|
||||
}
|
||||
<text>
|
||||
).FirstOrDefault()!;
|
||||
if (ent != null) { repository.DeleteNow(ent); }
|
||||
}
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
115
Templates/TypeScript.cshtml
Normal file
115
Templates/TypeScript.cshtml
Normal file
@ -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++)
|
||||
{
|
||||
<text>import { @classInfo.Usings[i].StringToProerty() } from "./@classInfo.Usings[i].StringToProtectedProerty()";
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
@{
|
||||
string implementTypeName=string.IsNullOrEmpty(classInfo.ImplementTypeName)?"":" extends "+classInfo.ImplementTypeName;
|
||||
if(!string.IsNullOrEmpty(implementTypeName))
|
||||
{
|
||||
<text>import { @classInfo.ImplementTypeName.StringToProerty() } from "./@classInfo.ImplementTypeName.StringToProtectedProerty()";
|
||||
</text>
|
||||
}
|
||||
}
|
||||
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")
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName?: Date= null!;
|
||||
</text>
|
||||
}
|
||||
else if(classInfo.ClassProperties[j].PropertyTypeName.ToLower()=="datetime")
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: Date = new Date();
|
||||
</text>
|
||||
}
|
||||
else if(classInfo.ClassProperties[j].PropertyTypeName=="Boolean")
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: boolean =false;
|
||||
</text>
|
||||
}
|
||||
else if(classInfo.ClassProperties[j].PropertyTypeName=="String")
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: string = "";
|
||||
</text>
|
||||
}
|
||||
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")
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: number = 0;
|
||||
</text>
|
||||
}
|
||||
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[]")
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: number[] = [];
|
||||
</text>
|
||||
}
|
||||
else if(classInfo.ClassProperties[j].PropertyTypeName.Contains("String[]"))
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: string[]= [];
|
||||
</text>
|
||||
}
|
||||
else if(!classInfo.ClassProperties[j].IsValueType && classInfo.ClassProperties[j].PropertyTypeName.Contains("[]"))
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: @classInfo.ClassProperties[j].PropertyTypeName.StringToProerty() = [];
|
||||
</text>
|
||||
}
|
||||
else if(classInfo.ClassProperties[j].PropertyTypeName=="any")
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: any;
|
||||
</text>
|
||||
}
|
||||
else if(!classInfo.ClassProperties[j].IsValueType)
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: @classInfo.ClassProperties[j].PropertyTypeName.StringToProerty() = new @{@classInfo.ClassProperties[j].PropertyTypeName.StringToProerty() }();
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text> public @classInfo.ClassProperties[j].PropertyName: any ={}
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@{
|
||||
if(classInfo.ClassFields!=null && classInfo.ClassFields.Length>0)
|
||||
{
|
||||
for (var j= 0; j< classInfo.ClassFields.Length; j++)
|
||||
{
|
||||
if(classInfo.ClassFields[j].FieldTypeName =="String")
|
||||
{
|
||||
<text> static readonly @classInfo.ClassFields[j].FieldName : string ='@classInfo.ClassFields[j].FieldValue';
|
||||
</text>
|
||||
}
|
||||
if(classInfo.ClassFields[j].FieldTypeName =="Boolean")
|
||||
{
|
||||
<text> static readonly @classInfo.ClassFields[j].FieldName : Boolean ='@classInfo.ClassFields[j].FieldValue';
|
||||
</text>
|
||||
}
|
||||
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")
|
||||
{
|
||||
<text> static readonly @classInfo.ClassFields[j].FieldName: number =@classInfo.ClassFields[j].FieldValue;
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
147
Templates/TypeScriptService.cshtml
Normal file
147
Templates/TypeScriptService.cshtml
Normal file
@ -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)
|
||||
{
|
||||
<text>import { request,download } from "@@/utils/request";
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>import { request } from "@@/utils/request";
|
||||
</text>
|
||||
}
|
||||
@{
|
||||
List<string> l=new List<string>();
|
||||
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;
|
||||
<text>import type { @s } from "@@/data/auto/@s.StringToProtectedProerty()";
|
||||
</text>
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
<text>
|
||||
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]"){<text>post</text>}else{<text>get</text>} }",
|
||||
}
|
||||
)
|
||||
};
|
||||
</text>
|
||||
}
|
||||
|
||||
|
||||
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;}
|
||||
|
||||
<text>
|
||||
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){<text>download</text>}else{ <text>request<@{@methodReturnName.Replace("dynamic", "any")}></text>}}(
|
||||
{
|
||||
url: "/@{@classInfo.ClassName.Replace("Service", "")}/@{@classInfo.ClassMethodInfos[j].MethodName}@url,
|
||||
method: "@{if(classInfo.ClassMethodInfos[j].HttpName!="[HttpGet]"){<text>post</text>}else{<text>get</text>} }",
|
||||
data,
|
||||
@{if(isDownloadFile){<text> responseType: "arraybuffer",
|
||||
</text>}else{ <text></text>}
|
||||
}
|
||||
@{if(isPrintBy){<text> filename:'@classInfo.ClassName.Replace("Service","")'
|
||||
</text>}else{ <text></text>}
|
||||
}
|
||||
}
|
||||
)
|
||||
};
|
||||
</text>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const @{@classInfo.ClassName.StringToProtectedProerty()}= new @{@classInfo.ClassName}();
|
||||
export default @{@classInfo.ClassName.StringToProtectedProerty()};
|
||||
Loading…
Reference in New Issue
Block a user