Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
saturn
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
1
Merge Requests
1
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
alpha
saturn
Commits
0b51eaa4
Commit
0b51eaa4
authored
Feb 27, 2019
by
zhanglu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'master'
Test See merge request
!28
parents
34ec6714
a5fe2768
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
129 additions
and
14 deletions
+129
-14
cache.py
api/cache/cache.py
+6
-0
urls.py
api/urls.py
+2
-0
tag.py
api/views/tag.py
+10
-8
topic.py
api/views/topic.py
+33
-4
user.py
api/views/user.py
+64
-0
user.py
libs/user.py
+13
-0
base.py
settings/base.py
+1
-2
No files found.
api/cache/cache.py
0 → 100644
View file @
0b51eaa4
from
engine.cache
import
RedisWithoutprefixProxy
from
django.conf
import
settings
ins_cache
=
RedisWithoutprefixProxy
(
settings
.
REDIS_GROUP
[
'ins_cache'
])
api/urls.py
View file @
0b51eaa4
...
@@ -18,5 +18,7 @@ urlpatterns = [
...
@@ -18,5 +18,7 @@ urlpatterns = [
# user
# user
url
(
r'^v1/user/shadow/list$'
,
user
.
ShadowUserList
.
as_view
(),
name
=
'create_tag_for_batch'
),
url
(
r'^v1/user/shadow/list$'
,
user
.
ShadowUserList
.
as_view
(),
name
=
'create_tag_for_batch'
),
url
(
r'^v1/validate_3party_or_account$'
,
user
.
Validate3PartyOrAccount
.
as_view
(),
name
=
'validate_3party_or_account'
),
url
(
r'^v1/validate_3party_account$'
,
user
.
Validate3PartyAccount
.
as_view
(),
name
=
'validate_3party_account$'
),
url
(
r'^v1/validate_3party_account$'
,
user
.
Validate3PartyAccount
.
as_view
(),
name
=
'validate_3party_account$'
),
url
(
r'^v1/user/batch_create_shadow_user$'
,
user
.
BatchCreateShadowUser
.
as_view
(),
name
=
'batch_create_shadow_user$'
),
]
]
api/views/tag.py
View file @
0b51eaa4
...
@@ -10,16 +10,18 @@ class CreateTagForBatch(BaseView):
...
@@ -10,16 +10,18 @@ class CreateTagForBatch(BaseView):
"""
"""
def
post
(
self
,
request
):
def
post
(
self
,
request
):
tag_list
=
json
.
loads
(
request
.
POST
.
get
(
"tags"
,
'[]'
))
tag_list
=
json
.
loads
(
request
.
POST
.
get
(
"tags"
,
'[]'
))
need_check
=
request
.
POST
.
get
(
'need_check'
,
0
)
tags
=
[]
tags
=
[]
# 敏感词检测,获取可用的帖子
if
need_check
:
# check_info = Sensitive.check([item["name"] for item in tag_list if item.get("name")])
# 敏感词检测,获取可用的帖子
# for tag in tag_list:
check_info
=
Sensitive
.
check
([
item
[
"name"
]
for
item
in
tag_list
if
item
.
get
(
"name"
)])
# succ = check_info.get(tag.get("name")) if tag.get("name") else True
for
tag
in
tag_list
:
# if not succ:
succ
=
check_info
.
get
(
tag
.
get
(
"name"
))
if
tag
.
get
(
"name"
)
else
True
# tags.append(tag)
if
not
succ
:
tags
=
tag_list
tags
.
append
(
tag
)
else
:
tags
=
tag_list
error
,
data
=
self
.
call_rpc
(
'venus/community/tag/batch_create_not_classify'
,
data
=
tags
)
error
,
data
=
self
.
call_rpc
(
'venus/community/tag/batch_create_not_classify'
,
data
=
tags
)
if
error
:
if
error
:
...
...
api/views/topic.py
View file @
0b51eaa4
...
@@ -2,20 +2,28 @@ import json
...
@@ -2,20 +2,28 @@ import json
from
api.views.base_view
import
BaseView
from
api.views.base_view
import
BaseView
from
api.utils.sensitive
import
Sensitive
from
api.utils.sensitive
import
Sensitive
from
api.cache.cache
import
ins_cache
from
libs.user
import
get_user_by_ids
from
libs.user
import
get_user_by_ids
from
alpha_types.venus
import
ERROR
as
CODES
from
alpha_types.venus
import
ERROR
as
CODES
from
alpha_types.venus
import
GRAP_PLATFORM
ins_account_cache
=
"ins_account_cache"
class
CreateTopicForBatch
(
BaseView
):
class
CreateTopicForBatch
(
BaseView
):
"""
"""
内部使用,批量建帖
内部使用,批量建帖
"""
"""
def
post
(
self
,
request
):
def
post
(
self
,
request
):
user_id
=
request
.
POST
.
get
(
"user_id"
,
0
)
user_id
=
request
.
POST
.
get
(
"user_id"
,
0
)
card_level
=
request
.
POST
.
get
(
"card_level"
,
0
)
card_level
=
request
.
POST
.
get
(
"card_level"
,
0
)
tag_id
=
request
.
POST
.
get
(
"tag_id"
)
tag_id
=
request
.
POST
.
get
(
"tag_id"
)
is_online
=
request
.
POST
.
get
(
"is_online"
,
0
)
is_online
=
request
.
POST
.
get
(
"is_online"
,
0
)
platform
=
request
.
POST
.
get
(
"platform"
)
topic_list
=
json
.
loads
(
request
.
POST
.
get
(
"topic_list"
,
'[]'
))
topic_list
=
json
.
loads
(
request
.
POST
.
get
(
"topic_list"
,
'[]'
))
if
not
user_id
:
if
not
user_id
:
...
@@ -55,9 +63,26 @@ class CreateTopicForBatch(BaseView):
...
@@ -55,9 +63,26 @@ class CreateTopicForBatch(BaseView):
tag_names
.
extend
([
tag
.
replace
(
"#"
,
''
)
.
strip
()
for
tag
in
tags
])
tag_names
.
extend
([
tag
.
replace
(
"#"
,
''
)
.
strip
()
for
tag
in
tags
])
item
[
"user_id"
]
=
user_id
item
[
"user_id"
]
=
user_id
item
[
"card_level"
]
=
card_level
item
[
"card_level"
]
=
card_level
item
[
"tag_id"
]
=
tag_id
item
[
"tag_id"
]
=
tag_id
if
tag_id
else
None
item
[
"is_online"
]
=
is_online
item
[
"is_online"
]
=
is_online
not_exists_ids
=
[]
topic_list
=
[]
if
platform
==
GRAP_PLATFORM
.
INS
:
for
item
in
topics
:
_id
=
item
.
get
(
"id"
)
if
not
_id
:
continue
exists
=
ins_cache
.
sismember
(
ins_account_cache
,
_id
)
if
exists
:
continue
topic_list
.
append
(
item
)
not_exists_ids
.
append
(
_id
)
else
:
topic_list
=
topics
# check_info = Sensitive.check(tag_names)
# check_info = Sensitive.check(tag_names)
# tags = [tag_name for tag_name, succ in check_info.items() if not succ]
# tags = [tag_name for tag_name, succ in check_info.items() if not succ]
tags
=
tag_names
tags
=
tag_names
...
@@ -65,14 +90,14 @@ class CreateTopicForBatch(BaseView):
...
@@ -65,14 +90,14 @@ class CreateTopicForBatch(BaseView):
# 先创建标签
# 先创建标签
_tag_error
,
_tag_data
=
self
.
call_rpc
(
_tag_error
,
_tag_data
=
self
.
call_rpc
(
"venus/community/tag/batch_create_tag_by_name"
,
"venus/community/tag/batch_create_tag_by_name"
,
tag_names
=
tags
tag_names
=
tags
,
is_own
=
1
)
)
if
_tag_error
:
if
_tag_error
:
return
self
.
error
(
_tag_error
)
return
self
.
error
(
_tag_error
)
# 更新发帖
# 更新发帖
# 处理标签,将文本中的标签处理成现有标签
# 处理标签,将文本中的标签处理成现有标签
for
item
in
topic
s
:
for
item
in
topic
_list
:
tags
=
item
.
get
(
"tags"
)
or
[]
tags
=
item
.
get
(
"tags"
)
or
[]
tags
=
[
tag
.
replace
(
"#"
,
''
)
.
strip
()
for
tag
in
tags
]
tags
=
[
tag
.
replace
(
"#"
,
''
)
.
strip
()
for
tag
in
tags
]
content
=
item
[
"content"
]
content
=
item
[
"content"
]
...
@@ -89,11 +114,15 @@ class CreateTopicForBatch(BaseView):
...
@@ -89,11 +114,15 @@ class CreateTopicForBatch(BaseView):
create_err
,
result
=
self
.
call_rpc
(
create_err
,
result
=
self
.
call_rpc
(
"venus/community/topic/batch_create_for_inner"
,
"venus/community/topic/batch_create_for_inner"
,
topic_list
=
topic
s
topic_list
=
topic
_list
)
)
if
create_err
:
if
create_err
:
return
self
.
error
(
create_err
)
return
self
.
error
(
create_err
)
# 将已经跑了的数据添加到缓存
if
not_exists_ids
:
ins_cache
.
sadd
(
ins_account_cache
,
*
not_exists_ids
)
return
self
.
ok
(
data
=
result
)
return
self
.
ok
(
data
=
result
)
...
...
api/views/user.py
View file @
0b51eaa4
import
json
import
json
import
json
from
api.views.base_view
import
BaseView
,
get_offset_count
from
api.views.base_view
import
BaseView
,
get_offset_count
from
libs.user
import
get_user_by_names
from
alpha_types.venus.error
import
ERROR
as
CODES
class
UpdateGraspStatus
(
BaseView
):
class
UpdateGraspStatus
(
BaseView
):
...
@@ -59,3 +62,64 @@ class Validate3PartyAccount(BaseView):
...
@@ -59,3 +62,64 @@ class Validate3PartyAccount(BaseView):
return
self
.
error
(
err
)
return
self
.
error
(
err
)
data
=
{
account_id
:
_data
.
get
(
account_id
,
False
)
for
account_id
in
account_ids
}
data
=
{
account_id
:
_data
.
get
(
account_id
,
False
)
for
account_id
in
account_ids
}
return
self
.
ok
(
data
=
data
)
return
self
.
ok
(
data
=
data
)
class
BatchCreateShadowUser
(
BaseView
):
"""
批量创建马甲用户
"""
def
post
(
self
,
request
):
request_data
=
json
.
loads
(
request
.
POST
.
get
(
'ins_data'
,
'[]'
))
print
(
request_data
)
err
,
_data
=
self
.
call_rpc
(
"venus/community/user/batch_create_shadow_user"
,
data
=
request_data
)
if
err
:
return
self
.
error
(
err
)
return
self
.
ok
(
data
=
_data
)
class
Validate3PartyOrAccount
(
BaseView
):
"""判断用户是否在三方账号或者alpha账号体系中。"""
def
post
(
self
,
request
):
try
:
names
=
json
.
loads
(
request
.
POST
.
get
(
"names"
,
"[]"
))
except
:
names
=
[]
if
not
names
:
return
self
.
error
(
self
.
get_ErrorInfo
(
CODES
.
PARAMS_INCOMPLETE
))
user_list
=
get_user_by_names
(
names
=
names
)
account_users
=
{}
for
name
in
names
:
for
_
,
user
in
user_list
.
items
():
if
user
[
"nick_name"
]
!=
name
:
continue
account_users
[
name
]
=
True
break
users
=
{
name
:
account_users
.
get
(
name
,
False
)
for
name
in
names
}
err
,
_3party_account
=
self
.
call_rpc
(
"venus/community/user/validate_has_bind_3party_account"
,
bind_account_ids
=
names
)
if
err
:
return
self
.
error
(
err
)
data
=
{
name
:
_3party_account
.
get
(
name
,
False
)
or
users
.
get
(
name
,
False
)
for
name
in
names
}
return
self
.
ok
(
data
=
{
"users"
:
data
,
})
libs/user.py
View file @
0b51eaa4
...
@@ -46,6 +46,19 @@ def get_user_by_ids(user_ids):
...
@@ -46,6 +46,19 @@ def get_user_by_ids(user_ids):
return
users_info
return
users_info
def
get_user_by_names
(
names
):
"""获取用户信息"""
try
:
rpc
=
get_current_rpc_invoker
()
users_info
=
rpc
[
"venus/account/user/userinfo_list_by_name"
](
names
=
names
)
.
unwrap
()
except
Exception
as
e
:
raise
Exception
(
e
)
return
[]
return
users_info
def
auth
(
request
):
def
auth
(
request
):
user_info
=
get_user_by_request
(
request
)
user_info
=
get_user_by_request
(
request
)
if
not
user_info
:
if
not
user_info
:
...
...
settings/base.py
View file @
0b51eaa4
...
@@ -68,8 +68,7 @@ QINIU_FACE_BUCKET = 'alpha-s'
...
@@ -68,8 +68,7 @@ QINIU_FACE_BUCKET = 'alpha-s'
FACE_TOP_N_CNT
=
3
FACE_TOP_N_CNT
=
3
REDIS_GROUP
=
{
REDIS_GROUP
=
{
'desc_cache'
:
{
'host'
:
'127.0.0.1'
,
'port'
:
6379
,
'db'
:
1
},
'ins_cache'
:
{
'host'
:
'127.0.0.1'
,
'port'
:
6379
,
'db'
:
1
},
'qq_cache'
:
{
'host'
:
'127.0.0.1'
,
'port'
:
6379
,
'db'
:
1
},
}
}
OPERTATION_POSITION
=
3
# 运营卡片位置
OPERTATION_POSITION
=
3
# 运营卡片位置
...
...
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