Controller 层
/**
* 查询一条数据
*
* @param major .
* @param minor .
* @return .
*/
@GetMapping("beacons/{major}/{minor}")
public ResultData findByMajorAndMinor(@PathVariable("major") String major,
@PathVariable("minor") String minor) {
Map<String, Object> paramsMap = new HashMap<String, Object>();
paramsMap.put("major", major);
paramsMap.put("minor", minor);
Beacon beacon = beaconDao.findByMajorAndMinor(paramsMap);
if (beacon != null) {
return ResultData.ok().putDataValue("beacons", beacon);
} else {
return ResultData.notFound();
}
}
Dao 层方法定义
/**
* 查看一条数据
* @param paramsMap .
* @return .
*/
Beacon findByMajorAndMinor(Map<String,Object> paramsMap);
xml 文件 获取值进行SQL语句查询
<select id="findByMajorAndMinor" resultMap="BaseResultMap">
SELECT
b.*
FROM beacon b
WHERE
b.major=#{major}
AND
b.minor=#{minor}
</select>