ns = params_kw.copy() for k,v in list(ns.items()): if v == 'NaN' or v == 'null' or v == '' or v is None: if k != 'id': del ns[k] else: ns[k] = None if v in ('NaN', 'null') else v db = DBPools() dbname = get_module_dbname('pipeline_bidding') async with db.sqlorContext(dbname) as sor: tblfields = json.loads('[{"name": "id", "title": "主键ID", "type": "str", "length": 32, "nullable": "no"}, {"name": "org_id", "title": "机构ID", "type": "str", "length": 32, "nullable": "no", "default": "0"}, {"name": "account_name", "title": "配置名称", "type": "str", "length": 128, "nullable": "no"}, {"name": "protocol", "title": "协议", "type": "str", "length": 16, "nullable": "no", "default": "imap"}, {"name": "host", "title": "服务器地址", "type": "str", "length": 128, "nullable": "no"}, {"name": "port", "title": "端口", "type": "int", "nullable": "no", "default": "993"}, {"name": "use_ssl", "title": "使用SSL", "type": "str", "length": 1, "nullable": "no", "default": "1"}, {"name": "username", "title": "登录账号", "type": "str", "length": 128, "nullable": "no"}, {"name": "password", "title": "登录密码(AES加密)", "type": "str", "length": 500, "nullable": "no"}, {"name": "folder", "title": "邮件目录", "type": "str", "length": 64, "default": "INBOX"}, {"name": "filter_keywords", "title": "招标关键词(逗号分隔)", "type": "str", "length": 500}, {"name": "fetch_days", "title": "回溯天数", "type": "int", "default": "7"}, {"name": "last_uid", "title": "上次同步UID", "type": "str", "length": 64}, {"name": "last_fetch_at", "title": "上次同步时间", "type": "timestamp"}, {"name": "enabled", "title": "启用", "type": "str", "length": 1, "nullable": "no", "default": "1"}, {"name": "status", "title": "状态", "type": "str", "length": 16, "default": "active"}, {"name": "created_by", "title": "创建人", "type": "str", "length": 32}, {"name": "created_at", "title": "创建时间", "type": "timestamp", "nullable": "no"}, {"name": "updated_at", "title": "更新时间", "type": "timestamp"}]') tblfname = [ f['name'] for f in tblfields ] other_keys = [ k for k in ns.keys() if k in tblfname and k != 'id' ] if len(other_keys) > 0: r = await sor.U('bid_mail_accounts', ns) debug('update success'); return { "widgettype":"Message", "options":{ "title":"Update Success", "cwidth":16, "cheight":9, "timeout":3, "message":"ok" } } return { "widgettype":"Error", "options":{ "title":"Update Error", "cwidth":16, "cheight":9, "timeout":3, "message":"failed" } }