Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl-generator
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
余保谷
ydl-generator
Commits
f4cf6996
Commit
f4cf6996
authored
Apr 09, 2019
by
flying-cattle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善驼峰命名,注释,去掉过时的方法2
parent
af9bd87a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
131 additions
and
125 deletions
+131
-125
DbColumnType.java
src/main/java/com/github/mybatis/fl/convert/DbColumnType.java
+89
-90
ITypeConvert.java
src/main/java/com/github/mybatis/fl/convert/ITypeConvert.java
+32
-32
MySqlToJavaUtil.java
src/main/java/com/github/mybatis/fl/util/MySqlToJavaUtil.java
+10
-3
No files found.
src/main/java/com/github/mybatis/fl/convert/DbColumnType.java
View file @
f4cf6996
/**
* Copyright © 2019 dream horse Info. Tech Ltd. All rights reserved.
*
* @Package: com.github.mybatis.fl.convert
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package
com
.
github
.
mybatis
.
fl
.
convert
;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明:表字段类型</p>
* @version: v2.1.0
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* 2019年4月9日 flying-cattle v2.1.0 initialize
*/
public
enum
DbColumnType
implements
IColumnType
{
// 基本类型
BASE_BYTE
(
"byte"
,
null
),
BASE_SHORT
(
"short"
,
null
),
BASE_CHAR
(
"char"
,
null
),
BASE_INT
(
"int"
,
null
),
BASE_LONG
(
"long"
,
null
),
BASE_FLOAT
(
"float"
,
null
),
BASE_DOUBLE
(
"double"
,
null
),
BASE_BOOLEAN
(
"boolean"
,
null
),
// 包装类型
BYTE
(
"Byte"
,
null
),
SHORT
(
"Short"
,
null
),
CHARACTER
(
"Character"
,
null
),
INTEGER
(
"Integer"
,
null
),
LONG
(
"Long"
,
null
),
FLOAT
(
"Float"
,
null
),
DOUBLE
(
"Double"
,
null
),
BOOLEAN
(
"Boolean"
,
null
),
STRING
(
"String"
,
null
),
// sql 包下数据类型
DATE_SQL
(
"Date"
,
"java.sql.Date"
),
TIME
(
"Time"
,
"java.sql.Time"
),
TIMESTAMP
(
"Timestamp"
,
"java.sql.Timestamp"
),
BLOB
(
"Blob"
,
"java.sql.Blob"
),
CLOB
(
"Clob"
,
"java.sql.Clob"
),
// java8 新时间类型
LOCAL_DATE
(
"LocalDate"
,
"java.time.LocalDate"
),
LOCAL_TIME
(
"LocalTime"
,
"java.time.LocalTime"
),
YEAR
(
"Year"
,
"java.time.Year"
),
YEAR_MONTH
(
"YearMonth"
,
"java.time.YearMonth"
),
LOCAL_DATE_TIME
(
"LocalDateTime"
,
"java.time.LocalDateTime"
),
// 其他杂类
BYTE_ARRAY
(
"byte[]"
,
null
),
OBJECT
(
"Object"
,
null
),
DATE
(
"Date"
,
"java.util.Date"
),
BIG_INTEGER
(
"BigInteger"
,
"java.math.BigInteger"
),
BIG_DECIMAL
(
"BigDecimal"
,
"java.math.BigDecimal"
);
/**
* <p>类型</p>
*/
private
final
String
type
;
/**
* <p>包路径</p>
*/
private
final
String
pkg
;
DbColumnType
(
final
String
type
,
final
String
pkg
)
{
this
.
type
=
type
;
this
.
pkg
=
pkg
;
}
@Override
public
String
getType
()
{
return
type
;
}
@Override
public
String
getPkg
()
{
return
pkg
;
}
}
/**
* Copyright © 2019 dream horse Info. Tech Ltd. All rights reserved.
*
* @Package: com.github.mybatis.fl.convert
* @author: flying-cattle
* @date: 2019年4月9日 下午8:15:25
*/
package
com
.
github
.
mybatis
.
fl
.
convert
;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明:表字段类型</p>
* @version: v2.1.0
* @author: flying-cattle
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* 2019年4月9日 flying-cattle v2.1.0 initialize
*/
public
enum
DbColumnType
implements
IColumnType
{
// 基本类型
BASE_BYTE
(
"byte"
,
null
),
BASE_SHORT
(
"short"
,
null
),
BASE_CHAR
(
"char"
,
null
),
BASE_INT
(
"int"
,
null
),
BASE_LONG
(
"long"
,
null
),
BASE_FLOAT
(
"float"
,
null
),
BASE_DOUBLE
(
"double"
,
null
),
BASE_BOOLEAN
(
"boolean"
,
null
),
// 包装类型
BYTE
(
"Byte"
,
null
),
SHORT
(
"Short"
,
null
),
CHARACTER
(
"Character"
,
null
),
INTEGER
(
"Integer"
,
null
),
LONG
(
"Long"
,
null
),
FLOAT
(
"Float"
,
null
),
DOUBLE
(
"Double"
,
null
),
BOOLEAN
(
"Boolean"
,
null
),
STRING
(
"String"
,
null
),
// sql 包下数据类型
DATE_SQL
(
"Date"
,
"java.sql.Date"
),
TIME
(
"Time"
,
"java.sql.Time"
),
TIMESTAMP
(
"Timestamp"
,
"java.sql.Timestamp"
),
BLOB
(
"Blob"
,
"java.sql.Blob"
),
CLOB
(
"Clob"
,
"java.sql.Clob"
),
// java8 新时间类型
LOCAL_DATE
(
"LocalDate"
,
"java.time.LocalDate"
),
LOCAL_TIME
(
"LocalTime"
,
"java.time.LocalTime"
),
YEAR
(
"Year"
,
"java.time.Year"
),
YEAR_MONTH
(
"YearMonth"
,
"java.time.YearMonth"
),
LOCAL_DATE_TIME
(
"LocalDateTime"
,
"java.time.LocalDateTime"
),
// 其他杂类
BYTE_ARRAY
(
"byte[]"
,
null
),
OBJECT
(
"Object"
,
null
),
DATE
(
"Date"
,
"java.util.Date"
),
BIG_INTEGER
(
"BigInteger"
,
"java.math.BigInteger"
),
BIG_DECIMAL
(
"BigDecimal"
,
"java.math.BigDecimal"
);
/**
* <p>类型</p>
*/
private
final
String
type
;
/**
* <p>包路径</p>
*/
private
final
String
pkg
;
DbColumnType
(
final
String
type
,
final
String
pkg
)
{
this
.
type
=
type
;
this
.
pkg
=
pkg
;
}
@Override
public
String
getType
()
{
return
type
;
}
@Override
public
String
getPkg
()
{
return
pkg
;
}
}
src/main/java/com/github/mybatis/fl/convert/ITypeConvert.java
View file @
f4cf6996
/**
* Copyright © 2019 dream horse Info. Tech Ltd. All rights reserved.
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* @Package: com.github.mybatis.fl.convert
* @author: flying-cattle
* @date: 2019年4月9日 下午8:06:16
*/
package
com
.
github
.
mybatis
.
fl
.
convert
;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明: 该类的功能描述</p>
* @version: v1.0.0
* @author: flying-cattle
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* 2019年4月9日 flying-cattle v2.0.1 initialize
*/
public
interface
ITypeConvert
{
/**
* <p>说明:执行类型转换</p>
* @param
globalConfig 全局配置
* @param fieldType
字段类型
* @return ignore
*/
IColumnType
processTypeConvert
(
DateType
dateType
,
String
fieldType
);
}
/**
* Copyright © 2019 dream horse Info. Tech Ltd. All rights reserved.
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* @Package: com.github.mybatis.fl.convert
* @author: flying-cattle
* @date: 2019年4月9日 下午8:06:16
*/
package
com
.
github
.
mybatis
.
fl
.
convert
;
/**
* Copyright: Copyright (c) 2019
*
* <p>说明: 该类的功能描述</p>
* @version: v1.0.0
* @author: flying-cattle
*
* Modification History:
* Date Author Version Description
*---------------------------------------------------------------*
* 2019年4月9日 flying-cattle v2.0.1 initialize
*/
public
interface
ITypeConvert
{
/**
* <p>说明:执行类型转换</p>
* @param
dateType 时间类型
* @param fieldType
字段类型
* @return ignore
*/
IColumnType
processTypeConvert
(
DateType
dateType
,
String
fieldType
);
}
src/main/java/com/github/mybatis/fl/util/MySqlToJavaUtil.java
View file @
f4cf6996
...
...
@@ -23,7 +23,9 @@ import com.github.mybatis.fl.convert.MySqlTypeConvert;
public
class
MySqlToJavaUtil
{
/**
* <p>获取java类名</p>
* <p>说明:获取java类名</p>
* @param table 表名
* @return String
*/
public
static
String
getClassName
(
String
table
)
{
table
=
changeToJavaFiled
(
table
);
...
...
@@ -35,7 +37,9 @@ public class MySqlToJavaUtil {
}
/**
* <p>获取字段名,把"_"后面字母变大写</p>
* <p>说明:获取字段名,把"_"后面字母变大写</p>
* @param field 字段名
* @return String
*/
public
static
String
changeToJavaFiled
(
String
field
)
{
String
[]
fields
=
field
.
split
(
"_"
);
...
...
@@ -48,8 +52,11 @@ public class MySqlToJavaUtil {
return
sbuilder
.
toString
();
}
/**
* <p>把sql的数据类型转为java需要的类型</p>
* <p>说明:把sql的数据类型转为java需要的类型</p>
* @param sqlType sql类型
* @return String java类型
*/
public
static
String
jdbcTypeToJavaType
(
String
sqlType
)
{
MySqlTypeConvert
typeConvert
=
new
MySqlTypeConvert
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment