Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
quick_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
Lv xiang
quick_generator
Commits
5c4cb6c1
Commit
5c4cb6c1
authored
Jun 13, 2018
by
xxlv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tpl
parent
b001e2b3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
49 additions
and
28 deletions
+49
-28
workspace.xml
.idea/workspace.xml
+0
-0
gen.py
gen.py
+26
-5
${PLACE}.java
template/${PLACE}.java
+1
-1
${PLACE}Biz.java
template/${PLACE}Biz.java
+3
-3
${PLACE}BizImpl.java
template/${PLACE}BizImpl.java
+4
-4
${PLACE}Facade.java
template/${PLACE}Facade.java
+4
-4
${PLACE}FacadeImpl.java
template/${PLACE}FacadeImpl.java
+6
-6
${PLACE}Mapper.java
template/${PLACE}Mapper.java
+3
-3
${PLACE}ReqDto.java
template/${PLACE}ReqDto.java
+1
-1
${PLACE}RespDto.java
template/${PLACE}RespDto.java
+1
-1
No files found.
.idea/workspace.xml
View file @
5c4cb6c1
This diff is collapsed.
Click to expand it.
gen.py
View file @
5c4cb6c1
...
@@ -5,6 +5,7 @@ import os
...
@@ -5,6 +5,7 @@ import os
import
shutil
import
shutil
import
argparse
import
argparse
import
xml.etree.ElementTree
as
ET
import
xml.etree.ElementTree
as
ET
import
re
DIR
=
"./template"
DIR
=
"./template"
TMP
=
"./tmp"
TMP
=
"./tmp"
...
@@ -189,7 +190,7 @@ def gen_po(res_name, project_target_path):
...
@@ -189,7 +190,7 @@ def gen_po(res_name, project_target_path):
print
(
"Mybatis 路径有误"
)
print
(
"Mybatis 路径有误"
)
exit
(
-
1
)
exit
(
-
1
)
tables_name
=
res_name
tables_name
=
get_table_name
(
res_name
)
local_mybatis_config
=
config_mybatis
(
res_name
,
tables_name
,
mybatis_config_path
)
local_mybatis_config
=
config_mybatis
(
res_name
,
tables_name
,
mybatis_config_path
)
...
@@ -279,6 +280,25 @@ def clean_tmp():
...
@@ -279,6 +280,25 @@ def clean_tmp():
print
(
"清空目录 {}"
.
format
(
TMP
))
print
(
"清空目录 {}"
.
format
(
TMP
))
def
get_res_name
(
res_name
):
# TODO
# 转化为驼峰
pass
def
get_table_name
(
res_name
):
table_name
=
""
res_name
=
res_name
[
0
:
1
]
.
lower
()
+
res_name
[
1
:]
for
i
in
range
(
0
,
len
(
res_name
)):
t
=
res_name
[
i
]
if
(
t
.
isupper
()):
t
=
""
.
join
([
"_"
,
t
.
lower
()])
table_name
=
""
.
join
([
table_name
,
t
])
return
table_name
def
gen
(
res_name
,
look_path
):
def
gen
(
res_name
,
look_path
):
"""
"""
核心逻辑
核心逻辑
...
@@ -288,8 +308,7 @@ def gen(res_name, look_path):
...
@@ -288,8 +308,7 @@ def gen(res_name, look_path):
:return:
:return:
"""
"""
clean_tmp
()
clean_tmp
()
res_name
=
get_res_name
(
res_name
)
res_name
=
res_name
[
0
]
.
upper
()
+
res_name
[
1
:]
print
(
"----------------------------------"
)
print
(
"----------------------------------"
)
print
(
"你的资源名称为 {}"
.
format
(
res_name
))
print
(
"你的资源名称为 {}"
.
format
(
res_name
))
print
(
"----------------------------------"
)
print
(
"----------------------------------"
)
...
@@ -308,7 +327,6 @@ def gen(res_name, look_path):
...
@@ -308,7 +327,6 @@ def gen(res_name, look_path):
compile_table
[
'${PLACE}'
]
=
"{}{}"
.
format
(
res_name
[
0
]
.
upper
(),
res_name
[
1
:])
compile_table
[
'${PLACE}'
]
=
"{}{}"
.
format
(
res_name
[
0
]
.
upper
(),
res_name
[
1
:])
compile_table
[
'${PLACE_VAR}'
]
=
"{}{}"
.
format
(
res_name
[
0
]
.
lower
(),
res_name
[
1
:])
compile_table
[
'${PLACE_VAR}'
]
=
"{}{}"
.
format
(
res_name
[
0
]
.
lower
(),
res_name
[
1
:])
import
re
intf
=
PROJECT_TARGET_PATH
[
"intf_po_path"
]
intf
=
PROJECT_TARGET_PATH
[
"intf_po_path"
]
p
=
re
.
compile
(
"[
\
s
\
S]*
\
/(.+)
\
-intf
\
/[
\
s
\
S]*"
)
p
=
re
.
compile
(
"[
\
s
\
S]*
\
/(.+)
\
-intf
\
/[
\
s
\
S]*"
)
...
@@ -344,6 +362,10 @@ def gen(res_name, look_path):
...
@@ -344,6 +362,10 @@ def gen(res_name, look_path):
PROJECT_TARGET_PATH
)
PROJECT_TARGET_PATH
)
safe_cpfile
(
compiled_file
,
PROJECT_TARGET_PATH
,
res_name
)
safe_cpfile
(
compiled_file
,
PROJECT_TARGET_PATH
,
res_name
)
print
(
"---------------------------------------------"
)
print
(
"你已经成功的生成了代码"
)
print
(
"---------------------------------------------"
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
print
(
"-------------------------"
)
print
(
"-------------------------"
)
...
@@ -354,7 +376,6 @@ if __name__ == "__main__":
...
@@ -354,7 +376,6 @@ if __name__ == "__main__":
parser
=
argparse
.
ArgumentParser
(
description
=
"Auto create Resource for ydl java project"
)
parser
=
argparse
.
ArgumentParser
(
description
=
"Auto create Resource for ydl java project"
)
parser
.
add_argument
(
'--verbose'
,
'-v'
,
action
=
'store_true'
,
help
=
'debug mode'
)
parser
.
add_argument
(
'--verbose'
,
'-v'
,
action
=
'store_true'
,
help
=
'debug mode'
)
parser
.
add_argument
(
"resource_name"
)
parser
.
add_argument
(
"resource_name"
)
parser
.
add_argument
(
"package"
)
parser
.
add_argument
(
"project_path"
)
parser
.
add_argument
(
"project_path"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
...
template/${PLACE}.java
View file @
5c4cb6c1
package
com
.
ydl
.
user
.
intf
.
po
;
package
com
.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL1
}
.
intf
.
po
;
public
class
${
PLACE
}
{
public
class
${
PLACE
}
{
...
...
template/${PLACE}Biz.java
View file @
5c4cb6c1
package
com
.
ydl
.
user
.
service
.
biz
;
package
com
.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
service
.
biz
;
import
com.
ydl
.common.service.IService
;
import
com.
$
{
PACKAGE_LEVEL1
}
.
common
.
service
.
IService
;
import
com.
ydl.user
.intf.po.
$
{
PLACE
};
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
po
.
$
{
PLACE
};
public
interface
${
PLACE
}
Biz
extends
IService
<
$
{
PLACE
}>
{
public
interface
${
PLACE
}
Biz
extends
IService
<
$
{
PLACE
}>
{
...
...
template/${PLACE}BizImpl.java
View file @
5c4cb6c1
package
com
.
ydl
.
user
.
service
.
biz
.
impl
;
package
com
.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
service
.
biz
.
impl
;
import
com.
ydl.user
.intf.po.
$
{
PLACE
};
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
po
.
$
{
PLACE
};
import
com.
ydl.user
.service.biz.
$
{
PLACE
}
Biz
;
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
service
.
biz
.
$
{
PLACE
}
Biz
;
import
com.
ydl.user
.service.dao.
$
{
PLACE
}
Mapper
;
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
service
.
dao
.
$
{
PLACE
}
Mapper
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.ydl.common.service.impl.BaseService
;
import
com.ydl.common.service.impl.BaseService
;
...
...
template/${PLACE}Facade.java
View file @
5c4cb6c1
package
com
.
ydl
.
user
.
intf
.
facade
;
package
com
.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
facade
;
import
com.
ydl
.common.dto.BaseDtoResponse
;
import
com.
$
{
PACKAGE_LEVEL1
}
.
common
.
dto
.
BaseDtoResponse
;
import
com.
ydl.user
.intf.dto.request.
{
PLACE
}
ReqDto
;
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
dto
.
request
.{
PLACE
}
ReqDto
;
import
com.
ydl.user
.intf.dto.response.
{
PLACE
}
RespDto
;
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
dto
.
response
.{
PLACE
}
RespDto
;
public
interface
${
PLACE
}
Facade
{
public
interface
${
PLACE
}
Facade
{
BaseDtoResponse
<
$
{
PLACE
}
RespDto
>
create
$
{
PLACE
}(
$
{
PLACE
}
ReqDto
$
{
PLACE_VAR
}
ReqDto
);
BaseDtoResponse
<
$
{
PLACE
}
RespDto
>
create
$
{
PLACE
}(
$
{
PLACE
}
ReqDto
$
{
PLACE_VAR
}
ReqDto
);
...
...
template/${PLACE}FacadeImpl.java
View file @
5c4cb6c1
package
com
.
ydl
.
user
.
service
.
facade
;
package
com
.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
service
.
facade
;
import
com.
ydl
.common.dto.BaseDtoResponse
;
import
com.
$
{
PACKAGE_LEVEL1
}
.
common
.
dto
.
BaseDtoResponse
;
import
com.
ydl
.common.helper.ResponseFormatterHelper
;
import
com.
$
{
PACKAGE_LEVEL1
}
.
common
.
helper
.
ResponseFormatterHelper
;
import
com.
ydl
.common.utils.ModelMapperUtil
;
import
com.
$
{
PACKAGE_LEVEL1
}
.
common
.
utils
.
ModelMapperUtil
;
import
com.
ydl.user
.intf.facade.
$
{
PLACE
}
Facade
;
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
facade
.
$
{
PLACE
}
Facade
;
import
com.
ydl.user
.service.biz.
$
{
PLACE
}
Biz
;
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
service
.
biz
.
$
{
PLACE
}
Biz
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
...
template/${PLACE}Mapper.java
View file @
5c4cb6c1
package
com
.
ydl
.
user
.
service
.
dao
;
package
com
.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
service
.
dao
;
import
com.
ydl
.common.service.BaseMapper
;
import
com.
$
{
PACKAGE_LEVEL1
}
.
common
.
service
.
BaseMapper
;
import
com.
ydl.user
.intf.po.
$
{
PLACE
};
import
com.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
po
.
$
{
PLACE
};
public
interface
${
PLACE
}
Mapper
extends
BaseMapper
<
$
{
PLACE
}>
{
public
interface
${
PLACE
}
Mapper
extends
BaseMapper
<
$
{
PLACE
}>
{
}
}
template/${PLACE}ReqDto.java
View file @
5c4cb6c1
package
com
.
ydl
.
user
.
intf
.
dto
.
request
;
package
com
.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
dto
.
request
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
...
template/${PLACE}RespDto.java
View file @
5c4cb6c1
package
com
.
ydl
.
user
.
intf
.
dto
.
response
;
package
com
.
$
{
PACKAGE_LEVEL1
}.
$
{
PACKAGE_LEVEL2
}
.
intf
.
dto
.
response
;
public
class
${
PLACE
}
RespDto
{
public
class
${
PLACE
}
RespDto
{
...
...
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