mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-17 01:46:30 +08:00
调整代码生成器生成变量命名方式
This commit is contained in:
parent
329c2c9f07
commit
5eec669cde
@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Humanizer;
|
||||
using Infrastructure;
|
||||
using Infrastructure.Utilities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@ -58,11 +59,11 @@ namespace OpenAuth.App
|
||||
{
|
||||
object[] objs = property.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
||||
object[] browsableObjs = property.GetCustomAttributes(typeof(BrowsableAttribute), true);
|
||||
var description = objs.Length > 0 ? ((DescriptionAttribute) objs[0]).Description : property.Name;
|
||||
var description = objs.Length > 0 ? ((DescriptionAttribute)objs[0]).Description : property.Name;
|
||||
if (string.IsNullOrEmpty(description)) description = property.Name;
|
||||
//如果没有BrowsableAttribute或 [Browsable(true)]表示可见,其他均为不可见,需要前端配合显示
|
||||
bool browsable = browsableObjs == null || browsableObjs.Length == 0 ||
|
||||
((BrowsableAttribute) browsableObjs[0]).Browsable;
|
||||
((BrowsableAttribute)browsableObjs[0]).Browsable;
|
||||
var typeName = property.PropertyType.Name;
|
||||
if (Nullable.GetUnderlyingType(property.PropertyType) != null)
|
||||
{
|
||||
@ -88,7 +89,7 @@ namespace OpenAuth.App
|
||||
public List<string> GetDbEntityNames()
|
||||
{
|
||||
var names = new List<string>();
|
||||
var models = _contexts.Select(u =>u.Model);
|
||||
var models = _contexts.Select(u => u.Model);
|
||||
|
||||
foreach (var model in models)
|
||||
{
|
||||
@ -135,8 +136,9 @@ namespace OpenAuth.App
|
||||
/// </summary>
|
||||
private IList<SysTableColumn> GetOracleStructure(string tableName)
|
||||
{
|
||||
tableName = tableName.ToUpper();
|
||||
var sql = $@"
|
||||
select utc.column_name as columnname
|
||||
select utc.column_name as columnname
|
||||
, utc.data_type columntype
|
||||
, utc.data_length maxlength
|
||||
, case utc.nullable when 'N' then 0 else 1 end isnull
|
||||
@ -171,16 +173,16 @@ select utc.column_name as columnname
|
||||
('CHAR', 'VARCHAR', 'TINY TEXT', 'TEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TINYBLOB', 'BLOB',
|
||||
'MEDIUMBLOB', 'LONGBLOB', 'Time') then
|
||||
'string'
|
||||
when data_type in ('Date', 'DateTime', 'TIMESTAMP(6)') then
|
||||
when data_type in ('DATE', 'DATETIME', 'TIMESTAMP(6)') then
|
||||
'DateTime'
|
||||
else 'string'
|
||||
end as entitytype
|
||||
from user_tab_columns utc
|
||||
from user_tab_columns utc
|
||||
, user_col_comments ucc
|
||||
where utc.table_name = ucc.table_name
|
||||
where utc.table_name = ucc.table_name
|
||||
and utc.column_name = ucc.column_name
|
||||
and utc.table_name = '{tableName}'
|
||||
order by column_id; ";
|
||||
order by column_id; ";
|
||||
|
||||
foreach (var context in _contexts)
|
||||
{
|
||||
@ -188,6 +190,7 @@ order by column_id; ";
|
||||
var columnList = columns?.ToList();
|
||||
if (columnList != null && columnList.Any())
|
||||
{
|
||||
columnList.ForEach(u => u.ColumnName = u.ColumnName.Transform(To.LowerCase, To.TitleCase));
|
||||
return columnList;
|
||||
}
|
||||
}
|
||||
@ -202,7 +205,7 @@ order by column_id; ";
|
||||
{
|
||||
var sql = $@"SELECT DISTINCT
|
||||
Column_Name AS ColumnName,
|
||||
'{ tableName}' as tableName,
|
||||
'{tableName}' as tableName,
|
||||
Column_Comment AS Comment,
|
||||
data_type as ColumnType,
|
||||
CASE
|
||||
@ -253,6 +256,7 @@ order by column_id; ";
|
||||
var columnList = columns?.ToList();
|
||||
if (columnList != null && columnList.Any())
|
||||
{
|
||||
columnList.ForEach(u => u.ColumnName = u.ColumnName.Transform(To.LowerCase, To.TitleCase));
|
||||
return columnList;
|
||||
}
|
||||
}
|
||||
@ -263,10 +267,11 @@ order by column_id; ";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取Mysql表结构信息
|
||||
/// 获取pgsql表结构信息
|
||||
/// </summary>
|
||||
private IList<SysTableColumn> GetPostgreStructure(string tableName)
|
||||
{
|
||||
tableName = tableName.ToLower();
|
||||
var sql = $@"select attr.attrelid
|
||||
, schema.nspname as schemaname
|
||||
, class.relname as tablename --表名
|
||||
@ -309,7 +314,7 @@ order by column_id; ";
|
||||
or con.conname is null then 0
|
||||
else 1
|
||||
end as isdisplay --是否显示
|
||||
from pg_catalog.pg_class class
|
||||
from pg_catalog.pg_class class
|
||||
inner join pg_catalog.pg_attribute attr on attr.attrelid = class.oid
|
||||
left join pg_catalog.pg_constraint con
|
||||
on con.conrelid = class.oid and attr.attnum = any (con.conkey) and con.contype = 'p'
|
||||
@ -317,7 +322,7 @@ from pg_catalog.pg_class class
|
||||
inner join pg_catalog.pg_description comment
|
||||
on comment.objoid = attr.attrelid and comment.objsubid = attr.attnum
|
||||
inner join pg_catalog.pg_namespace schema on schema.oid = class.relnamespace
|
||||
where attr.attnum > 0
|
||||
where attr.attnum > 0
|
||||
and not attr.attisdropped
|
||||
and schema.nspname = 'public' -- replace 'your_schema' with your schema name
|
||||
and class.relname = '{tableName}'";
|
||||
@ -328,6 +333,7 @@ where attr.attnum > 0
|
||||
var columnList = columns?.ToList();
|
||||
if (columnList != null && columnList.Any())
|
||||
{
|
||||
columnList.ForEach(u => u.ColumnName = u.ColumnName.Transform(To.LowerCase, To.TitleCase));
|
||||
return columnList;
|
||||
}
|
||||
}
|
||||
@ -426,7 +432,7 @@ where attr.attnum > 0
|
||||
LEFT JOIN sys.extended_properties epTwo ON obj.id = epTwo.major_id
|
||||
AND epTwo.minor_id = 0
|
||||
AND epTwo.name = 'MS_Description'
|
||||
WHERE obj.name = '{ tableName}') AS t
|
||||
WHERE obj.name = '{tableName}') AS t
|
||||
ORDER BY t.colorder";
|
||||
|
||||
foreach (var context in _contexts)
|
||||
|
@ -19,6 +19,7 @@
|
||||
<PackageReference Include="Autofac" Version="8.1.1" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
|
||||
<PackageReference Include="Autofac.Extras.Quartz" Version="5.1.0" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="5.0.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user