Theory of spin-fluctuation induced superconductivity in iron-based superconductors