Thompson Sampling-Based Learning and Control for Unknown Dynamic Systems