To treat someone in a specified way — well, badly, fairly, etc.
"He always tried to do right by his employees, even when times were tough."
Do unto others as you would have them do unto you.
— The Bible, Luke 6:31 (Golden Rule, King James Version) — a foundational expression of 'doing by' others