Commit f0eae71f by dong

fix202302014

parent ada4307b
...@@ -6,6 +6,9 @@ IMAGE_CODE_REDIS_EXPIRES = 180 ...@@ -6,6 +6,9 @@ IMAGE_CODE_REDIS_EXPIRES = 180
# 短信验证码的redis有效期, 单位:秒 # 短信验证码的redis有效期, 单位:秒
SMS_CODE_REDIS_EXPIRES = 300 SMS_CODE_REDIS_EXPIRES = 300
# 产业链以及相关企业数量数据
INDUSTRY_ENTERPRISE_REDIS_EXPIRES = 120
# 发送短信验证码的间隔, 单位:秒 # 发送短信验证码的间隔, 单位:秒
SEND_SMS_CODE_INTERVAL = 60 SEND_SMS_CODE_INTERVAL = 60
......
...@@ -90,13 +90,24 @@ def get_cluster(): ...@@ -90,13 +90,24 @@ def get_cluster():
def industry_cluster(): def industry_cluster():
req_dic = request.get_json() req_dic = request.get_json()
industry_name = req_dic['industry_name'] industry_name = req_dic['industry_name']
# industry_id = req_dic['industry_id']
flag = req_dic['flag'] flag = req_dic['flag']
# # 查询redis
# try:
# result = redis_store.get('industry_id_{}'.format(industry_id)).decode()
# except Exception as e:
# current_app.logger.error(e)
# return jsonify(code=RET.DBERR, msg="redis数据库异常")
try: try:
industry_obj = IndustryChain.query.filter_by(industry_name=industry_name).first() industry_obj = IndustryChain.query.filter_by(industry_name=industry_name).first()
industry_id = industry_obj.id industry_id = industry_obj.id
chain_id = industry_obj.chain_id chain_id = industry_obj.chain_id
# 查询redis # 查询redis
result = redis_store.get('chain_id_{}'.format(industry_id))
if result:
return jsonify(code=RET.OK, msg="获取成功", data=json.loads(result))
result = { result = {
"industryChain": industry_name, "industryChain": industry_name,
"nodeList": [find_up_thr1(chain_id, 1, industry_id, flag), "nodeList": [find_up_thr1(chain_id, 1, industry_id, flag),
...@@ -106,6 +117,15 @@ def industry_cluster(): ...@@ -106,6 +117,15 @@ def industry_cluster():
except Exception as e: except Exception as e:
current_app.logger.error(e) current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="数据异常") return jsonify(code=RET.DBERR, msg="数据异常")
try:
redis_store.setex("chain_id_%s" % industry_id, constants.INDUSTRY_ENTERPRISE_REDIS_EXPIRES, json.dumps(result))
# 保存发送给这个手机号的记录,防止用户在60s内再次出发发送短信的操作
# redis_store.setex("send_sms_code_%s" % mobile, constants.SEND_SMS_CODE_INTERVAL, 1)
except Exception as e:
current_app.logger.error(e)
return jsonify(code=RET.DBERR, msg="保存产业/企业数量信息异常")
return jsonify(code=RET.OK, msg="获取成功", data=result) return jsonify(code=RET.OK, msg="获取成功", data=result)
......
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