Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
deploy_script
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Script
deploy_script
Commits
0813d8ea
Commit
0813d8ea
authored
Jun 22, 2021
by
jinkaiqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dip 表转为java模型
parent
a0345752
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
3 deletions
+105
-3
AnalysisFile.py
NginxLog/AnalysisFile.py
+9
-3
dip_table_to_java_model.py
dip_table_to_java_model.py
+96
-0
No files found.
NginxLog/AnalysisFile.py
View file @
0813d8ea
...
@@ -7,7 +7,7 @@ from NginxLog.DBDriver import DBDriver
...
@@ -7,7 +7,7 @@ from NginxLog.DBDriver import DBDriver
def
get_cell_data
(
row_data
):
def
get_cell_data
(
row_data
):
re_result
=
re
.
match
(
re_result
=
re
.
match
(
r'^(?P<ip>\d+.\d+.\d+.\d+) - - \[(?P<time>.*) \+0
8
00\] "(?P<url>.*)" (?P<status>\d{3}) .*'
,
r'^(?P<ip>\d+.\d+.\d+.\d+) - - \[(?P<time>.*) \+0
0
00\] "(?P<url>.*)" (?P<status>\d{3}) .*'
,
row_data
)
row_data
)
if
re_result
is
None
:
if
re_result
is
None
:
print
(
row_data
)
print
(
row_data
)
...
@@ -24,13 +24,19 @@ def get_cell_data(row_data):
...
@@ -24,13 +24,19 @@ def get_cell_data(row_data):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
file_path
=
r"D:\Work\nginx-1.19.0\logs\access-2021-04-27T09.log"
# 2021-04-27 11:22:05, 18:09:55
date1
=
datetime
.
datetime
.
strptime
(
"2021-04-27 11:22:05"
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
date2
=
datetime
.
datetime
.
strptime
(
"2021-04-27 18:09:55"
,
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
print
((
date2
-
date1
)
.
total_seconds
())
# 24470
exit
(
1
)
file_path
=
r"D:\Work\Git\deploy_script\NginxLog\access.log"
db_driver
=
DBDriver
(
"mysql+pymysql://jkq:741963@localhost:3306/test?charset=utf8"
)
db_driver
=
DBDriver
(
"mysql+pymysql://jkq:741963@localhost:3306/test?charset=utf8"
)
lines
=
0
lines
=
0
insert_count
=
0
insert_count
=
0
sql_str_list
=
[]
sql_str_list
=
[]
with
open
(
file_path
,
'r'
)
as
f
:
with
open
(
file_path
,
'r'
)
as
f
:
while
lines
<
10000
00
:
while
lines
<
20851
00
:
data
=
f
.
readline
()
data
=
f
.
readline
()
if
data
is
None
:
if
data
is
None
:
print
(
"exit:"
,
lines
)
print
(
"exit:"
,
lines
)
...
...
dip_table_to_java_model.py
0 → 100644
View file @
0813d8ea
# -*- coding:utf-8 -*-
'''
字段名 类型 长度 可为空 默认值 UI非空 链接常量 录入方式 资源
id bigint 8 非校验 非校验 0 主键
name nvarchar 50 非校验 非校验 0 名称
description nvarchar 200 非校验 非校验 0 描述
domain nvarchar 100 非校验 非校验 0 域名
secret_key nvarchar 50 非校验 非校验 0 秘钥
admin_telephones varchar 200 非校验 非校验 0 管理员手机号码
usable bit 1 非校验 1 非校验 0 是否可用
'''
def
str2Hump
(
text
):
arr
=
filter
(
None
,
text
.
lower
()
.
split
(
'_'
))
res
=
''
j
=
0
for
i
in
arr
:
if
j
==
0
:
res
=
i
else
:
res
=
res
+
i
[
0
]
.
upper
()
+
i
[
1
:]
j
+=
1
return
res
def
str2Type
(
c_type
):
if
c_type
.
lower
()
==
"bigint"
:
return
"Long"
if
c_type
.
lower
()
==
"nvarchar"
:
return
"String"
if
c_type
.
lower
()
==
"varchar"
:
return
"String"
if
c_type
.
lower
()
==
"bit"
:
return
"Boolean"
if
c_type
.
lower
()
==
"int"
:
return
"Integer"
if
c_type
.
lower
()
==
"datetime"
:
return
"LocalDateTime"
if
c_type
.
lower
()
==
"date"
:
return
"LocalDate"
return
"Unkown"
def
str2Remark
(
c_resource
,
c_remark
):
if
not
c_resource
and
not
c_remark
:
return
""
if
c_remark
:
return
f
"""/**
* {c_resource}
* {c_remark}
*/"""
else
:
return
f
"""/**
* {c_resource}
*/"""
if
__name__
==
'__main__'
:
dip_table_str
=
"""字段名 类型 长度 可为空 默认值 UI非空 链接常量 录入方式 资源
id bigint 8 非校验 非校验 0 主键
app_id bigint 8 非校验 非校验 0 appId
app_name nvarchar 50 非校验 非校验 0 所属App
order_no nvarchar 32 非校验 非校验 0 订单号
amount int 4 非校验 非校验 0 金额
description nvarchar 127 非校验 非校验 0 订单描述
attach nvarchar 128 非校验 '' 非校验 0 订单附加信息
remark nvarchar 200 校验 非校验 0 备注
callback nvarchar 300 非校验 非校验 0 回调信息
status int 4 非校验 0 非校验 6442 订单状态
redirect_url nvarchar 500 非校验 非校验 0 跳转地址
active_out_trade_no nvarchar 32 非校验 非校验 0 商户订单号
create_time datetime 8 非校验 getdate() 非校验 0 创建时间
pay_time datetime 8 校验 非校验 0 支付时间
payment_type int 4 非校验 1 非校验 6443 支付类型
"""
dip_table_column_list
=
dip_table_str
.
split
(
"
\n
"
)
for
dip_table_column
in
dip_table_column_list
:
if
not
dip_table_column
:
continue
column_info
=
dip_table_column
.
split
(
"
\t
"
)
c_name
=
column_info
[
0
]
if
c_name
==
"字段名"
:
continue
c_type
=
column_info
[
1
]
c_resource
=
column_info
[
8
]
c_remark
=
""
j_name
=
str2Hump
(
c_name
)
j_type
=
str2Type
(
c_type
)
j_remark
=
str2Remark
(
c_resource
,
c_remark
)
print
(
f
"""{j_remark}
private {j_type} {j_name};"""
)
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