Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
1da338ac
Commit
1da338ac
authored
Apr 24, 2019
by
eddie.woo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
dfcca34c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
287 additions
and
5 deletions
+287
-5
generatorConfig.xml
atms-dao/etc/generator-mysql/generatorConfig.xml
+18
-5
SimpleCommentGenerator.java
...est/java/pwc/taxtech/atms/gen/SimpleCommentGenerator.java
+269
-0
No files found.
atms-dao/etc/generator-mysql/generatorConfig.xml
View file @
1da338ac
...
...
@@ -8,13 +8,13 @@
<!-- <classPathEntry location="../hsqldb/hsqldb-2.3.5.jar" /> -->
<context
id=
"contextId"
targetRuntime=
"MyBatis3"
>
<!-- 考虑需要兼容DB2与ORCAL数据库, 大部份字段不需要加双引号,autoDelimitKeywords设置为false -->
<property
name=
"autoDelimitKeywords"
value=
"
fals
e"
/>
<property
name=
"autoDelimitKeywords"
value=
"
tru
e"
/>
<property
name=
"javaFileEncoding"
value=
"UTF-8"
/>
<!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
<property
name=
"beginningDelimiter"
value=
"`"
/>
<property
name=
"endingDelimiter"
value=
"`"
/>
<plugin
type=
"org.mybatis.generator.plugins.MapperAnnotationPlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.RowBoundsPlugin"
/
>
<!-- <plugin type="org.mybatis.generator.plugins.RowBoundsPlugin"/>--
>
<plugin
type=
"org.mybatis.generator.plugins.ToStringPlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.SerializablePlugin"
/>
<commentGenerator>
...
...
@@ -41,13 +41,26 @@
<property
name=
"rootInterface"
value=
"pwc.taxtech.atms.MyMapper"
/>
</javaClientGenerator>
<table
tableName=
"
data_import_log"
domainObjectName=
"DataImportLog
"
>
<table
tableName=
"
wf_record"
domainObjectName=
"WfRecord
"
>
<property
name=
"useActualColumnNames"
value=
"false"
/>
<property
name=
"ignoreQualifiersAtRuntime"
value=
"true"
/>
<columnOverride
column=
"period"
javaType=
"java.lang.Integer"
jdbcType=
"TINYINT"
/>
<columnOverride
column=
"type"
javaType=
"java.lang.Integer"
jdbcType=
"TINYINT"
/>
<columnOverride
column=
"tms_period_month"
javaType=
"java.lang.Integer"
jdbcType=
"TINYINT"
/>
<columnOverride
column=
"period_month"
javaType=
"java.lang.Integer"
jdbcType=
"TINYINT"
/>
<columnOverride
column=
"status"
javaType=
"java.lang.Integer"
jdbcType=
"TINYINT"
/>
</table>
<table
tableName=
"wf_record_detail"
domainObjectName=
"WfRecordDetail"
>
<property
name=
"useActualColumnNames"
value=
"false"
/>
<property
name=
"ignoreQualifiersAtRuntime"
value=
"true"
/>
<columnOverride
column=
"status"
javaType=
"java.lang.Integer"
jdbcType=
"TINYINT"
/>
</table>
<!-- <table tableName="data_import_log" domainObjectName="DataImportLog">-->
<!-- <property name="useActualColumnNames" value="false"/>-->
<!-- <property name="ignoreQualifiersAtRuntime" value="true"/>-->
<!-- <columnOverride column="type" javaType="java.lang.Integer" jdbcType="TINYINT"/>-->
<!-- <columnOverride column="tms_period_month" javaType="java.lang.Integer" jdbcType="TINYINT"/>-->
<!-- <columnOverride column="period_month" javaType="java.lang.Integer" jdbcType="TINYINT"/>-->
<!-- </table>-->
<!--<table tableName="analysis_expected_tax_return" domainObjectName="AnalysisExpectedTaxReturn">-->
<!--<property name="useActualColumnNames" value="false"/>-->
...
...
atms-dao/src/test/java/pwc/taxtech/atms/gen/SimpleCommentGenerator.java
0 → 100644
View file @
1da338ac
package
pwc
.
taxtech
.
atms
.
gen
;
import
org.mybatis.generator.api.CommentGenerator
;
import
org.mybatis.generator.api.IntrospectedColumn
;
import
org.mybatis.generator.api.IntrospectedTable
;
import
org.mybatis.generator.api.dom.java.*
;
import
org.mybatis.generator.api.dom.xml.XmlElement
;
import
org.mybatis.generator.config.MergeConstants
;
import
org.mybatis.generator.config.PropertyRegistry
;
import
org.mybatis.generator.internal.util.StringUtility
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Properties
;
import
java.util.Set
;
public
class
SimpleCommentGenerator
implements
CommentGenerator
{
private
Properties
properties
;
// private Properties systemPro;
private
boolean
suppressDate
;
private
boolean
suppressAllComments
;
private
String
currentDateStr
;
public
SimpleCommentGenerator
()
{
super
();
properties
=
new
Properties
();
// systemPro = System.getProperties();
suppressDate
=
false
;
suppressAllComments
=
false
;
currentDateStr
=
(
new
SimpleDateFormat
(
"yyyy-MM-dd"
)).
format
(
new
Date
());
}
public
void
addJavaFileComment
(
CompilationUnit
compilationUnit
)
{
// add no file level comments by default
}
/**
* Adds a suitable comment to warn users that the element was generated, and
* when it was generated.
*/
public
void
addComment
(
XmlElement
xmlElement
)
{
}
public
void
addRootComment
(
XmlElement
rootElement
)
{
// add no document level comments by default
}
@Override
public
void
addGeneralMethodAnnotation
(
Method
method
,
IntrospectedTable
introspectedTable
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
}
@Override
public
void
addGeneralMethodAnnotation
(
Method
method
,
IntrospectedTable
introspectedTable
,
IntrospectedColumn
introspectedColumn
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
}
@Override
public
void
addFieldAnnotation
(
Field
field
,
IntrospectedTable
introspectedTable
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
}
@Override
public
void
addFieldAnnotation
(
Field
field
,
IntrospectedTable
introspectedTable
,
IntrospectedColumn
introspectedColumn
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
}
@Override
public
void
addClassAnnotation
(
InnerClass
innerClass
,
IntrospectedTable
introspectedTable
,
Set
<
FullyQualifiedJavaType
>
imports
)
{
}
public
void
addConfigurationProperties
(
Properties
properties
)
{
this
.
properties
.
putAll
(
properties
);
suppressDate
=
StringUtility
.
isTrue
(
properties
.
getProperty
(
PropertyRegistry
.
COMMENT_GENERATOR_SUPPRESS_DATE
));
suppressAllComments
=
StringUtility
.
isTrue
(
properties
.
getProperty
(
PropertyRegistry
.
COMMENT_GENERATOR_SUPPRESS_ALL_COMMENTS
));
}
/**
* This method adds the custom javadoc tag for. You may do nothing if you do
* not wish to include the Javadoc tag - however, if you do not include the
* Javadoc tag then the Java merge capability of the eclipse plugin will
* break.
*
* @param javaElement the java element
*/
protected
void
addJavadocTag
(
JavaElement
javaElement
,
boolean
markAsDoNotDelete
)
{
javaElement
.
addJavaDocLine
(
" *"
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
" * "
);
sb
.
append
(
MergeConstants
.
NEW_ELEMENT_TAG
);
if
(
markAsDoNotDelete
)
{
sb
.
append
(
" do_not_delete_during_merge"
);
}
String
s
=
getDateString
();
if
(
s
!=
null
)
{
sb
.
append
(
' '
);
sb
.
append
(
s
);
}
javaElement
.
addJavaDocLine
(
sb
.
toString
());
}
/**
* This method returns a formated date string to include in the Javadoc tag
* and XML comments. You may return null if you do not want the date in
* these documentation elements.
*
* @return a string representing the current timestamp, or null
*/
protected
String
getDateString
()
{
String
result
=
null
;
if
(!
suppressDate
)
{
result
=
currentDateStr
;
}
return
result
;
}
public
void
addClassComment
(
InnerClass
innerClass
,
IntrospectedTable
introspectedTable
)
{
if
(
suppressAllComments
)
{
return
;
}
StringBuilder
sb
=
new
StringBuilder
();
innerClass
.
addJavaDocLine
(
"/**"
);
sb
.
append
(
" * "
);
sb
.
append
(
introspectedTable
.
getFullyQualifiedTable
());
sb
.
append
(
" "
);
sb
.
append
(
getDateString
());
innerClass
.
addJavaDocLine
(
sb
.
toString
());
innerClass
.
addJavaDocLine
(
" */"
);
}
public
void
addEnumComment
(
InnerEnum
innerEnum
,
IntrospectedTable
introspectedTable
)
{
if
(
suppressAllComments
)
{
return
;
}
StringBuilder
sb
=
new
StringBuilder
();
innerEnum
.
addJavaDocLine
(
"/**"
);
// addJavadocTag(innerEnum, false);
sb
.
append
(
" * "
);
sb
.
append
(
introspectedTable
.
getFullyQualifiedTable
());
innerEnum
.
addJavaDocLine
(
sb
.
toString
());
innerEnum
.
addJavaDocLine
(
" */"
);
}
public
void
addFieldComment
(
Field
field
,
IntrospectedTable
introspectedTable
,
IntrospectedColumn
introspectedColumn
)
{
if
(
suppressAllComments
)
{
return
;
}
StringBuilder
sb
=
new
StringBuilder
();
field
.
addJavaDocLine
(
"/**"
);
sb
.
append
(
" * "
);
sb
.
append
(
introspectedColumn
.
getRemarks
());
field
.
addJavaDocLine
(
sb
.
toString
());
// addJavadocTag(field, false);
field
.
addJavaDocLine
(
" */"
);
}
public
void
addFieldComment
(
Field
field
,
IntrospectedTable
introspectedTable
)
{
if
(
suppressAllComments
)
{
return
;
}
StringBuilder
sb
=
new
StringBuilder
();
field
.
addJavaDocLine
(
"/**"
);
sb
.
append
(
" * "
);
sb
.
append
(
introspectedTable
.
getFullyQualifiedTable
());
field
.
addJavaDocLine
(
sb
.
toString
());
field
.
addJavaDocLine
(
" */"
);
}
public
void
addModelClassComment
(
TopLevelClass
topLevelClass
,
IntrospectedTable
introspectedTable
)
{
}
public
void
addGeneralMethodComment
(
Method
method
,
IntrospectedTable
introspectedTable
)
{
if
(
suppressAllComments
)
{
return
;
}
// method.addJavaDocLine("/**");
// addJavadocTag(method, false);
// method.addJavaDocLine(" */");
}
public
void
addGetterComment
(
Method
method
,
IntrospectedTable
introspectedTable
,
IntrospectedColumn
introspectedColumn
)
{
if
(
suppressAllComments
)
{
return
;
}
method
.
addJavaDocLine
(
"/**"
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
" * "
);
sb
.
append
(
introspectedColumn
.
getRemarks
());
method
.
addJavaDocLine
(
sb
.
toString
());
sb
.
setLength
(
0
);
sb
.
append
(
" * @return "
);
sb
.
append
(
introspectedColumn
.
getActualColumnName
());
sb
.
append
(
" "
);
sb
.
append
(
introspectedColumn
.
getRemarks
());
method
.
addJavaDocLine
(
sb
.
toString
());
// addJavadocTag(method, false);
method
.
addJavaDocLine
(
" */"
);
}
public
void
addSetterComment
(
Method
method
,
IntrospectedTable
introspectedTable
,
IntrospectedColumn
introspectedColumn
)
{
if
(
suppressAllComments
)
{
return
;
}
method
.
addJavaDocLine
(
"/**"
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
" * "
);
sb
.
append
(
introspectedColumn
.
getRemarks
());
method
.
addJavaDocLine
(
sb
.
toString
());
Parameter
parm
=
method
.
getParameters
().
get
(
0
);
sb
.
setLength
(
0
);
sb
.
append
(
" * @param "
);
sb
.
append
(
parm
.
getName
());
sb
.
append
(
" "
);
sb
.
append
(
introspectedColumn
.
getRemarks
());
method
.
addJavaDocLine
(
sb
.
toString
());
// addJavadocTag(method, false);
method
.
addJavaDocLine
(
" */"
);
}
public
void
addClassComment
(
InnerClass
innerClass
,
IntrospectedTable
introspectedTable
,
boolean
markAsDoNotDelete
)
{
// if (suppressAllComments) {
// return;
// }
// StringBuilder sb = new StringBuilder();
//
// innerClass.addJavaDocLine("/**");
// sb.append(" * ");
// sb.append(introspectedTable.getFullyQualifiedTable());
// innerClass.addJavaDocLine(sb.toString());
//
// sb.setLength(0);
// sb.append(" * @author ");
// sb.append(systemPro.getProperty("user.name"));
// sb.append(" ");
// sb.append(currentDateStr);
//
// // addJavadocTag(innerClass, markAsDoNotDelete);
//
// innerClass.addJavaDocLine(" */");
}
}
\ No newline at end of file
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