Commit b3f07036 authored by 李小芳's avatar 李小芳

Merge branch 'hkx/feature/rpc-method-header' into 'test'

Hkx/feature/rpc method header

See merge request !17
parents 45321f83 1877d5da
......@@ -37,7 +37,7 @@ RUN apk add --no-cache --virtual .build-deps \
\
# 取消ssh第一次链接的确认
&& echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config \
&& apk add --no-cache mariadb-connector-c-dev libxml2-dev libxslt-dev librdkafka-dev \
&& apk add --no-cache build-base mariadb-connector-c-dev libxml2-dev libxslt-dev librdkafka-dev libexecinfo libexecinfo-dev snappy snappy-dev \
&& pip install --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r /tmp/requirements.txt \
&& mkdir -p /data/log/vest/app
......
......@@ -5,35 +5,52 @@ import logging
from libs.cache import redis_client
import json
from moment.views.send_email import send_email_tome
import datetime
def click(card_info):
try:
rpc_invoker = get_rpc_invoker()
rpc_invoker['qa/irrigation/create_answer_vote'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id']).unwrap()
key = "auto_vest_one_user_action:" + str(card_info['card_id'])
redis_data = redis_client.get(key)
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
key = "auto_vest_one_user_action_answer:" + str(card_info['card_id'])
redis_data = redis_client.hget(key, str_today)
if redis_data:
redis_data = json.loads(redis_data)
redis_data = json.loads(str(redis_data, encoding="utf8"))
click_num = int(redis_data.get("click")) + 1
redis_data['click'] = click_num
redis_client.set(key, json.dumps(redis_data))
redis_client.hset(key, str_today, json.dumps(redis_data))
else:
##代表还没有存储或者是已经过去一天了 需要清掉数据 从新的一天开始
redis_client.delete(key)
redis_data = {"click": 1, "follow": 0, "comment": 0}
redis_client.set(key, json.dumps(redis_data))
redis_client.expire(key, time=24 * 60 * 60)
redis_client.hset(key, str_today, json.dumps(redis_data))
logging.info("get redis_data:%s" % redis_data)
logging.info("get action:click,card_id:%s,redis_data:%s" % (card_info['card_id'], redis_data))
click_num = redis_data["click"]
values = list(redis_data.values())
s = [True for i in values if i > 10]
if len(s) > 0:
send_email_tome(str(redis_data) + str(card_info))
if click_num > 12:
logging.info("今天已经消费到最大次数了,不能再消费")
return True, False
else:
rpc_invoker = get_rpc_invoker()
try:
status = rpc_invoker['qa/irrigation/create_answer_vote'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id']).unwrap()
return True
logging.info("get_card_info:%s,create_answer_vote:%s" % (card_info, status))
error = status.get('error', 1)
if error == 0:
return True, True
else:
send_email_tome(str(card_info) + str(status))
return False, True
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False, True
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
......@@ -62,6 +62,7 @@ def auto_comment_user(card_info, after_day=False):
if card_info['type'] == "get_write_answer_userinfo":
repeat_time = 0
card_info['have_comment_number'] = 0
get_time, time_region = get_content_time_by_create_time(create_time, content_level,
action_type="comment",
after_day=after_day,
......
......@@ -5,36 +5,160 @@ import logging
from libs.cache import redis_client
import json
from moment.views.send_email import send_email_tome
import datetime
from moment.views.process_time import get_vest_userid_and_comment
def comment(card_info):
"""
在这里需要判断是帖子下发评论还是问答还是日记下发
:param card_info:
:return:
"""
try:
rpc_invoker = get_rpc_invoker()
rpc_invoker['qa/irrigation/create_answer_reply'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id'],
content=card_info['comment_content']).unwrap()
####
key = "auto_vest_one_user_action:" + str(card_info['card_id'])
redis_data = redis_client.get(key)
if redis_data:
redis_data = json.loads(redis_data)
click_num = int(redis_data.get("comment")) + 1
redis_data['comment'] = click_num
redis_client.set(key, json.dumps(redis_data))
if card_info['card_status'] == 'tractate':
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
key = "auto_vest_one_user_action_tractate:" + str(card_info['card_id'])
redis_data = redis_client.hget(key, str_today)
if redis_data:
redis_data = json.loads(str(redis_data, encoding="utf8"))
click_num = int(redis_data.get("comment")) + 1
redis_data['comment'] = click_num
redis_client.hset(key, str_today, json.dumps(redis_data))
else:
##代表还没有存储或者是已经过去一天了 需要清掉数据 从新的一天开始
redis_client.delete(key)
redis_data = {"comment": 1}
redis_client.hset(key, str_today, json.dumps(redis_data))
logging.info("get action:comment,card_id:%s,redis_data:%s" % (card_info['card_id'], redis_data))
comment_num = redis_data["comment"]
if comment_num > 12:
logging.info("今天已经消费到最大次数了,不能再消费")
else:
try:
rpc_invoker = get_rpc_invoker()
status = rpc_invoker['qa/irrigation/create_answer_reply'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id'],
content=card_info[
'comment_content']).unwrap()
logging.info("get_card_info:%s,have_answer_reply:%s" % (card_info, status))
error = status.get('error', 1)
if error == 0 and comment_num <= 11:
return True, True
elif error == 0 and comment_num > 11:
return True, False
else:
send_email_tome(str(card_info) + str(status))
return False, False
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False, False
elif card_info['card_status'] == 'diary':
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
key = "auto_vest_one_user_action_diary:" + str(card_info['card_id'])
redis_data = redis_client.hget(key, str_today)
if redis_data:
redis_data = json.loads(str(redis_data, encoding="utf8"))
click_num = int(redis_data.get("comment")) + 1
redis_data['comment'] = click_num
redis_client.hset(key, str_today, json.dumps(redis_data))
else:
redis_client.delete(key)
redis_data = {"comment": 1}
redis_client.hset(key, str_today, json.dumps(redis_data))
logging.info("get action:comment,card_id:%s,redis_data:%s" % (card_info['card_id'], redis_data))
comment_num = redis_data["comment"]
if comment_num > 12:
logging.info("今天已经消费到最大次数了,不能再消费")
else:
try:
rpc_invoker = get_rpc_invoker()
status = rpc_invoker['qa/irrigation/create_answer_reply'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id'],
content=card_info[
'comment_content']).unwrap()
logging.info("get_card_info:%s,have_answer_reply:%s" % (card_info, status))
error = status.get('error', 1)
if error == 0:
return True
else:
send_email_tome(str(card_info) + str(status))
return False
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
else:
redis_data = {"click": 0, "follow": 0, "comment": 1}
redis_client.set(key, json.dumps(redis_data))
redis_client.expire(key, time=24 * 60 * 60)
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
key = "auto_vest_one_user_action_answer:" + str(card_info['card_id'])
redis_data = redis_client.hget(key, str_today)
if redis_data:
redis_data = json.loads(str(redis_data, encoding="utf8"))
click_num = int(redis_data.get("comment")) + 1
redis_data['comment'] = click_num
redis_client.hset(key, str_today, json.dumps(redis_data))
else:
redis_client.delete(key)
redis_data = {"click": 0, "follow": 0, "comment": 1}
redis_client.hset(key, str_today, json.dumps(redis_data))
logging.info("get action:comment,card_id:%s,redis_data:%s" % (card_info['card_id'], redis_data))
comment_num = redis_data["comment"]
###判断一下如果评论为空就重新拿一个
if not card_info['comment_content']:
comment = get_vest_userid_and_comment(need_comment_num=1, tag_names=card_info['tag_names'])[0]
card_info['comment_content'] = comment
logging.info("get redis_data:%s" % redis_data)
##在这里加一个判断 如果当前的评论的user_id和评论内容已经在这个评论下了就不再下发给同一个回答ID
else:
key = 'have_reply_answer_comment:' + str(card_info['card_id'])
redis_data = redis_client.hget(key, card_info['current_user_id'])
if redis_data:
datas = json.loads(redis_data, encoding="utf-8")
if card_info['comment_content'] in datas:
logging.info("当前评论和当前的用户已经存在了")
pass
else:
datas.append(card_info['comment_content'])
redis_client.hset(key, card_info['current_user_id'], json.dumps(datas))
else:
conent = [card_info['comment_content']]
redis_client.hset(key, card_info['current_user_id'], json.dumps(conent))
values = list(redis_data.values())
s = [True for i in values if i > 10]
if len(s) > 0:
send_email_tome(str(redis_data) + str(card_info))
if comment_num > 12:
logging.info("今天已经消费到最大次数了,不能再消费")
return True, False
return True
else:
rpc_invoker = get_rpc_invoker()
try:
status = rpc_invoker['qa/irrigation/create_answer_reply'](user_id=card_info['current_user_id'],
answer_id=card_info['card_id'],
content=card_info[
'comment_content']).unwrap()
logging.info("get_card_info:%s,have_answer_reply:%s" % (card_info, status))
error = status.get('error', 1)
if error == 0:
return True, True
else:
send_email_tome(str(card_info) + str(status))
return False, True
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False, True
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
......@@ -93,6 +93,7 @@ def auto_follow_user(card_info, after_day=False):
card_info['current_push_time'] = card_info['all_push_time'][0]
save_data_to_kafka(card_info) # 存储数据
logging.info("get-------follow---------------card_info:%s" % card_info)
except:
logging_exception()
......
......@@ -5,34 +5,50 @@ import logging
from libs.cache import redis_client
import json
from moment.views.send_email import send_email_tome
import datetime
def follow(card_info):
try:
rpc_invoker = get_rpc_invoker()
rpc_invoker['api/irrigation/user_add_follow'](follow_user_id=card_info['current_user_id'],
followed_user_id=card_info['card_user_id']).unwrap()
key = "auto_vest_one_user_action:" + str(card_info['card_id'])
redis_data = redis_client.get(key)
today = datetime.datetime.now()
str_today = str(today.year) + str(today.month) + str(today.day)
key = "auto_vest_one_user_action_answer:" + str(card_info['card_id'])
redis_data = redis_client.hget(key, str_today)
if redis_data:
redis_data = json.loads(redis_data)
redis_data = json.loads(str(redis_data, encoding="utf8"))
click_num = int(redis_data.get("follow")) + 1
redis_data['follow'] = click_num
redis_client.set(key, json.dumps(redis_data))
redis_client.hset(key, str_today, json.dumps(redis_data))
else:
redis_client.delete(key)
redis_data = {"click": 0, "follow": 1, "comment": 0}
redis_client.set(key, json.dumps(redis_data))
redis_client.expire(key, time=24 * 60 * 60)
redis_client.hset(key, str_today, json.dumps(redis_data))
logging.info("get action:follow,card_id:%s,redis_data:%s" % (card_info['card_id'], redis_data))
follow_num = redis_data["follow"]
logging.info("get redis_data:%s" % redis_data)
values = list(redis_data.values())
s = [True for i in values if i > 10]
if len(s) > 0:
send_email_tome(str(redis_data) + str(card_info))
if follow_num > 11:
logging.info("今天已经消费到最大次数了,不能再消费")
return True, False
else:
rpc_invoker = get_rpc_invoker()
try:
status = rpc_invoker['api/irrigation/user_add_follow'](follow_user_id=card_info['current_user_id'],
followed_user_id=card_info[
'card_user_id']).unwrap()
logging.info("get_card_info:%s,user_add_follow:%s" % (card_info, status))
return True
error = status.get('error', 1)
if error == 0:
return True, True
else:
send_email_tome(str(card_info) + str(status))
return False, True
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False, True
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
return False, False
......@@ -19,110 +19,149 @@ from comment.views.comment_fun import comment
from follow.views.follow_fun import follow
from libs.cache import redis_client
from kafka.structs import TopicPartition
from moment.views.process_time import judge_offset_partition_have_consum
def kafka_consum(topic_name=None):
topic_name = settings.KAFKA_TOPIC_NAME if not topic_name else topic_name
consumser_obj = KafkaConsumer(topic_name, bootstrap_servers=settings.KAFKA_BROKER_LIST, enable_auto_commit=True,
auto_commit_interval_ms=1, group_id="vest")
auto_commit_interval_ms=1, group_id="vest", auto_offset_reset='earliest')
consumser_obj.subscribe([topic_name, ])
try:
redis_topic_partition_name = "vest:topic_name:" + str(topic_name)
# redis_topic_partition_name = "vest:topic_name:" + str(topic_name)
# topic_partition_info = redis_client.hgetall(redis_topic_partition_name)
# for partition_id in topic_partition_info:
# print (int(partition_id.decode()),topic_name)
# consumser_obj.seek(partition=TopicPartition(topic_name,int(partition_id.decode())),offset=int(topic_partition_info[partition_id]))
while True:
begin = time.time()
msg_dict = consumser_obj.poll(timeout_ms=100, max_records=30)
for msg_key in msg_dict:
consume_msg = msg_dict[msg_key]
for msg in consume_msg:
card_info = json.loads(msg.value)
msg_dict = consumser_obj.poll(timeout_ms=100, max_records=50)
for msg_value in msg_dict.values():
for msg in msg_value:
card_info = json.loads(str(msg.value, encoding="utf8"))
if card_info['card_type'] == "auto_vest":
logging.info("消费到新数据了[%s,%s,%s,%s],get card_info:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key), card_info))
redis_client.hset(redis_topic_partition_name, msg.partition, msg.offset)
# 代表当天数据
current_push_time = card_info['current_push_time']
create_time = card_info['create_time']
nowtime = datetime.datetime.now()
push_time_date = datetime.datetime.strptime(current_push_time, '%Y-%m-%d %H:%M:%S')
if push_time_date <= nowtime: # push_time已经到时间了 需要去下发
# 判断如果当前的push_time 和当前的创建时间一样 需要给push_time下发真的push时间
if current_push_time == create_time:
if card_info['action_type'] == "comment":
auto_comment_user(card_info, after_day=True)
elif card_info['action_type'] == "click":
auto_click_user(card_info, after_day=True)
elif card_info['action_type'] == "follow":
auto_follow_user(card_info, after_day=True)
###在这里去判断一下当前的partition和offset是否已经消费过了 如果已经消费了需要直接去掉数据
bol_consum = judge_offset_partition_have_consum(card_info=card_info, offset=msg.offset,
partition=msg.partition)
if bol_consum:
logging.info("消费到新数据了[%s,%s,%s,%s],get card_info:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key), card_info))
# 如果没有代表是之前的老的数据
if 'card_status' not in card_info:
card_info['card_status'] = 'answer'
current_push_time = card_info['current_push_time']
create_time = card_info['create_time']
nowtime = datetime.datetime.now()
push_time_date = datetime.datetime.strptime(current_push_time, '%Y-%m-%d %H:%M:%S')
if push_time_date <= nowtime: # push_time已经到时间了 需要去下发
# 判断如果当前的push_time 和当前的创建时间一样 需要给push_time下发真的push时间
if current_push_time == create_time:
if card_info['action_type'] == "comment":
auto_comment_user(card_info, after_day=True)
logging.info("当前卡片ID:%s,auto_comment_user子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
elif card_info['action_type'] == "click":
auto_click_user(card_info, after_day=True)
logging.info("当前卡片ID:%s,auto_click_user子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
elif card_info['action_type'] == "follow":
auto_follow_user(card_info, after_day=True)
logging.info("当前卡片ID:%s,auto_follow_user子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
else:
pass
else:
pass
else:
# 当前已下发完 需要判断最新一次的下发时间是否是今天 是的话直接保存起来,l=轮询等待明天再下发
if card_info['have_pust_num'] == card_info['need_pust_num']:
if nowtime.day - push_time_date.day == 0: # 今日的已经下发完了,需要去取之后的
# 当前已下发完 需要判断最新一次的下发时间是否是今天 是的话直接保存起来,l=轮询等待明天再下发
if card_info['have_pust_num'] == card_info['need_pust_num']:
if nowtime.day - push_time_date.day == 0: # 今日的已经下发完了,需要去取之后的
action_type = card_info['action_type']
logging.info("今天已经下发完了[%s,%s,%s,%s]" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key)))
if action_type == "comment":
auto_comment_user(card_info, after_day=True)
logging.info("当前卡片ID:%s,auto_comment_user子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
elif action_type == "click":
auto_click_user(card_info, after_day=True)
logging.info("当前卡片ID:%s,auto_comment_user子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
elif action_type == "follow":
auto_follow_user(card_info, after_day=True)
logging.info("当前卡片ID:%s,auto_comment_user子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
else:
pass
else: # 还有一种是下发时间已到
action_type = card_info['action_type']
logging.info("今天已经下发完了[%s,%s,%s,%s]" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key)))
if action_type == "comment":
auto_comment_user(card_info, after_day=True)
elif action_type == "click":
auto_click_user(card_info, after_day=True)
elif action_type == "follow":
auto_follow_user(card_info, after_day=True)
else:
pass
else: # 还有一种是下发时间已到
action_type = card_info['action_type']
if card_info['have_pust_num'] < card_info['need_pust_num'] and \
push_time_date < nowtime:
if action_type == "comment": # 在这里去调评论的接口
if 'have_comment_number' in card_info and \
card_info['have_comment_number'] < 20:
card_info["have_comment_number"] += 1
is_success = comment(card_info)
logging.info("comment [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
# 调完接口后需要再次去拿新的push_time的时间
auto_comment_user(card_info)
elif action_type == "click": # 在这里去调点赞的接口
if 'have_click_number' in card_info and card_info['have_click_number'] < 20:
card_info["have_click_number"] += 1
is_success = click(card_info)
logging.info("click [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
auto_click_user(card_info)
elif action_type == "follow": # 在这里去调关注的接口
if 'have_follow_number' in card_info and \
card_info['have_follow_number'] < 20:
card_info["have_follow_number"] += 1
is_success = follow(card_info)
logging.info("follow [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key),
card_info["card_id"], is_success))
auto_follow_user(card_info)
else: # push_time时间未到 需要等待
logging.info("follow [%s,%s,%s,%s],push_time未到,需要等待" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key)))
save_data_to_kafka(card_info)
if card_info['have_pust_num'] < card_info['need_pust_num'] and \
push_time_date < nowtime:
is_many = True
if action_type == "comment": # 在这里去调评论的接口
if 'have_comment_number' in card_info and \
card_info['have_comment_number'] < 20:
card_info["have_comment_number"] += 1
logging.info("当前卡片ID:%s,comment1子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
is_success, is_many = comment(card_info)
logging.info("comment [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset),
str(msg.key),
card_info["card_id"], is_success))
logging.info("当前卡片ID:%s,comment2子函数消费处理耗时:%f" % (
card_info['card_id'], time.time() - begin))
# 调完接口后需要再次去拿新的push_time的时间
if is_many:
auto_comment_user(card_info)
elif action_type == "click": # 在这里去调点赞的接口
is_many = True
if 'have_click_number' in card_info:
card_info["have_click_number"] += 1
logging.info("当前卡片ID:%s,click1子函数消费处理耗时:%f" % (
card_info["card_id"], time.time() - begin))
is_success, is_many = click(card_info)
logging.info("click [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset),
str(msg.key),
card_info["card_id"], is_success))
logging.info("当前卡片ID:%s,click2子函数消费处理耗时:%f" % (
card_info["card_id"], time.time() - begin))
if is_many:
auto_click_user(card_info)
elif action_type == "follow": # 在这里去调关注的接口
is_many = True
if 'have_follow_number' in card_info:
card_info["have_follow_number"] += 1
logging.info("当前卡片ID:%s,follow1子函数消费处理耗时:%f" % (
card_info["card_id"], time.time() - begin))
is_success, is_many = follow(card_info)
logging.info("当前卡片ID:%s,follow2子函数消费处理耗时:%f" % (
card_info["card_id"], time.time() - begin))
logging.info("follow [%s,%s,%s,%s],当前ID:%s,下发状状态:%s" % (
str(msg.topic), str(msg.partition), str(msg.offset),
str(msg.key),
card_info["card_id"], is_success))
if is_many == True:
auto_follow_user(card_info)
else: # push_time时间未到 需要等待
logging.info("follow [%s,%s,%s,%s],push_time未到,需要等待" % (
str(msg.topic), str(msg.partition), str(msg.offset), str(msg.key)))
save_data_to_kafka(card_info)
pass
else:
logging.info("此条数据已经消费过了")
pass
logging.info("消费处理耗时:%f" % (time.time() - begin))
except:
......
......@@ -14,6 +14,16 @@ from libs.error import logging_exception
@bind('vest/moment/vest_irrigation')
def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time="", content_level=0, tag_names=[]):
"""
在这里把后端传的数据存进卡夫卡 日记和帖子只需要发评论不需要点赞和关注
:param card_id:
:param card_type:
:param card_user_id:
:param create_time:
:param content_level:
:param tag_names:
:return:
"""
try:
producer = KafkaProducer(bootstrap_servers=settings.KAFKA_BROKER_LIST)
......@@ -32,6 +42,7 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
comment_msg_dict = {
"card_id": card_id,
"card_type": "auto_vest",
'card_status': card_type,
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
......@@ -43,32 +54,35 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
logging.info("get comment_msg_dict:%s" % comment_msg_dict)
producer.send(topic, json.dumps(comment_msg_dict).encode())
follow_msg_dict = {
"card_id": card_id,
"card_type": "auto_vest",
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
"type": "get_write_answer_userinfo",
"current_push_time": create_time,
'action_type': 'follow',
'card_user_id': card_user_id
if card_type == 'answer':
follow_msg_dict = {
"card_id": card_id,
"card_type": "auto_vest",
'card_status': card_type,
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
"type": "get_write_answer_userinfo",
"current_push_time": create_time,
'action_type': 'follow',
'card_user_id': card_user_id
}
producer.send(topic, json.dumps(follow_msg_dict).encode())
}
producer.send(topic, json.dumps(follow_msg_dict).encode())
click_msg_dict = {
"card_id": card_id,
"card_type": "auto_vest",
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
"type": "get_write_answer_userinfo",
"current_push_time": create_time,
'action_type': 'click'
click_msg_dict = {
"card_id": card_id,
"card_type": "auto_vest",
'card_status': card_type,
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
"type": "get_write_answer_userinfo",
"current_push_time": create_time,
'action_type': 'click'
}
producer.send(topic, json.dumps(click_msg_dict).encode())
}
producer.send(topic, json.dumps(click_msg_dict).encode())
producer.close()
......
......@@ -17,6 +17,18 @@ from bs4 import BeautifulSoup
logger = logging.getLogger(__name__)
producer = KafkaProducer(bootstrap_servers=settings.KAFKA_BROKER_LIST)
db_mimas_eagle = pymysql.connect(host=settings.HOST, port=settings.PORT, user=settings.USER,
password=settings.PASSWORD,
db=settings.NAME)
mimas_cursor = db_mimas_eagle.cursor()
db_zhengxing_eagle = pymysql.connect(host=settings.HOST1, port=settings.PORT, user=settings.USER1,
password=settings.PASSWORD1,
db=settings.NAME1)
zhengxing_cursor = db_zhengxing_eagle.cursor()
def strTimeProp(start, end, prop, frmt):
stime = time.mktime(time.strptime(start, frmt))
......@@ -30,10 +42,10 @@ def randomDate(create_time, frmt='%Y-%m-%d %H:%M:%S', action_type=None):
action_num = random.randint(1, 3)
if action_type == "comment":
action_num = random.randint(0, 1)
action_num = random.randint(1, 2)
start = str(create_time + datetime.timedelta(hours=2))
end = str(create_time + datetime.timedelta(hours=4))
start = str(create_time + datetime.timedelta(minutes=30))
end = str(create_time + datetime.timedelta(hours=2))
random_times = [randomDate_six_one(start, end, frmt) for _ in range(action_num)]
have_sort_times = sorted(random_times, key=lambda date: get_list(date))
......@@ -60,20 +72,20 @@ def get_one_six_days_random_time(frmt='%Y-%m-%d %H:%M:%S', num_days=0, action_ty
action_num = random.randint(5, 10)
if num_days <= 15 and num_days > 1 and action_type in ("follow", "click") and int(content_level) < 3:
action_num = random.randint(0, 1)
action_num = random.randint(1, 2)
if num_days <= 15 and num_days > 1 and action_type in ("follow") and int(content_level) >= 3:
action_num = random.randint(0, 5)
action_num = random.randint(1, 5)
if num_days == 1 and action_type in ("click") and int(content_level) >= 3:
action_num = random.randint(6, 12)
if num_days <= 15 and num_days > 1 and action_type in ("click") and int(content_level) >= 3:
action_num = random.randint(0, 6)
action_num = random.randint(1, 6)
if num_days >= 1 and num_days <= 6 and action_type in ("comment"):
if int(content_level) <= 3:
action_num = random.randint(0, 1)
action_num = random.randint(1, 2)
else:
action_num = random.randint(2, 4)
......@@ -104,24 +116,24 @@ def get_ten_last_days_random_time(num_days=None, frmt='%Y-%m-%d %H:%M:%S', conte
lastday = datetime.datetime(now.year, now.month, now.day, 23, 0, 0)
add_number = 0
if num_days > 15 and action_type in ("follow"):
action_num = random.randint(0, 2)
action_num = random.randint(1, 2)
add_number = 10
elif num_days > 15 and action_type in ("click"):
if content_level < 3:
action_num = random.randint(0, 1)
action_num = random.randint(1, 2)
add_number = 6
else:
action_num = random.randint(0, 2)
action_num = random.randint(1, 2)
add_number = 5
elif num_days > 6 and action_type in ("comment"):
if content_level <= 3:
action_num = random.randint(0, 1)
action_num = 1
add_number = 10
else:
action_num = random.randint(0, 2)
action_num = random.randint(1, 2)
add_number = 10
else:
......@@ -147,7 +159,10 @@ def get_ten_last_days_random_time(num_days=None, frmt='%Y-%m-%d %H:%M:%S', conte
def get_content_time_by_create_time(create_time="", content_level=0, action_type=None, after_day=False, card_info=None,
repeat_time=0):
try:
###在这个地方需要重新判断一下星级
content_level = get_current_card_content_level(card_info)
card_info['content_level'] = content_level
##
card_info['type'] = 'have_get_push_time'
card_info['have_comment_number'] = 0
now = datetime.datetime.now()
......@@ -193,6 +208,10 @@ def get_content_time_by_create_time(create_time="", content_level=0, action_type
def get_click_follow_time_by_create_time(create_time="", content_level=0, action_type=None, after_day=False,
card_info=None, repeat_time=0):
try:
######在这个地方需要重新判断一下星级
content_level = get_current_card_content_level(card_info)
card_info['content_level'] = content_level
####
card_info['have_click_number'] = 0
card_info['have_follow_number'] = 0
now = datetime.datetime.now()
......@@ -296,17 +315,76 @@ def get_vest_userid_and_comment(need_comment_num=0, tag_names=[], card_id=0):
for item in tag_names:
if item in all_keys_name:
service_closure_tags = redis_client.hget(redis_key, item)
closure_tags = json.loads(service_closure_tags)
closure_tags = json.loads(str(service_closure_tags, encoding="utf-8"))
all_comment_list.extend(closure_tags)
if all_comment_list:
content = random.sample(all_comment_list, need_comment_num)
else:
content = None
content = []
else:
content = None
content = []
return content
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
def judge_offset_partition_have_consum(card_info=None, offset=0, partition=0):
"""
根据当前的offset和分区去判断数据是否已经被消费
:param offset:
:param partition:
:return:
"""
try:
##先判断是不是2019-12-29的
create_time = card_info['create_time']
datetime_create_time = datetime.datetime.strptime(create_time, '%Y-%m-%d %H:%M:%S')
str_data = str(datetime_create_time.year) + str(datetime_create_time.month) + str(datetime_create_time.day)
if str_data in ['20191229', '20191230']:
logging.info("该日期的数据已经被删除啦")
return False
redis_list_data = 0
key = "irrigation_partition_offset_have_consum:" + str(partition)
redis_data = redis_client.get(key)
if offset < int(redis_data):
return False
redis_client.set(key, offset)
return True
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return False
def get_current_card_content_level(card_info=[]):
try:
# 判断当前卡片的等级
if card_info['card_status'] == 'answer':
sql = 'select level from api_answer where id = %s ' % (card_info['card_id'])
mimas_cursor.execute(sql)
data = list(mimas_cursor.fetchall())
if card_info['card_status'] == 'tractate':
sql = 'select content_level from api_tractate where id = %s ' % (card_info['card_id'])
mimas_cursor.execute(sql)
data = list(mimas_cursor.fetchall())
if card_info['card_status'] == 'diary':
sql = 'select content_level from api_diary where id = %s ' % (card_info['card_id'])
zhengxing_cursor.execute(sql)
data = list(zhengxing_cursor.fetchall())
if len(data) > 0:
if data[0][0]:
return int(data[0][0])
else:
return 0
else:
return 0
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return 0
......@@ -4,9 +4,8 @@ import redis
import json
import redis
from django.conf import settings
from libs.cache import redis_client
REDIS_URL = "redis://redis.paas-test.env:6379/0"
redis_client = redis.StrictRedis.from_url(REDIS_URL)
tag_list = ["瘦脸针kyc", "双眼皮kyc", "水光针kyc", "玻尿酸kyc", "吸脂kyc", "祛痘kyc", "鼻综合kyc", "光子嫩肤kyc", "没有想法kyc",
"牙齿kyc", "抗衰紧致kyc", "胸部kyc", "果酸换肤kyc", "祛斑kyc", "美白针kyc", "瘦腿针kyc"]
......@@ -134,7 +133,7 @@ shoulianzhen = ['瘦脸针疼吗!?超级怕疼', '我好特别怕疼的,
'我特别怕疼,打瘦脸针大概有多疼啊?', '瘦脸针效果明显吗???', '瘦脸针术后能吃辣椒吗?', '打完瘦脸针,饮食上有要求吗???', '我爱吃辣,是不是打了瘦脸针恢复期间,就不能吃辣了啊?',
'术后护理麻烦吗?', '打瘦脸针要多少钱呢?', '例假期间可以打瘦脸针吗?', '瘦脸针会不会很贵啊?', '啊,想做瘦脸针,但是会很疼吗???', '瘦脸针天冷做好还是天热做好啊?',
'瘦脸针适合啥样的人群啊?', '打完瘦脸针会反弹吗?', '什么体质都适合做瘦脸针吗?', '打瘦脸针几天能恢复好啊???', '我打算去做来着,术后恢复多久啊?', '"打完瘦脸针术后护理麻烦吗?',
'', '"', '瘦脸针是不是要忌辣啊?', '正规瘦脸针多少钱一次?', '有人在北京正规医院打过瘦脸针么?多少钱一针?', '公立医院瘦脸针一般多少钱,只打一边?', '正规瘦脸针品牌有几种?',
'瘦脸针是不是要忌辣啊?', '正规瘦脸针多少钱一次?', '有人在北京正规医院打过瘦脸针么?多少钱一针?', '公立医院瘦脸针一般多少钱,只打一边?', '正规瘦脸针品牌有几种?',
'瘦脸针打在哪个部位好?', '有人打过瘦脸针,效果怎么样?', '打瘦脸针会后悔吗?', '打瘦脸针靠谱吗?安全吗?有什么副作用?三次真的能定型吗?', '瘦脸针多久能见效?长期打瘦脸针会危害健康吗?',
'打瘦脸针后为什么显老?', '瘦脸针会导致皮肤松弛下垂吗?', '打完瘦脸针可以喝酒吗?', '疤痕体质可以打瘦脸针吗?', '打完瘦脸针可以吃药吗?', '孕妇可以打瘦脸针吗?',
'打完瘦脸针可以吃海鲜吗?', '打完瘦脸针后多久可以化妆?', '打完瘦脸针可以洗澡?', '打完瘦脸针可以碰水吗?', '哺乳期可以打水光针吗?', '瘦脸针一年要打多少次呢?',
......@@ -304,7 +303,7 @@ bizonghe_data = ['鼻综合会很疼吗?', '感觉我需要做鼻综合,啧
'鼻综合手术贵么?我也想做呢!', '想问下,我在北京,做鼻综合手术有推荐的医院嘛?', '准备年底去机构做鼻综合,希望有明显的效果', '关于鼻综合,大家有什么好的医师推荐嘛,我想面诊了解一下',
'想隆鼻,听说现在流行鼻综合,咨询一下鼻综合都包含哪些项目?', '想做鼻综合来着,但是没人陪我去!哭!', '山根低,鼻头肥大,想做鼻综合改善,鼻综合隆鼻是永久的吗?',
'鼻综合有没有危险啊,想做,但是有点害怕~', '做鼻综合手术,天冷做合适,还天热做合适啊?', '想做鼻综合,请问一下做鼻综合有哪些需要注意的地方?', '想问一下鼻综合和隆鼻有什么区别吗?',
'哪些鼻型人适合做鼻综合整形?', '鼻综合整形是不是不包括鼻基底填充?', '鼻综合手术做的过程大概多久啊?', '鼻综合整形哪里会留疤?', '"', '',
'哪些鼻型人适合做鼻综合整形?', '鼻综合整形是不是不包括鼻基底填充?', '鼻综合手术做的过程大概多久啊?', '鼻综合整形哪里会留疤?',
'做过鼻子的亲我想问下哪家做鼻综合比较好"', '我之前做过单纯假体隆鼻,现在可以改鼻综合吗?我想做网红鼻', '做鼻综合需要多少钱啊?炒鸡想做,但是钱包只允许我先观望一下~', '鼻综合什么时候出鼻尖',
'我爱吃辣,是不是做了鼻综合恢复期间就不能吃辣了啊', '鼻综合多久可以泡温泉?', '鼻综合这个项目的相关知识在哪儿能看到呀,我也想了解一下', '做了鼻综合,鼻头上长痘痘要怎样处理?',
'做鼻综合手术风险大吗?', '北京哪有整鼻好的啊,鼻综合大概需要多少钱', '做鼻综合是什么体验?', '综合鼻老了会咋样?', '单纯隆鼻和鼻综合有什么区别?为什么价格差这么多?',
......@@ -367,7 +366,7 @@ guangzinenfu_data = ['光子嫩肤做完黑眼圈都没了', '光子嫩肤做完
'复合彩光嫩肤和光子嫩肤一样吗?', '"做光子嫩肤是飞顿辉煌360、科医人皇后光子嫩肤和赛诺龙e乐姿强光', '靓肤仪器这三种仪器那个综合效果好呢"', '光子嫩肤具体是什么,和微针一样吗?',
'"光子嫩肤多少钱?我的脸上有红血丝,挺多的,偶尔过敏。', '我已经试了很多的办法,但是都没有效果,我听说光子嫩肤可以解决,所以我想试试"',
'"我怀孕了,脸上长了好多斑。听朋友说光子嫩肤就可以去除这些斑,', '但是我担心会对肚子里的宝宝不好。请问,怀孕的时候可以做光子嫩肤吗?"', '光子嫩肤和射频能同时做吗?',
'做完光子嫩肤脸上出现了色素沉淀,怎么办?', '"做了光子嫩肤,皮肤会不会对其产生依赖性?', '', '"', '请问光子嫩肤对痣有影响吗,能不能去痣?',
'做完光子嫩肤脸上出现了色素沉淀,怎么办?', '"做了光子嫩肤,皮肤会不会对其产生依赖性?', '请问光子嫩肤对痣有影响吗,能不能去痣?',
'光子嫩肤可以一直做吗,我已经做了5次,虽然效果不是特别满意,但是多做效果会不会更好?', '光子嫩肤属于激光吗,要做多少次,会对皮肤有不好的影响吗',
'光子嫩肤的疗程为多久、维持时间、会复发吗?术前、后应如何护理?', '做完光子嫩肤第二天可以做脂肪填充吗?', '做完光子嫩肤后要多久可以做小气泡?', '光子光子嫩肤能去妊娠斑吗?',
'打完瘦脸针可以做光子嫩肤吗?', '光子嫩肤和射频、超声刀可以同时进行吗?', '"\t做一次光子嫩肤能维持多久?"', '做光子嫩肤术后能晒太阳吗?', '做完光子嫩肤,多久可以化妆?',
......@@ -462,14 +461,14 @@ shoutuizhen_data = ['我想打瘦腿针,多久会见效?', '肌肉腿可以
'割双眼皮多久之后可以打瘦脸针或者瘦腿针?或者打瘦脸针多久之后可以割双眼皮?', '瘦腿针应该怎么选择呢?有什么区别?', '打瘦腿针效果怎么样?保持多久呢?',
'打瘦腿针会不会引起腿部静脉曲张?', '瘦腿针和瘦脸针可以一起打吗?会不会有抗体啊?', '请问国产瘦腿针和进口瘦腿针有什么区别吗?去医院打的时候医生建议打进口的',
'打完瘦腿针后,因为工作的需要,长时间在户外走路,会影响效果吗?', '打了瘦腿针,感冒了可以吃药吗,比如吃头孢', '打了瘦腿针,腿一直酸疼吗?', '腿容易抽筋,能打瘦腿针么,或者能做吸脂么',
'"', '', '瘦腿针多少计量可以达到瘦小腿的目的?可以同时瘦脚踝吗?"', '"', '', '打瘦腿针要用绷带束小腿吗?"', '瘦小腿推荐什么牌子的瘦腿针效果会怎样',
'瘦腿针多少计量可以达到瘦小腿的目的?可以同时瘦脚踝吗?"', '打瘦腿针要用绷带束小腿吗?"', '瘦小腿推荐什么牌子的瘦腿针效果会怎样',
'能不能同时打瘦脸针瘦腿针和腹部溶脂,会不会打太多了一次?', '什么样的腿部适合注射瘦腿针?', '怀孕期间可以打瘦腿针吗?', '哺乳期间可以打瘦腿针吗?', '打完瘦腿针可以吃辣吗?',
'打完瘦腿针饮食有忌口吗?', '瘦腿针分几种?', '哪些人可以打瘦腿针?', '瘦腿针后穿了压力很大的塑身裤会怎样?', '打完瘦腿针有什么注意事项?', '瘦腿针贵吗?多少钱啊?',
'打完瘦腿针有啥后遗症吗?', '腿部瘦腿针?瘦腿针能维持多久?有副作用吗?', '瘦腿的针多少钱?', '打完瘦腿针又大了一圈怎么回事?', '瘦腿针可以反复打吗?',
'瘦腿针是什么原理?瘦腿针有用吗?', '瘦腿针13mm针头全插吗?', '"打瘦腿针用粉毒还是白毒好?', '"', '怎样可以让瘦腿针的效果更久一些?',
'打一次瘦腿针能瘦多少!保持多长时间!?', '瘦腿针一次打多少单位 ?', '瘦腿针一般能瘦几厘米?', '打瘦腿针要麻醉吗?注射瘦腿针的时间多长?',
'衡力瘦腿针打完第一针后多久时间打第二针?', '瘦腿针跟瘦肩针 瘦脸针能一起打么?', '打瘦腿针会不会有风险,怎么避免呢?', '打完瘦腿针每天都要爬楼梯,肌肉会不会很快长出来?',
'怎么判断需不需要注射瘦腿针?', '瘦脸针瘦腿针用的难道不是同一种肉毒素?小腿一般打几针?', '瘦腿针打几次肌肉就完全消失了?', '瘦腿针打了之后会走不动路吗?',
'怎么判断需不需要注`射瘦腿针?', '瘦脸针瘦腿针用的难道不是同一种肉毒素?小腿一般打几针?', '瘦腿针打几次肌肉就完全消失了?', '瘦腿针打了之后会走不动路吗?',
'打瘦腿针一个月后可以做高周波吗?', '对青霉素过敏到底可不可以注射瘦脸针瘦腿针?', '打了瘦腿针 可以去抽脂吗 这两者要避开吗 避开的话要多久', '感冒期间可以打瘦腿针吗?',
'瘦腿针为什么能瘦腿?', '肌肉型小腿 腿型不好看 打瘦腿针有效果吗?', '打完瘦腿针可以用热水泡脚吗?', '瘦腿针200个单位打出来效果好吗. 会不会不够 我小腿肌肉很粗?',
'有没有上门打瘦腿针的医院?', '瘦腿针真的对身体有影响吗?', '打过瘦腿针多久能洗澡啊?', '网上卖的瘦腿针和溶脂针价格怎么差那么多啊?', '小腿属于肌肉型抽脂好还是瘦腿针?',
......@@ -566,64 +565,64 @@ closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "果酸换肤kyc", json.dumps(list(guosuanhuanfu_data)))
service_closure_tags = redis_client.hget(redis_key, "果酸换肤kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "祛斑kyc", json.dumps(list(queban_data)))
service_closure_tags = redis_client.hget(redis_key, "祛斑kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "美白针kyc", json.dumps(list(meibaizhen_data)))
service_closure_tags = redis_client.hget(redis_key, "美白针kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "瘦腿针kyc", json.dumps(list(shoutuizhen_data)))
service_closure_tags = redis_client.hget(redis_key, "瘦腿针kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "胸部kyc", json.dumps(list(xiongbu_data)))
service_closure_tags = redis_client.hget(redis_key, "胸部kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "抗衰紧致kyc", json.dumps(list(kangshuaijinzhi_data)))
service_closure_tags = redis_client.hget(redis_key, "抗衰紧致kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "牙齿kyc", json.dumps(list(yachi_data)))
service_closure_tags = redis_client.hget(redis_key, "牙齿kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "瘦脸针kyc", json.dumps(list(shoulianzhen)))
service_closure_tags = redis_client.hget(redis_key, "瘦脸针kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "双眼皮kyc", json.dumps(list(shuangyanpi_data)))
service_closure_tags = redis_client.hget(redis_key, "双眼皮kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "水光针kyc", json.dumps(list(shuiguangzhen_data)))
service_closure_tags = redis_client.hget(redis_key, "水光针kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "玻尿酸kyc", json.dumps(list(boniaosuan_data)))
service_closure_tags = redis_client.hget(redis_key, "玻尿酸kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "吸脂kyc", json.dumps(list(xizhi_data)))
service_closure_tags = redis_client.hget(redis_key, "吸脂kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "祛痘kyc", json.dumps(list(qudou_data)))
service_closure_tags = redis_client.hget(redis_key, "祛痘kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "鼻综合kyc", json.dumps(list(bizonghe_data)))
service_closure_tags = redis_client.hget(redis_key, "鼻综合kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "光子嫩肤kyc", json.dumps(list(guangzinenfu_data)))
service_closure_tags = redis_client.hget(redis_key, "光子嫩肤kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
redis_client.hset(redis_key, "没有想法kyc", json.dumps(list(meiyouxiangfa_data)))
service_closure_tags = redis_client.hget(redis_key, "没有想法kyc")
closure_tags = json.loads(service_closure_tags)
# closure_tags = json.loads(service_closure_tags)
......@@ -24,3 +24,4 @@ def send_email_tome(stat_data):
# server.quit()
except Exception:
logging.error("catch exception,main:%s" % traceback.format_exc())
......@@ -19,8 +19,10 @@ urllib3==1.24.1
git+ssh://git@git.wanmeizhensuo.com/backend/helios.git@v0.7.2
virtualenv==15.1.0
gevent==1.2.1
git+ssh://git@git.wanmeizhensuo.com/backend/gm-rpcd.git@v0.2.2
git+ssh://git@git.wanmeizhensuo.com/backend/gm-rpcd.git@v0.2.3
jieba==0.39
gunicorn==19.7.1
wheel==0.24.0
bs4==0.0.1
\ No newline at end of file
bs4==0.0.1
python-snappy==0.5.4
lz4==2.2.1
......@@ -20,6 +20,12 @@ PASSWORD = 'Gengmei1'
HOST = 'bj-cdb-6slgqwlc.sql.tencentcdb.com'
PORT = 62120
ENGINE1 = 'django.db.backends.mysql', # 设置为mysql数据库
NAME1 = 'zhengxing_test'
USER1 = 'work'
PASSWORD1 = 'Gengmei1'
HOST1 = 'bj-cdb-6slgqwlc.sql.tencentcdb.com'
OPTIONS = {
"init_command": "SET foreign_key_checks = 0;",
"charset": "utf8mb4", # 为了支持emoji表情
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment