It's understandable (and not necessarily wrong) to vent here, and I'm not going to ask whether you have done this already, because it's not useful to draw out an answer, but: if you can, find the relevant anti-corruption agency and report the events to them.
There's a chance that doing so might increase the likelihood of harassment again in future -- I have no idea how these things show up on border entry systems -- so it's your choice, but the key idea is to get a paper trail in place that will show up if (and hopefully when) investigations are later taking place.
I haven't worked in law enforcement, but I imagine that the same way that good policework involves collecting statements and records of events to put together a case, internal (or independent) investigations into misconduct require similar records. The ability for individuals to get away with bad conduct is, I'd guess, based on people believing that it's not worthwhile to file reports against them. They do get caught when they are.