Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
evm-store
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
wanli
evm-store
Commits
9d898628
Commit
9d898628
authored
Jul 16, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat(应用管理模块): 完成应用管理模块开发
parent
926e390d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
70 deletions
+64
-70
tools/build_out/controllers/app.py
tools/build_out/controllers/app.py
+25
-30
tools/build_out/views/app.py
tools/build_out/views/app.py
+12
-13
tools/frontend/src/api/openapi.js
tools/frontend/src/api/openapi.js
+3
-4
tools/frontend/src/views/Application/Index.vue
tools/frontend/src/views/Application/Index.vue
+24
-23
No files found.
tools/build_out/controllers/app.py
View file @
9d898628
...
...
@@ -37,14 +37,14 @@ class AppResource(object):
def
__init__
(
self
):
super
()
.
__init__
()
def
get
(
self
,
uuid
,
params
):
def
get
(
self
,
uuid
,
jwt
):
# handle business
filters
=
[
AppModel
.
is_delete
==
False
,
AppModel
.
uuid
==
uuid
]
app
=
AppModel
.
query
.
filter
(
*
filters
)
.
one_or_none
()
if
not
app
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
user
=
UserModel
.
query
.
filter
(
UserModel
.
id
==
params
.
get
(
'user
'
))
.
one_or_none
()
user
=
UserModel
.
query
.
filter
(
UserModel
.
uuid
==
jwt
.
get
(
'uuid
'
))
.
one_or_none
()
if
not
user
:
return
False
,
ResponseCode
.
USER_NOT_EXISTS
...
...
@@ -53,37 +53,34 @@ class AppResource(object):
# 将这些零散文件进行打包
# 更新数据库对应文件的路径
source_files
=
AnnexModel
.
query
.
filter
(
AnnexModel
.
app
==
app
)
.
all
()
source_files
=
AnnexModel
.
query
.
filter
(
AnnexModel
.
app
==
app
.
id
)
.
all
()
if
not
source_files
:
return
None
,
ResponseCode
.
HTTP_NOT_FOUND
dtNowString
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
dirname
=
"{}-{}-{}-{}"
.
format
(
app
.
app_name
,
app
.
app_version
,
app
.
category
,
dtNowString
)
upload_dir
=
os
.
sep
.
join
([
config
.
UPLOAD_ROOT_DIR
,
config
.
EPK_DIR
])
target_dir
=
os
.
sep
.
join
([
upload_dir
,
dirname
])
dest_dir
=
os
.
sep
.
join
([
target_dir
,
"src"
])
if
not
os
.
path
.
exists
(
dest_dir
):
os
.
makedirs
(
dest_dir
)
now_str
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
dirname
=
"{}-{}-{}-{}"
.
format
(
app
.
app_name
,
app
.
app_version
,
app
.
category
,
now_str
)
target_dir
=
Path
(
config
.
UPLOAD_ROOT_DIR
)
.
joinpath
(
config
.
EPK_DIR
)
.
joinpath
(
dirname
)
dest_dir
=
target_dir
.
joinpath
(
"src"
)
if
not
dest_dir
.
exists
():
os
.
makedirs
(
dest_dir
.
resolve
()
.
as_posix
())
app_files
=
[]
for
sf
in
source_files
:
target_file
=
sf
.
path
if
not
os
.
path
.
exists
(
sf
.
path
):
target_file
=
os
.
sep
.
join
([
config
.
UPLOAD_ROOT_DIR
,
sf
.
path
]
)
target_file
=
Path
(
sf
.
path
)
if
not
target_file
.
exists
(
):
target_file
=
Path
(
config
.
UPLOAD_ROOT_DIR
)
.
joinpath
(
sf
.
path
)
filename
=
os
.
path
.
basename
(
target_file
)
name
,
suffix
=
os
.
path
.
splitext
(
filename
)
name
=
re
.
sub
(
r"_\d{14}$"
,
""
,
name
)
dst_file
=
os
.
path
.
normpath
(
os
.
sep
.
join
([
dest_dir
,
name
+
suffix
]))
shutil
.
copy
(
os
.
path
.
normpath
(
target_file
),
dst_file
)
app_files
.
append
([
sf
.
id
,
dst_file
])
name
=
re
.
sub
(
r"_\d{14}$"
,
""
,
target_file
.
stem
)
suffix
=
target_file
.
suffix
dst_file
=
dest_dir
.
joinpath
(
name
+
suffix
)
shutil
.
copy
(
target_file
.
resolve
()
.
as_posix
(),
dst_file
.
resolve
()
.
as_posix
())
app_files
.
append
([
sf
.
id
,
dst_file
.
resolve
()
.
as_posix
()])
with
open
(
os
.
sep
.
join
([
target_dir
,
"epk.json"
]),
"w"
)
as
f
:
json
.
dump
(
app
.
to_dict
(
exclude
=
[
"uuid"
,
"create_at"
,
"update_at"
,
"delete_at"
]),
f
)
target_dir
.
joinpath
(
"epk.json"
)
.
write_text
(
json
.
dumps
(
app
.
to_dict
()),
encoding
=
"utf-8"
)
# 打包成EPK文件
app_info
=
{}
params
=
{
'appName'
:
app
.
app_name
,
'appDir'
:
dest_dir
,
'appVersion'
:
app
.
app_version
,
'output'
:
target_dir
}
params
=
{
'appName'
:
app
.
app_name
,
'appDir'
:
dest_dir
.
resolve
()
.
as_posix
(),
'appVersion'
:
app
.
app_version
,
'output'
:
target_dir
.
resolve
()
.
as_posix
()
}
if
user
.
role
==
1
:
params
[
'algorithm'
]
=
"h"
epk
=
EpkApp
(
**
params
)
...
...
@@ -92,9 +89,9 @@ class AppResource(object):
# 更新数据库对应文件路径
# 将文件拷贝过去后,需要重新更新数据库文件记录
epk_path
=
os
.
sep
.
join
([
target_dir
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
"{}.epk"
.
format
(
app
.
app_name
)])
.
replace
(
'
\\
'
,
'/'
)
epk_path
=
target_dir
.
relative_to
(
config
.
UPLOAD_ROOT_DIR
)
.
joinpath
(
"{}.epk"
.
format
(
app
.
app_name
))
.
resolve
()
.
as_posix
(
)
package
=
PackageModel
.
query
.
filter
(
PackageModel
.
app
==
app
)
.
one_or_none
()
package
=
PackageModel
.
query
.
filter
(
PackageModel
.
app
==
app
.
id
)
.
one_or_none
()
if
package
:
package
.
app_path
=
epk_path
package
.
app_info
=
app_info
...
...
@@ -103,11 +100,11 @@ class AppResource(object):
db
.
session
.
commit
()
# 新增一条AppLogs
package
=
PackageModel
(
app
=
app
.
app_name
,
app_version
=
app
.
app_version
,
file_path
=
epk_path
,
package_info
=
app_info
,
create_by
=
user
,
create_at
=
datetime
.
now
())
package
=
PackageModel
(
app
=
app
.
app_name
,
app_version
=
app
.
app_version
,
file_path
=
epk_path
,
package_info
=
json
.
dumps
(
app_info
),
create_by
=
user
.
id
,
create_at
=
datetime
.
now
())
db
.
session
.
add
(
package
)
db
.
session
.
commit
()
return
{
'app_name'
:
app
.
app_name
,
'app_path'
:
epk_path
},
ResponseCode
.
HTTP_
NOT_FOUND
return
{
'app_name'
:
app
.
app_name
,
'app_path'
:
epk_path
},
ResponseCode
.
HTTP_
SUCCESS
def
getList
(
self
,
params
,
jwt
):
user
=
UserModel
.
query
.
filter
(
UserModel
.
uuid
==
jwt
.
get
(
'uuid'
))
.
one_or_none
()
...
...
@@ -139,8 +136,6 @@ class AppResource(object):
if
hasattr
(
AppModel
,
p
)
and
params
[
p
]
!=
None
:
temp
[
p
]
=
params
[
p
]
logger
.
info
(
temp
)
result
=
AppModel
.
query
.
filter_by
(
**
temp
)
.
order_by
(
AppModel
.
create_at
.
desc
())
.
paginate
(
params
.
get
(
"page"
,
1
),
params
.
get
(
"pageSize"
,
15
),
error_out
=
False
)
# result = AppModel.query.filter(*filters).order_by(AppModel.create_at.desc()).paginate(params.get('page', 1), params.get('pageSize', 15), error_out=False)
...
...
tools/build_out/views/app.py
View file @
9d898628
...
...
@@ -128,15 +128,13 @@ class AppResource(Resource):
# args = self.parser.parse_args()
try
:
json_payload
=
request
.
json
print
(
"========>"
,
uuid
,
json_payload
)
data
=
getAppSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionGetApp
.
emit
(
uuid
,
data
)
jwt
=
get_jwt_identity
()
result
,
message
=
signalManager
.
actionGetApp
.
emit
(
uuid
,
jwt
)
if
result
:
json_dumps
=
getAppSchema
.
dump
(
result
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
json_dumps
,
msg
=
message
)
return
response_result
(
ResponseCode
.
HTTP_NOT_FOUND
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
result
)
return
response_result
(
message
)
except
Exception
as
e
:
traceback
.
print_exc
()
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
...
...
@@ -149,8 +147,8 @@ class AppResource(Resource):
data
=
putAppSchema
.
load
(
json_payload
)
result
,
message
=
signalManager
.
actionPutApp
.
emit
(
uuid
,
data
)
if
result
:
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
result
,
msg
=
message
)
return
response_result
(
ResponseCode
.
HTTP_NO_CHANGE
,
msg
=
message
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
result
)
return
response_result
(
message
)
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
...
...
@@ -160,12 +158,13 @@ class AppResource(Resource):
def
delete
(
self
,
uuid
):
try
:
json_payload
=
request
.
json
data
=
deleteAppSchema
.
load
(
json_payload
)
print
(
"========>"
,
uuid
,
data
,
json_payload
)
#
data = deleteAppSchema.load(json_payload)
print
(
"========>"
,
uuid
,
json_payload
)
result
,
message
=
signalManager
.
actionDeleteApp
.
emit
(
uuid
)
if
result
:
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
result
,
msg
=
message
)
return
response_result
(
ResponseCode
.
HTTP_NOT_FOUND
,
msg
=
message
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
result
)
return
response_result
(
message
)
except
Exception
as
e
:
traceback
.
print_exc
()
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
tools/frontend/src/api/openapi.js
View file @
9d898628
/*
* @Author: your name
* @Date: 2021-07-15 09:33:39
* @LastEditTime: 2021-07-16 1
0:00:41
* @LastEditTime: 2021-07-16 1
8:28:38
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \evm-store\tools\frontend\src\api\openapi.js
...
...
@@ -40,11 +40,10 @@ export function getApplicationList(params) {
})
}
export
function
rebuildApplication
(
uuid
,
params
)
{
export
function
rebuildApplication
(
uuid
)
{
return
request
({
url
:
`/api/v1/app/
${
uuid
}
`
,
method
:
"
get
"
,
params
method
:
"
get
"
})
}
...
...
tools/frontend/src/views/Application/Index.vue
View file @
9d898628
...
...
@@ -3,15 +3,15 @@
<a-card
:bordered=
"false"
>
<div
class=
"tableList"
>
<div
class=
"tableListForm"
>
<a-form
v-show=
"!expandForm"
layout=
"inline"
:form=
"form"
>
<a-form
v-show=
"!expandForm"
layout=
"inline"
:
model=
"query"
:
form=
"form"
>
<a-row
:gutter=
"
{ md: 8, lg: 24, xl: 48 }">
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"应用名称"
v-decorator=
"['app_name']"
>
<a-form-item
label=
"应用名称"
prop=
"app_name"
v-decorator=
"['app_name']"
>
<a-input
v-model=
"query.app_name"
placeholder=
"请输入"
/>
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"应用类别"
v-decorator=
"['category']"
>
<a-form-item
label=
"应用类别"
prop=
"category"
v-decorator=
"['category']"
>
<a-select
v-model=
"query.category"
placeholder=
"请选择"
...
...
@@ -39,15 +39,15 @@
</a-col>
</a-row>
</a-form>
<a-form
v-show=
"expandForm"
layout=
"inline"
:form=
"form"
>
<a-form
v-show=
"expandForm"
layout=
"inline"
:
model=
"query"
:
form=
"form"
>
<a-row
:gutter=
"
{ md: 8, lg: 24, xl: 48 }">
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"应用名称"
v-decorator=
"['app_name']"
>
<a-form-item
label=
"应用名称"
prop=
"app_name"
v-decorator=
"['app_name']"
>
<a-input
v-model=
"query.app_name"
placeholder=
"请输入"
/>
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"应用类别"
v-decorator=
"['category']"
>
<a-form-item
label=
"应用类别"
prop=
"category"
v-decorator=
"['category']"
>
<a-select
v-model=
"query.category"
placeholder=
"请选择"
...
...
@@ -63,14 +63,14 @@
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"应用版本号"
v-decorator=
"['app_name
']"
>
<a-form-item
label=
"应用版本号"
prop=
"app_version"
v-decorator=
"['app_version
']"
>
<a-input
v-model=
"query.app_version"
placeholder=
"请输入"
/>
</a-form-item>
</a-col>
</a-row>
<a-row
:gutter=
"
{ md: 8, lg: 24, xl: 48 }">
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"创建时间"
v-decorator=
"['create_at']"
>
<a-form-item
label=
"创建时间"
prop=
"create_at"
v-decorator=
"['create_at']"
>
<a-range-picker
v-model=
"query.create_at"
style=
"width: 100%"
...
...
@@ -78,8 +78,8 @@
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"应用尺寸"
v-decorator=
"['app_screen_size']"
>
<a-select
v-model=
"
post
.app_screen_size"
>
<a-form-item
label=
"应用尺寸"
prop=
"app_screen_size"
v-decorator=
"['app_screen_size']"
>
<a-select
v-model=
"
query
.app_screen_size"
>
<a-select-option
v-for=
"item in sizeList"
:key=
"item.value"
...
...
@@ -91,8 +91,8 @@
</a-form-item>
</a-col>
<a-col
:md=
"8"
:sm=
"24"
>
<a-form-item
label=
"适配平台"
v-decorator=
"['app_arch']"
>
<a-select
v-model=
"
post
.app_arch"
>
<a-form-item
label=
"适配平台"
prop=
"app_arch"
v-decorator=
"['app_arch']"
>
<a-select
v-model=
"
query
.app_arch"
>
<a-select-option
v-for=
"item in portList"
:key=
"item.value"
...
...
@@ -402,7 +402,6 @@ export default {
methods
:
{
resetForm
()
{
this
.
$nextTick
(()
=>
{
console
.
log
(
this
.
form
)
this
.
form
.
resetFields
();
})
},
...
...
@@ -444,32 +443,34 @@ export default {
getApplicationList
(
opts
)
.
then
((
res
)
=>
{
console
.
log
(
res
);
message
.
success
(
res
.
msg
);
if
(
res
.
code
==
200
)
{
this
.
tableData
.
list
=
res
.
data
;
this
.
tableData
.
pagination
.
pageSize
=
res
.
pageSize
;
this
.
tableData
.
pagination
.
total
=
res
.
total
;
}
message
.
success
(
res
.
msg
);
})
.
catch
((
err
)
=>
{
message
.
error
(
err
);
message
.
error
(
err
.
msg
);
});
},
rebuildApplication
(
record
)
{
rebuildApplication
(
record
.
uuid
,
this
.
post
)
rebuildApplication
(
record
.
uuid
)
.
then
((
res
)
=>
{
message
.
success
(
res
);
message
.
success
(
res
.
msg
);
})
.
catch
((
err
)
=>
{
message
.
error
(
err
);
message
.
error
(
err
.
msg
);
});
},
deleteApplication
(
record
)
{
deleteApplication
(
record
.
uuid
)
.
then
((
res
)
=>
{
message
.
success
(
res
);
message
.
success
(
res
.
msg
);
this
.
getApplicationList
();
})
.
catch
((
err
)
=>
{
message
.
error
(
err
);
message
.
error
(
err
.
msg
);
});
},
},
...
...
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