!2 解决新建用户没有关联角色时,会关联所有角色BUG。
Merge pull request !2 from liujian8670/N/A
This commit is contained in:
commit
93fbfbbe39
@ -63,9 +63,10 @@ class UserDal(DalBase):
|
||||
data.password = self.model.get_password_hash(password)
|
||||
data.avatar = data.avatar if data.avatar else settings.DEFAULT_AVATAR
|
||||
obj = self.model(**data.dict(exclude={'role_ids'}))
|
||||
roles = await RoleDal(self.db).get_datas(limit=0, id=("in", data.role_ids), v_return_objs=True)
|
||||
for role in roles:
|
||||
obj.roles.append(role)
|
||||
if data.role_ids:
|
||||
roles = await RoleDal(self.db).get_datas(limit=0, id=("in", data.role_ids), v_return_objs=True)
|
||||
for role in roles:
|
||||
obj.roles.append(role)
|
||||
await self.flush(obj)
|
||||
return await self.out_dict(obj, v_options, v_return_obj, v_schema)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user