Scenario 1) You did produce substandard shit code that could have been done in a week. In that case, figure out what you did wrong and learn from it. Most fresh college grads produce shit code, it's just a thing. No one holds it against you because you're young and new. In this case, recognize the advice from someone better and more experienced than you, and just do better next time. Don't take it personally as an attack on your abilities and character. I'm sure you're a nice person. I'm also sure as a new college grad, you have a lot to learn still. This is one of those times where you can use an experience to learn.
Scenario 2) You did a fine job but your manager is unable to appreciate that. In this case, you still have more to learn but not on the programming side (well, probably still more to learn there, but not relevant to this situation). This is a lesson on how to deal with bad managers. They are not better than you, they do not own all of your time, and you have the right to leave at any time. As a dev, you will probably be able to find employment again easily. Use this to your advantage and any time the pressure from this bad manager rises, remind them of that fact and be ready to call their bluffs. Polish your resume, and get out of there in 18 months (bad managers don't get better). Leverage your position to a better job at higher pay.
How to tell between Scenario 1 and 2? That's hard to say without more specifics, but either way I think the takeaway is to try to learn what you can from this and don't take it too hard.
The professional habit I developed to manage scenario 2 started out as upward directed leadership and sometimes turned into simply coaching my bosses to be better themselves. There's a part that jumps out to me in the OP, the requirements changed so a lot of his work went to waste. Incredibly common. Equally common is management not realizing that it's something that they should take ownership of.
Yes, coaching your bosses is something that most people completely overlook as an option. After all they are bosses, and you don't question the boss!
But once you spend some time in the industry you've seen enough that you can recognize the mistakes of your superiors, and you feel comfortable enough to point them out. Because what are they going to do, fire you? Better to be fired by a stubborn boss who refuses to learn than to work under one, I'd say.
Scenario 2) You did a fine job but your manager is unable to appreciate that. In this case, you still have more to learn but not on the programming side (well, probably still more to learn there, but not relevant to this situation). This is a lesson on how to deal with bad managers. They are not better than you, they do not own all of your time, and you have the right to leave at any time. As a dev, you will probably be able to find employment again easily. Use this to your advantage and any time the pressure from this bad manager rises, remind them of that fact and be ready to call their bluffs. Polish your resume, and get out of there in 18 months (bad managers don't get better). Leverage your position to a better job at higher pay.
How to tell between Scenario 1 and 2? That's hard to say without more specifics, but either way I think the takeaway is to try to learn what you can from this and don't take it too hard.