def handle_banuser(): """ 封禁用户 :return: json """ res = ResMsg() req = request.get_json(force=True) memberid = req.get("id") status = req.get("status") update_dict = { "status": status, } update_dict_ready = helpers.rmnullkeys(update_dict) user = db.session.query(EtMember).filter(EtMember.id == memberid).first() if user: db.session.query(EtMember).filter(EtMember.id == memberid).update(update_dict_ready) try: db.session.commit() Redis.delete(user_center_key + str(user.id)) Redis.delete(user_info_key + str(user.mobile)) Redis.lpush(balck_list_key, user.mobile) res.update(code=ResponseCode.Success, data={}, msg='完成封禁用户') return res.data except Exception as why: res.update(code=ResponseCode.Success, data={}, msg=f'修改失败,请稍后再试{why}') return res.data else: res.update(code=ResponseCode.Success, data={}, msg='修改失败,请稍后再试') return res.data
def handle_sysconfig_edit(): """ 系统全局设置修改 :return: json """ res = ResMsg() req = request.get_json(force=True) now_timestr = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) sysid = 1 notice = req.get("notice", '') domains = req.get("domains", '') share_domains = req.get("share_domains", '') task_limit = req.get("task_limit", 20) banners = req.get("banners", '') limit_withdrawal = req.get("limit_withdrawal", '') sys_status = int(req.get("status", 1)) rules = req.get("rules", 1) helper = req.get("helpers", 1) start_page = req.get("start_page", 1) upgrade = int(req.get("upgrade", 10)) update_dict = { "notice": notice, "domains": domains, "share_domains": share_domains, "task_limit": task_limit, "banners": banners, "limit_withdrawal": limit_withdrawal, "sys_status": sys_status, "rules": rules, "helpers": helper, "start_page": start_page, "upgrade": upgrade, "update_time": now_timestr } update_dict_ready = helpers.rmnullkeys(update_dict) sysdata = db.session.query(EtGlobalConfig).filter( EtGlobalConfig.id == sysid).first() if sysdata: db.session.query(EtGlobalConfig).filter( EtGlobalConfig.id == sysid).update(update_dict_ready) if notice: data = {'content': notice, 'time': now_timestr} json_data = json.dumps(data) redis_res = Redis.lpush(system_logging, json_data) try: db.session.commit() Redis.delete(redis_key_sys) res_data = helpers.queryToDict(sysdata) del res_data['update_time'] Redis.hmset(redis_key_sys, res_data) res.update(code=ResponseCode.Success, data={}, msg='系统全局配置成功') return res.data except Exception as why: res.update(code=ResponseCode.Success, data={}, msg=f'修改失败,请稍后再试{why}') return res.data else: res.update(code=ResponseCode.Success, data={}, msg='修改失败,请稍后再试') return res.data