package com.persagy.transfer.controller; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.persagy.transfer.service.impl.DemoService; /** * 多数据源测试 * * @version 1.0.0 * @company persagy * @author zhangqiankun * @date 2021年9月15日 下午4:12:18 */ @RestController public class DemoController { @Autowired private DemoService demoService; @RequestMapping("/test") public Object queryCount(HttpServletRequest request) { String datasource = request.getHeader("datasource"); return "1".equals(datasource) ? this.demoService.getDataByMasterOne() : this.demoService.getDataByMasterTwo(); } }