The court shall resolve the case within the limits of the claims asserted by the plaintiff. However, the court may go beyond the claims asserted by the plaintiff, if it deems it necessary to protect the rights and legally protected interests of the plaintiff, as well as in other cases stipulated by law.