def get_by_tenant_id(self, tenant_id, user_id): conn = BaseConnection() sql = """ SELECT DISTINCT a.user_id, a.email, a.nick_name, a.phone, a.is_active, a.enterprise_id, b.identity FROM user_info a, tenant_perms b, tenant_info c WHERE a.user_id = b.user_id AND b.tenant_id = c.ID AND a.user_id = {user_id} AND c.tenant_id = '{tenant_id}'""".format(tenant_id=tenant_id, user_id=user_id) result = conn.query(sql) if len(result) == 0: raise UserNotExistError("用户{0}不存在于团队{1}中".format( user_id, tenant_id)) return result[0]
def get_user_by_username(self, user_name): users = Users.objects.filter(nick_name=user_name) if not users: raise UserNotExistError("用户名{}不存在".format(user_name)) return users[0]
def get_user_by_user_id(self, user_id): u = Users.objects.filter(user_id=user_id) if not u: raise UserNotExistError("用户{}不存在".format(user_id)) return u[0]