添加了查询最新的三百条火情信息的功能模块
This commit is contained in:
parent
8eb571336e
commit
d3ac08778d
@ -47,4 +47,13 @@ public class FireController {
|
||||
public String selectFireBetweenTime(@RequestParam("code") String code, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime){
|
||||
return fireService.selectFireBetweenTime(code,startTime,endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询最新的300条火情信息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/findThreeHundredData")
|
||||
public String findThreeHundredData(){
|
||||
return fireService.findThreeHundredData();
|
||||
}
|
||||
}
|
||||
|
@ -38,4 +38,11 @@ public interface FireDao extends JpaRepository<Fire,Long>, JpaSpecificationExecu
|
||||
* @return
|
||||
*/
|
||||
List<Fire> findByDeviceCode(String code);
|
||||
|
||||
/**
|
||||
* 查询最新的300条火情信息
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "select * from fire order by alarm_date desc limit 300",nativeQuery = true)
|
||||
List<Fire> findThreeHundredData();
|
||||
}
|
||||
|
@ -23,4 +23,10 @@ public interface FireService {
|
||||
* @return
|
||||
*/
|
||||
String selectFireBetweenTime(String code, String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 查询最新三百条火情信息
|
||||
* @return
|
||||
*/
|
||||
String findThreeHundredData();
|
||||
}
|
||||
|
@ -64,4 +64,18 @@ public class FireServerImpl implements FireService {
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,fires,locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询最新300条火情信息
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator",unless="#result == null")
|
||||
@Override
|
||||
public String findThreeHundredData() {
|
||||
List<Fire> threeHundredData = fireDao.findThreeHundredData();
|
||||
if(threeHundredData == null || threeHundredData.size() == 0){
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有火情信息!",locale);
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,threeHundredData,locale);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user