Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
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
钟尚武
sun
Commits
14b98b9d
Commit
14b98b9d
authored
Mar 13, 2019
by
王浩
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'haow/dev' into 'dev'
Haow/dev See merge request
alpha/sun!97
parents
a26ed04c
d08b6730
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
5 deletions
+147
-5
channel_build.py
api/channel_build.py
+7
-1
pictorial.py
api/pictorial.py
+107
-0
search.py
api/search.py
+14
-2
tasks.py
api/tasks/tasks.py
+8
-2
urls.py
api/urls.py
+11
-0
No files found.
api/channel_build.py
View file @
14b98b9d
...
...
@@ -145,6 +145,12 @@ class Channel(APIView):
if
not
all
([
channel_name
,
url_name
,
auto_pack
,
channel_type
]):
error_logger
.
error
(
u'参数不完整'
)
return
self
.
write_fail
(
code
=
ERROR
.
ARG_MISS
,
message
=
'参数不完整'
)
if
channel_id
:
channel
=
self
.
rpc
[
'venus/sun/channel_build/channel/get'
](
id
=
channel_id
)
.
unwrap
()
else
:
channel
=
{}
data
=
dict
()
if
channel_name
:
data
.
update
({
'name'
:
channel_name
})
...
...
@@ -162,7 +168,7 @@ class Channel(APIView):
error_logger
.
error
(
'操作失败
%
s'
,
e
)
return
self
.
write_fail
(
message
=
'路径名不能重复'
,
code
=-
1
)
version
=
resp
.
get
(
'version'
,
''
)
if
version
and
not
channel_id
:
if
version
and
channel
.
get
(
'url_name'
)
!=
url_name
:
channel_build_one
.
delay
(
version
,
url_name
)
return
self
.
write_success
(
message
=
'操作成功'
,
data
=
{})
...
...
api/pictorial.py
0 → 100644
View file @
14b98b9d
import
json
from
utils.base
import
APIView
from
utils.logger
import
error_logger
class
PictorialListView
(
APIView
):
def
get
(
self
,
request
):
star_id
=
request
.
GET
.
get
(
'star_id'
)
user_id
=
request
.
GET
.
get
(
'user_id'
)
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filters
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
if
star_id
:
filters
.
update
({
'star_id'
:
star_id
})
if
user_id
:
filters
.
update
({
'user_id'
:
user_id
})
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/list'
](
filters
=
filters
,
offset
=
(
offset
-
1
)
*
limit
,
limit
=
limit
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取画报列表失败
%
s'
,
e
)
raise
return
data
def
post
(
self
,
request
):
ids
=
json
.
loads
(
request
.
POST
.
get
(
'ids'
,
'[]'
))
updates
=
json
.
loads
(
request
.
POST
.
get
(
'updates'
,
'{}'
))
try
:
self
.
rpc
[
'venus/sun/pictorial/batch/update'
](
updates
=
updates
,
ids
=
ids
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'批量更新失败
%
s'
,
e
)
raise
return
{
"message"
:
"更新成功"
}
class
PictorialUpdateOrCreate
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
)
.
split
(
':'
)[
0
]
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/get'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取
%
s用户信息失败
%
s'
%
(
id
,
e
))
raise
return
data
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
)
star_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'star'
,
'[]'
))))
pictorial_user_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'pictorial_users'
,
'[]'
))))
data
=
{
'name'
:
request
.
POST
.
get
(
'name'
,
''
),
'description'
:
request
.
POST
.
get
(
'description'
,
''
),
'creator_id'
:
request
.
POST
.
get
(
'user'
,
''
)
.
split
(
':'
)[
0
],
'celebrity_ids'
:
star_ids
,
'is_online'
:
int
(
request
.
POST
.
get
(
'is_online'
,
0
)),
'is_recommend'
:
int
(
request
.
POST
.
get
(
'is_recommend'
,
0
)),
'pictorial_user_ids'
:
pictorial_user_ids
,
'icon'
:
request
.
POST
.
get
(
'icon'
,
''
)[:
-
2
]
}
try
:
self
.
rpc
[
'venus/sun/pictorial/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
s用户信息失败
%
s'
%
(
id
,
e
))
raise
return
{
'message'
:
'更新成功'
}
class
PictorialRelatedUser
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
)
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
count
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filters
=
{
'pictorial_id'
:
id
}
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/user/list'
](
filters
=
filters
,
offset
=
(
offset
-
1
)
*
count
,
limit
=
count
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取画报用户信息失败
%
s'
,
e
)
raise
return
data
class
PictorialRelatedUserGET
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
,
''
)
.
split
(
':'
)[
0
]
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/user/get'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取画报用户信息失败
%
s'
,
e
)
raise
return
[
data
,
]
def
post
(
self
,
request
):
pictorial_id
=
request
.
POST
.
get
(
'pictorial_id'
)
user_id
=
request
.
POST
.
get
(
'user_id'
)
data
=
{
'role_id'
:
request
.
POST
.
get
(
'original_pictorial_identify'
),
}
try
:
self
.
rpc
[
'venus/sun/pictorial/user/edit'
](
id
=
pictorial_id
,
user_id
=
user_id
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑画报用户
%
s信息失败
%
s'
%
(
user_id
,
e
))
raise
return
\ No newline at end of file
api/search.py
View file @
14b98b9d
...
...
@@ -103,4 +103,17 @@ class TagTypeSearchView(APIView):
raise
e
return
{
'data'
:
[
'{id}:{name}'
.
format
(
id
=
search_data
[
'id'
],
name
=
search_data
[
'name'
])
for
search_data
in
data
]
}
\ No newline at end of file
}
class
PictorialSearchView
(
APIView
):
def
get
(
self
,
request
):
name
=
request
.
GET
.
get
(
'name'
)
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/search'
](
name
=
name
)
.
unwrap
()
except
Exception
as
e
:
raise
e
return
{
'data'
:
[
'{id}:{name}'
.
format
(
id
=
search_data
[
'id'
],
name
=
search_data
[
'name'
])
for
search_data
in
data
]
}
api/tasks/tasks.py
View file @
14b98b9d
...
...
@@ -34,8 +34,14 @@ def version_release_task(packed_channels, version_id=None, version=None): # 一
@shared_task
def
channel_build_one
(
version
=
None
,
channel
=
None
,
data
=
None
):
url
=
ChannelPackage
.
apk_url
(
''
,
version
)
r
=
requests
.
get
(
url
,
stream
=
True
)
info_logger
.
debug
(
url
)
for
_
in
range
(
5
):
try
:
r
=
requests
.
get
(
url
,
stream
=
True
)
info_logger
.
debug
(
url
)
if
r
.
content
:
break
except
:
info_logger
.
debug
(
'第
%
s下载失败
%
s:'
,
_
,
url
)
chn_pkg
=
ChannelPackage
(
r
.
content
,
version
)
build_one_channel
(
chn_pkg
,
channel
)
...
...
api/urls.py
View file @
14b98b9d
...
...
@@ -21,6 +21,7 @@ from .face_star import *
from
.advertise
import
*
from
.channel_build
import
*
from
.commons
import
*
from
.pictorial
import
*
urlpatterns
=
[
# 登陆,注销相关
...
...
@@ -128,6 +129,15 @@ urlpatterns = [
url
(
r'^channel_build/version/create'
,
VersionCreate
.
as_view
()),
url
(
r'^suggestion/list$'
,
SuggestionListView
.
as_view
())
# 画报相关
url
(
r'^pictorial/list$'
,
PictorialListView
.
as_view
()),
url
(
r'^pictorial/list/update$'
,
PictorialListView
.
as_view
()),
url
(
r'^pictorial/get$'
,
PictorialUpdateOrCreate
.
as_view
()),
url
(
r'^pictorial/create$'
,
PictorialUpdateOrCreate
.
as_view
()),
url
(
r'^pictorial/user/list$'
,
PictorialRelatedUser
.
as_view
()),
url
(
r'^pictorial/user/get$'
,
PictorialRelatedUserGET
.
as_view
()),
url
(
r'^pictorial/user/edit_group_identify'
,
PictorialRelatedUserGET
.
as_view
()),
]
search_urlpatterns
=
[
...
...
@@ -139,6 +149,7 @@ search_urlpatterns = [
url
(
r'search/city$'
,
CitySearchView
.
as_view
()),
url
(
r'search/topic$'
,
TopicSearchView
.
as_view
()),
url
(
r'search/tagtype$'
,
TagTypeSearchView
.
as_view
()),
url
(
r'search/pictorial$'
,
PictorialSearchView
.
as_view
()),
]
common_urlpatterns
=
[
...
...
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