1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
select t.column_description,concat( 'private ',CASE t.column_type WHEN 'varchar' THEN 'String' WHEN 'nvarchar ' THEN 'String' WHEN 'ntext' THEN 'String' WHEN 'bit' THEN 'boolean' WHEN 'int' THEN 'Integer' WHEN 'tinyint' THEN 'Integer' WHEN 'bigint' THEN 'Long' WHEN 'datetime' THEN 'Date' WHEN 'money' THEN 'BigDecimal' WHEN 'Decimal' THEN 'BigDecimal' WHEN 'numeric' THEN 'BigDecimal' WHEN 'date' THEN 'Date' ELSE t.column_type END ,' ',IIF(CHARINDEX('_', t.column_name) > 0, CONCAT(SUBSTRING(t.column_name, 1, CHARINDEX('_', t.column_name) - 1), UPPER(SUBSTRING(t.column_name, CHARINDEX('_', t.column_name) + 1, 1)), SUBSTRING(t.column_name, CHARINDEX('_', t.column_name) + 2, LEN(t.column_name))), Lower(t.column_name)),';') from ( SELECT A.name AS table_name, B.name AS column_name, C.value AS column_description ,D.name as column_type FROM sys.tables A INNER JOIN sys.columns B ON B.object_id = A.object_id LEFT JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id LEFT JOIN systypes D on B.user_type_id = D.xusertype WHERE A.name = 'TBKSXX') t;
SELECT CONCAT('/**',column_comment,"*/") mark, case when COLUMN_KEY like '%PRI%' then CONCAT('@TableId("',COLUMN_NAME,'")') else CONCAT('@TableField("',COLUMN_NAME,'")') end anno , case when COLUMN_NAME='fid' then CONCAT('@Id @GeneratedValue(generator = "uuid") @GenericGenerator(name = "uuid", strategy = "uuid") private String ',COLUMN_NAME,';') when DATA_TYPE like '%char%' or DATA_TYPE like '%text%' then CONCAT('private String ',COLUMN_NAME,';') when DATA_TYPE like '%int%' then CONCAT('private Integer ',COLUMN_NAME,';') when DATA_TYPE like '%float%' then CONCAT('private Float ',COLUMN_NAME,';') when DATA_TYPE like '%decimal%' then CONCAT('private BigDecimal ',COLUMN_NAME,';') when DATA_TYPE like '%date%' then CONCAT('@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date ',COLUMN_NAME,';') when DATA_TYPE like '%timestamp%' then CONCAT('@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date ',COLUMN_NAME,';') else COLUMN_NAME end filed FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'contact';
|