9 changed files with 172 additions and 1 deletions
@ -0,0 +1,2 @@ |
|||||
|
|
||||
|
FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace BBWYB.Server.Model.Db -DB "MySql,data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=jdhy;charset=utf8;sslmode=none;" -FileName "{name}.cs" |
@ -0,0 +1,47 @@ |
|||||
|
using FreeSql.DatabaseModel; |
||||
|
using System; |
||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Reflection; |
||||
|
using System.Threading.Tasks; |
||||
|
using Newtonsoft.Json; |
||||
|
using FreeSql.DataAnnotations; |
||||
|
|
||||
|
namespace BBWYB.Server.Model.Db.HY |
||||
|
{ |
||||
|
|
||||
|
[Table(Name = "hycats", DisableSyncStructure = true)] |
||||
|
public partial class HyCats |
||||
|
{ |
||||
|
|
||||
|
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
||||
|
public string Id { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 是否最子级
|
||||
|
/// </summary>
|
||||
|
[Column(DbType = "tinyint")] |
||||
|
public sbyte IsLeaf { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 级别
|
||||
|
/// </summary>
|
||||
|
[Column(DbType = "int")] |
||||
|
public int Level { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 名称
|
||||
|
/// </summary>
|
||||
|
[Column(IsNullable = false)] |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 父级ID
|
||||
|
/// </summary>
|
||||
|
[Column(StringLength = 50)] |
||||
|
public string ParentId { get; set; } |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,67 @@ |
|||||
|
using FreeSql.DatabaseModel;@{ |
||||
|
var gen = Model as RazorModel; |
||||
|
|
||||
|
Func<string, string> GetAttributeString = attr => { |
||||
|
if (string.IsNullOrEmpty(attr)) return ""; |
||||
|
return string.Concat(", ", attr.Trim('[', ']')); |
||||
|
}; |
||||
|
Func<string, string> GetDefaultValue = defval => { |
||||
|
if (string.IsNullOrEmpty(defval)) return ""; |
||||
|
return " = " + defval + ";"; |
||||
|
}; |
||||
|
}@{ |
||||
|
switch (gen.fsql.Ado.DataType) { |
||||
|
case FreeSql.DataType.PostgreSQL: |
||||
|
@:using System; |
||||
|
@:using System.Collections; |
||||
|
@:using System.Collections.Generic; |
||||
|
@:using System.Linq; |
||||
|
@:using System.Reflection; |
||||
|
@:using System.Threading.Tasks; |
||||
|
@:using Newtonsoft.Json; |
||||
|
@:using FreeSql.DataAnnotations; |
||||
|
@:using System.Net; |
||||
|
@:using Newtonsoft.Json.Linq; |
||||
|
@:using System.Net.NetworkInformation; |
||||
|
@:using NpgsqlTypes; |
||||
|
@:using Npgsql.LegacyPostgis; |
||||
|
break; |
||||
|
case FreeSql.DataType.SqlServer: |
||||
|
case FreeSql.DataType.MySql: |
||||
|
default: |
||||
|
@:using System; |
||||
|
@:using System.Collections; |
||||
|
@:using System.Collections.Generic; |
||||
|
@:using System.Linq; |
||||
|
@:using System.Reflection; |
||||
|
@:using System.Threading.Tasks; |
||||
|
@:using Newtonsoft.Json; |
||||
|
@:using FreeSql.DataAnnotations; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
namespace @gen.NameSpace { |
||||
|
|
||||
|
@if (string.IsNullOrEmpty(gen.table.Comment) == false) { |
||||
|
@:/// <summary> |
||||
|
@:/// @gen.table.Comment.Replace("\r\n", "\n").Replace("\n", "\r\n /// ") |
||||
|
@:/// </summary> |
||||
|
} |
||||
|
[JsonObject(MemberSerialization.OptIn)@GetAttributeString(gen.GetTableAttribute())] |
||||
|
public partial class @gen.GetCsName(gen.FullTableName) { |
||||
|
|
||||
|
@foreach (var col in gen.columns) { |
||||
|
|
||||
|
if (string.IsNullOrEmpty(col.Comment) == false) { |
||||
|
@:/// <summary> |
||||
|
@:/// @col.Comment.Replace("\r\n", "\n").Replace("\n", "\r\n /// ") |
||||
|
@:/// </summary> |
||||
|
} |
||||
|
@:@("[JsonProperty" + GetAttributeString(gen.GetColumnAttribute(col, true)) + "]") |
||||
|
@:public @gen.GetCsType(col) @gen.GetCsName(col.Name) { get; set; }@GetDefaultValue(gen.GetColumnDefaultValue(col, false)) |
||||
|
@: |
||||
|
} |
||||
|
} |
||||
|
@gen.GetMySqlEnumSetDefine() |
||||
|
} |
@ -0,0 +1,2 @@ |
|||||
|
|
||||
|
FreeSql.Generator -Razor "__razor.cshtml.txt" -NameOptions 1,0,0,0 -NameSpace BBWYB.Server.Model.Db -DB "MySql,data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=jdhy;charset=utf8;sslmode=none;" -FileName "{name}.cs" |
Loading…
Reference in new issue