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
1b2386f8
Commit
1b2386f8
authored
Jun 13, 2018
by
xxlv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix typo
parent
9bcbcb29
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
13 deletions
+50
-13
.gitignore
.gitignore
+3
-0
workspace.xml
.idea/workspace.xml
+0
-0
gen.py
gen.py
+47
-13
mysql-connector-java-5.1.25.jar
jar/mysql-connector-java-5.1.25.jar
+0
-0
No files found.
.gitignore
0 → 100644
View file @
1b2386f8
tmp
.idea
\ No newline at end of file
.idea/workspace.xml
View file @
1b2386f8
This diff is collapsed.
Click to expand it.
gen.py
View file @
1b2386f8
...
@@ -9,6 +9,7 @@ import xml.etree.ElementTree as ET
...
@@ -9,6 +9,7 @@ import xml.etree.ElementTree as ET
DIR
=
"./template"
DIR
=
"./template"
TMP
=
"./tmp"
TMP
=
"./tmp"
JAR_PATH
=
"./jar"
JAR_PATH
=
"./jar"
MYBATIS_GEN_JAVA_PATH
=
"{}/java"
.
format
(
TMP
)
def
parse_ydl_project
(
path
):
def
parse_ydl_project
(
path
):
...
@@ -74,6 +75,14 @@ def parse_ydl_project(path):
...
@@ -74,6 +75,14 @@ def parse_ydl_project(path):
# cp文件
# cp文件
def
safe_cpfile
(
f
,
target_path_map
,
res_name
):
def
safe_cpfile
(
f
,
target_path_map
,
res_name
):
"""
cp文件到project path
:param f:
:param target_path_map:
:param res_name:
:return:
"""
res_name
=
res_name
[
0
]
.
upper
()
+
res_name
[
1
:]
res_name
=
res_name
[
0
]
.
upper
()
+
res_name
[
1
:]
if
f
is
None
:
if
f
is
None
:
...
@@ -113,6 +122,13 @@ def safe_cpfile(f, target_path_map, res_name):
...
@@ -113,6 +122,13 @@ def safe_cpfile(f, target_path_map, res_name):
def
is_po
(
res_name
,
identity
):
def
is_po
(
res_name
,
identity
):
"""
检测是否是po
:param res_name:
:param identity:
:return:
"""
print
(
"检测po {} {}"
.
format
(
res_name
,
identity
.
split
(
"/"
)[
-
1
]))
print
(
"检测po {} {}"
.
format
(
res_name
,
identity
.
split
(
"/"
)[
-
1
]))
return
"{}.java"
.
format
(
res_name
)
==
identity
.
split
(
"/"
)[
-
1
]
return
"{}.java"
.
format
(
res_name
)
==
identity
.
split
(
"/"
)[
-
1
]
...
@@ -143,10 +159,20 @@ def config_mybatis(res_name, table_name, mybatis_config_path):
...
@@ -143,10 +159,20 @@ def config_mybatis(res_name, table_name, mybatis_config_path):
context
=
root
.
find
(
"context"
)
context
=
root
.
find
(
"context"
)
context
.
append
(
e
)
context
.
append
(
e
)
po_path
=
context
.
find
(
"javaModelGenerator"
)
.
get
(
"targetPackage"
)
java_model_generator
=
context
.
find
(
"javaModelGenerator"
)
java_model_generator
.
set
(
"targetProject"
,
"{}/java/"
.
format
(
TMP
))
tmp_mybatis_path
=
os
.
path
.
join
(
TMP
,
"generatorConfig.xml"
)
tmp_mybatis_path
=
os
.
path
.
join
(
TMP
,
"generatorConfig.xml"
)
root
.
write
(
tmp_mybatis_path
,
encoding
=
"utf-8"
)
root
.
write
(
tmp_mybatis_path
,
encoding
=
"utf-8"
)
with
open
(
tmp_mybatis_path
,
"r+"
)
as
f
:
content
=
f
.
read
()
f
.
seek
(
0
,
0
)
f
.
write
(
head
+
content
)
return
tmp_mybatis_path
return
{
"tmp_mybatis_path"
:
tmp_mybatis_path
,
"po_path"
:
po_path
}
def
gen_po
(
res_name
,
project_target_path
):
def
gen_po
(
res_name
,
project_target_path
):
...
@@ -165,23 +191,28 @@ def gen_po(res_name, project_target_path):
...
@@ -165,23 +191,28 @@ def gen_po(res_name, project_target_path):
tables_name
=
res_name
tables_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
)
local_mybatis_config_path
=
local_mybatis_config
[
"tmp_mybatis_path"
]
po_path
=
"{}/{}"
.
format
(
MYBATIS_GEN_JAVA_PATH
,
"/"
.
join
(
local_mybatis_config
[
"po_path"
]
.
split
(
"."
)))
print
(
po_path
)
gen_po_cmd
=
"""
gen_po_cmd
=
"""
java -jar {}/mybatis-generator-core-1.3.6.jar -configfile {} -overwrite
java -jar {}/mybatis-generator-core-1.3.6.jar -configfile {} -overwrite
"""
.
format
(
JAR_PATH
,
local_mybatis_config
)
"""
.
format
(
JAR_PATH
,
local_mybatis_config_path
)
print
(
"----------------------------------------"
)
print
(
"----------------------------------------"
)
print
(
gen_po_cmd
)
print
(
gen_po_cmd
)
print
(
"----------------------------------------"
)
print
(
"----------------------------------------"
)
os
.
system
(
gen_po_cmd
)
# os.system(gen_po_cmd)
with
open
(
"{}/{}.java"
.
format
(
po_path
,
res_name
),
"r+"
)
as
f
:
po
=
f
.
read
()
return
"PO"
return
po
def
rewrite_mybatis_config
():
pass
# 编译内容
# 编译内容
...
@@ -236,9 +267,12 @@ def clean_tmp():
...
@@ -236,9 +267,12 @@ def clean_tmp():
:return:
:return:
"""
"""
for
root
,
dirs
,
files
in
os
.
walk
(
TMP
,
False
):
if
(
os
.
path
.
isdir
(
TMP
)):
for
file
in
files
:
shutil
.
rmtree
(
TMP
)
os
.
remove
(
os
.
path
.
join
(
root
,
file
))
os
.
mkdir
(
TMP
)
os
.
mkdir
(
MYBATIS_GEN_JAVA_PATH
)
print
(
"清空目录 {}"
.
format
(
TMP
))
print
(
"清空目录 {}"
.
format
(
TMP
))
...
...
jar/mysql-connector-java-5.1.25.jar
0 → 100644
View file @
1b2386f8
File added
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