kboss/b/hpc/HpcLdapUpdate.dspy
2025-07-16 14:27:17 +08:00

58 lines
2.4 KiB
Plaintext

async def HpcLdapUpdate(ns={}):
"""
编辑添加的账号
:param ns:
:return:
"""
db = DBPools()
async with db.sqlorContext('kboss') as sor:
try:
# 已经同步成功的账号不能更新
if ns.get('orgid'):
# 首先判断当前的账号是否已经同步过
sync_status_li = await sor.R('jncs_syncinfo', {'customerid': ns.get('orgid')})
sync_status_list = [item['sync_status'] for item in sync_status_li]
if '1' in sync_status_list:
return {
'status': False,
'msg': '用户已经同步过, 账号只能绑定一次, 强制更新可联系后台, 更新后将清空原来购买的所有核时'
}
else:
# 更新账号表
ns_usermap= {
'id': ns.get('id'),
"clustercode": ns.get('clustercode'),
"queuecode": ns.get('queuecode'),
"ldapuid": ns.get('ldapuid')
}
await sor.U('jncs_usermapping', ns_usermap)
# 更新订单中绑定的账号
update_sql = """UPDATE jncs_syncinfo SET clustercode = '%s', queuecode = '%s' where
customerid = '%s';""" % (ns.get('clustercode'), ns.get('queuecode'), ns.get('orgid'))
await sor.sqlExe(update_sql, {})
return {
'status': True,
'msg': '更新济南超算账号成功'
}
# 没有绑定过的账号直接更新
else:
# 更新账号表
ns_usermap = {
'id': ns.get('id'),
"clustercode": ns.get('clustercode'),
"queuecode": ns.get('queuecode'),
"ldapuid": ns.get('ldapuid')
}
await sor.U('jncs_usermapping', ns_usermap)
return {
'status': True,
'msg': '更新济南超算账号成功'
}
except Exception as e:
raise e
return {
'status': False,
'msg': '更新济南超算账号失败'
}
ret = await HpcLdapUpdate(params_kw)
return ret