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
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
钟尚武
saturn
Commits
d168e2bc
Commit
d168e2bc
authored
Feb 26, 2019
by
zhanglu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/user_list' into 'test'
根据用户名或者用户列表 See merge request
alpha/saturn!24
parents
91040cf2
7f7cb6cc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
4 deletions
+91
-4
cache.py
api/cache/cache.py
+6
-0
urls.py
api/urls.py
+1
-0
topic.py
api/views/topic.py
+24
-2
user.py
api/views/user.py
+46
-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 @
d168e2bc
from
engine.cache
import
RedisWithoutprefixProxy
from
django.conf
import
settings
ins_cache
=
RedisWithoutprefixProxy
(
settings
.
REDIS_GROUP
[
'ins_cache'
])
api/urls.py
View file @
d168e2bc
...
...
@@ -18,5 +18,6 @@ urlpatterns = [
# user
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$'
),
]
api/views/topic.py
View file @
d168e2bc
...
...
@@ -2,14 +2,20 @@ import json
from
api.views.base_view
import
BaseView
from
api.utils.sensitive
import
Sensitive
from
api.cache.cache
import
ins_cache
from
libs.user
import
get_user_by_ids
from
alpha_types.venus
import
ERROR
as
CODES
ins_account_cache
=
"ins_account_cache"
class
CreateTopicForBatch
(
BaseView
):
"""
内部使用,批量建帖
"""
def
post
(
self
,
request
):
user_id
=
request
.
POST
.
get
(
"user_id"
,
0
)
...
...
@@ -58,6 +64,18 @@ class CreateTopicForBatch(BaseView):
item
[
"tag_id"
]
=
tag_id
if
tag_id
else
None
item
[
"is_online"
]
=
is_online
not_exists_ids
=
[]
topic_list
=
[]
for
item
in
topics
:
_id
=
item
.
get
(
"id"
)
exists
=
ins_cache
.
sismember
(
ins_account_cache
,
_id
)
if
exists
:
continue
topic_list
.
append
(
item
)
not_exists_ids
.
append
(
_id
)
# check_info = Sensitive.check(tag_names)
# tags = [tag_name for tag_name, succ in check_info.items() if not succ]
tags
=
tag_names
...
...
@@ -72,7 +90,7 @@ class CreateTopicForBatch(BaseView):
# 更新发帖
# 处理标签,将文本中的标签处理成现有标签
for
item
in
topic
s
:
for
item
in
topic
_list
:
tags
=
item
.
get
(
"tags"
)
or
[]
tags
=
[
tag
.
replace
(
"#"
,
''
)
.
strip
()
for
tag
in
tags
]
content
=
item
[
"content"
]
...
...
@@ -89,11 +107,15 @@ class CreateTopicForBatch(BaseView):
create_err
,
result
=
self
.
call_rpc
(
"venus/community/topic/batch_create_for_inner"
,
topic_list
=
topic
s
topic_list
=
topic
_list
)
if
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
)
...
...
api/views/user.py
View file @
d168e2bc
import
json
import
json
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
):
...
...
@@ -59,3 +62,46 @@ class Validate3PartyAccount(BaseView):
return
self
.
error
(
err
)
data
=
{
account_id
:
_data
.
get
(
account_id
,
False
)
for
account_id
in
account_ids
}
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 @
d168e2bc
...
...
@@ -46,6 +46,19 @@ def get_user_by_ids(user_ids):
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
):
user_info
=
get_user_by_request
(
request
)
if
not
user_info
:
...
...
settings/base.py
View file @
d168e2bc
...
...
@@ -68,8 +68,7 @@ QINIU_FACE_BUCKET = 'alpha-s'
FACE_TOP_N_CNT
=
3
REDIS_GROUP
=
{
'desc_cache'
:
{
'host'
:
'127.0.0.1'
,
'port'
:
6379
,
'db'
:
1
},
'qq_cache'
:
{
'host'
:
'127.0.0.1'
,
'port'
:
6379
,
'db'
:
1
},
'ins_cache'
:
{
'host'
:
'127.0.0.1'
,
'port'
:
6379
,
'db'
:
1
},
}
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