Controller:
package cn.nokia.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.nokia.service.HellowService;;
@Controller
public class HellowController {
@Autowired
private HellowService helloservice;
@RequestMapping("index")
public @ResponseBody List doindex() {
return helloservice.doHello();
}
}
mapper:
package cn.nokia.mapper;
import java.util.List;
import java.util.Map;
public interface kpimapper {
List<Map<String,String>>selectall();
List<Map<String,String>>selectkpi();
}
mapper.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.nokia.mapper.kpimapper">
<select id="selectall" resultType="java.util.HashMap">
select pm_date as datetime,enb_id as enbid,cell_id as cellid,cell_avail_rate as rate from QIYUEFANV2 where rownum < 100
</select>
<select id="selectkpi" resultType="java.util.HashMap">
select enb_id as enbid,cell_id as cellid,cell_avail_rate as rate from QIYUEFANV2 where rownum < 100
</select>
</mapper>
Service:
package cn.nokia.service;
import java.util.List;
public interface HellowService {
public List doHello();
}
Service impl:
package cn.nokia.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.nokia.mapper.kpimapper;
import cn.nokia.service.HellowService;
@Service("helloservice")
public class HellowServiceImpl implements HellowService{
@Autowired
private kpimapper kpimaper;
@Override
public List doHello(){
/*List<Map<String, String>> list = new ArrayList<>();
Map<String,String> map = new HashMap<>();
map.put("name", "zouwei");
map.put("age", "24");
list.add(map);*/
return kpimaper.selectkpi();
}
}