Preparation method for magnetic composite for treating and diagnosing cancer