TestController.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package com.robot.remote.smartrobotremote.controller;
  2. import com.robot.remote.smartrobotremote.domain.BizDevice;
  3. import com.robot.remote.smartrobotremote.mapper.BizDeviceMapper;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.jdbc.core.JdbcTemplate;
  7. import org.springframework.web.bind.annotation.GetMapping;
  8. import org.springframework.web.bind.annotation.RestController;
  9. import java.util.List;
  10. import java.util.Map;
  11. @Slf4j
  12. @RestController
  13. public class TestController {
  14. @Autowired
  15. private JdbcTemplate jdbcTemplate;
  16. @Autowired
  17. private BizDeviceMapper bizDeviceMapper;
  18. @GetMapping("/hello")
  19. public String hello(String name) {
  20. return "hello " + name;
  21. }
  22. /**
  23. * jdbcTemplate 模拟查询数据
  24. *
  25. */
  26. @GetMapping("/testQuerySqlServerByJDBC")
  27. public List<Map<String, Object>> testQuerySqlServerByJDBC() {
  28. String sql = "SELECT * FROM biz_device";
  29. return jdbcTemplate.queryForList(sql);
  30. }
  31. /**
  32. * mybatis 模拟查询数据
  33. *
  34. */
  35. @GetMapping("/testQuerySqlServerByMybatis")
  36. public List<BizDevice> testQuerySqlServerByMybatis() {
  37. return this.bizDeviceMapper.selectBizDeviceList(null);
  38. }
  39. }