发表于: 2017-05-22 23:40:23
2 1072
今天完成的事情:
写一个公司详情的接口
@RequestMapping(value = "/a/company/{id}", method = RequestMethod.GET)
public String getCompanyJson(HttpServletRequest request, HttpServletResponse response,
ModelMap model, @PathVariable Long id) {
log.info("get data : id= " + id);
try {
Company company = companyService.getObjectById(id);
log.info("get company data is " + company);
model.addAttribute("company", company);
/* 获取行业ID */
List<Long> industryIds = companyIndustryService.getCompanyIndustryIdsByCompanyId(id, 0, 10);
/* 获取行业 */
List<CompanyIndustry> industryList = companyIndustryService.getObjectsByIds(industryIds);
model.addAttribute("industryList", industryList);
/* 获取公司产品ID */
List<Long> productIds = productService.getProductIdsByCompanyId(id, 0, 10);
/* 获取公司产品信息 */
List<Product> productList = productService.getObjectsByIds(productIds);
model.addAttribute("productList", productList);
model.addAttribute("code", 0);
}
catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
log.error("get company error,id is " + id,t);
model.addAttribute("code", -100000);
}
return "/carrots-weiqi-home-service/company/json/companyDetailJson";
}
明天计划的事情:
继续写接口
遇到问题:
报错显示取得的id为null,查看打印出的log日志
发现是DAO抛出了异常,然后进dao代码看问题
发现控制台打印的sql
limit 居然是0,0。修改为1,10
重启,请求GET
又报错了。。。。彻底没招了,明天再看
收获:
被报错折磨的死去活来,高潮迭起,很爽!
评论