@RequestMapping(value = "/dflights/cityLowPrice", method = { RequestMethod.GET }, headers = "Accept=application/json")
public CommResponse searchCityLowPrice(
@RequestParam(value = "depCity", required = true) String depCity,
@RequestParam(value = "qDays", defaultValue = "30") int qDays,
@RequestParam(value = "qLines", defaultValue = "10") int qLines,
@RequestParam(value = "daysPerLine", defaultValue = "1") int daysPerLine) {
CommResponse ret;
List<LowPriceContent> list;
try {
this.verify(depCity, qDays, qLines, daysPerLine);
list = lowPriceService.getCityLowPrice(depCity, qDays, qLines,
daysPerLine);
List<LowPriceODT> lowPrices = new ArrayList<LowPriceODT>();
for (LowPriceContent lowPriceContent : list) {
LowPriceODT odt = new LowPriceODT();
odt.setCfcsdm(lowPriceContent.getDepartCity());
String searchItem = baseInfoService
.getAviationCityNameByCode(lowPriceContent
.getDepartCity());
if (searchItem != null) {
odt.setCfcs(searchItem);
}
odt.setDdcsdm(lowPriceContent.getArrivelCity());
searchItem = baseInfoService
.getAviationCityNameByCode(lowPriceContent
.getArrivelCity());
if (searchItem != null) {
odt.setDdcs(searchItem);
}
odt.setCfrq(lowPriceContent.getDate());
odt.setGj(CurrencyUtil.convertFen2YuanText(lowPriceContent
.getPrice()));
odt.setZk(lowPriceContent.getDiscountRate());
lowPrices.add(odt);
}
CommResponseWithArray<LowPriceODT> response = new CommResponseWithArray<LowPriceODT>();
response.setIsSuccess("Y");
response.setFailReason("");
response.setData(lowPrices);
ret = response;
} catch (ServiceException e) {
ret = new CommResponse();
ret.setIsSuccess("N");
ret.setFailReason(e.getMsg());
}
return ret;
}
原文:http://www.cnblogs.com/duojia/p/4552441.html