This is the setup I'm currently working on for my main gate. I've yet to set up a proper military, but it'll consist of melee dwarves armed with pickaxes that are crosstrained with mining and engraving (squads of 3 until they have decent skills), and crossbow dwarves. Civilians not given the woodcutting task will be put in militia squads with crossbows.
^ - Bridge raising north
> - Retracting bridge
T - Weapon trap / Menacing spike trap
# - Fortification
+ - Floor
0 - Wall
- - Empty space
z = 0
FORTRESS
0^^^^^^^^0
0^^^^^^^^0
0^^^^^^^^0
0>>>TT>>>0
0>>>TT>>>0
...
0>>>TT>>>0
0^^^^^^^^0
0^^^^^^^^0
0^^^^^^^^0
0>>>>>>>>0
0>>>>>>>>0
...
0>>>>>>>>0
OUTSIDE
z = 1
FORTRESS
--------
--------
...
--------
########
++++++++
00000000
OUTSIDE
Basically the way this works is there's an airlock system using the two raising bridges. The outside bridge is a pit trap set over magma, and using the southern airlock, is a nearly foolproof means of killing invaders. For invasions where you want to collect the equipment used by the enemy, you can let them through the southern airlock while keeping the northern airlock closed. The bridges between the airlocks are retracting, forming a pit trap that drops enemies into a holding cell above the main barracks. This cell can then be flooded with magma, water, or both, or can be used to train your military. Creative use of z levels can allow you to utilize archers with fortifications, though you'll need magma-safe floodgates to prevent accidents. With the bridges between the airlocks retracted, the hallway becomes a long dodge-me trap. If the enemies are flying and able to survive the traps, you can station the melee dwarves behind the northern airlock, and provide covering fire from the walkway above. If you've left some space to either side, you can also make a branch off from the main hallway to serve as a reusable building destroyer trap, which you can find details for on the wiki.
This setup works well for numerous situations, and allows you to fight on conditions that you choose. A third airlock bridge can be put closer to your fortress to prevent disaster if your military dies, but you'd have to first choose to engage the enemy with your military.