1. add_users.dspy: 新增用户时 created_at 默认设为当天日期 2. add/update: 清除 Tabular 发送的 _text 后缀字段 (user_status_text, orgid_text 等不是真实列,会导致 sor.U/C 失败) 3. update_users.dspy: 密码为空时从 ns 中移除,避免覆盖为空白
59 lines
1.1 KiB
Plaintext
59 lines
1.1 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
for k,v in ns.items():
|
|
if v == 'NaN' or v == 'null':
|
|
ns[k] = None
|
|
# remove _text suffix fields sent by Tabular (not real DB columns)
|
|
for k in list(ns.keys()):
|
|
if k.endswith('_text'):
|
|
ns.pop(k, None)
|
|
id = params_kw.id
|
|
if not id or len(id) > 32:
|
|
id = uuid()
|
|
ns['id'] = id
|
|
|
|
if params_kw.get('password'):
|
|
ns['password'] = password_encode(params_kw.get('password'))
|
|
|
|
ns['created_at'] = curDateString()
|
|
|
|
|
|
userorgid = await get_userorgid()
|
|
if not userorgid:
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Authorization Error",
|
|
"timeout":3,
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"message":"Please login"
|
|
}
|
|
}
|
|
ns['orgid'] = userorgid
|
|
|
|
db = DBPools()
|
|
dbname = get_module_dbname('rbac')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
r = await sor.C('users', ns.copy())
|
|
return {
|
|
"widgettype":"Message",
|
|
"options":{
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"title":"Add Success",
|
|
"timeout":3,
|
|
"message":"ok"
|
|
}
|
|
}
|
|
|
|
return {
|
|
"widgettype":"Error",
|
|
"options":{
|
|
"title":"Add Error",
|
|
"cwidth":16,
|
|
"cheight":9,
|
|
"timeout":3,
|
|
"message":"failed"
|
|
}
|
|
} |