发表于: 2017-08-22 20:02:33
1 948
今天完成的事情:
1.上午帮师弟们解决问题
2.下午用的postman测试自己的接口,有很多bug,之前测试的都是没有传值的接口,然后需要重新进行修改。
明天计划的事情:
两个师弟这两天差不多要进复盘了,跟他们讲一讲复盘要注意的事情。还是接着调自己的接口
遇到的问题:
在后台的新增用户的接口中的返回参数是一个account的model,但是在Postman中传值到后台都是空的
@RequestMapping(value = "/a/u/account", method = RequestMethod.POST)
public String addAccountJson(HttpServletRequest request, HttpServletResponse response, ModelMap model, Account account) throws Exception {
log.info("update account : account= " + account);
//获取当前操作者id
Long id = CookieUtil.getIdByCookie(request);
log.info("==========>id" + id);
//将创建者id放到createby中
account.setCreateBy(id);
//将account中的username+password进行加密
String md5 = MD5Util.stringToMD5(account.getUsername() + account.getPassword());
account.setPassword(md5);
log.info("------------->account="+account);
try {
account.setId(null);
accountService.insert(account);
model.addAttribute("code", 0);
model.addAttribute("massage", "success");
return "/data/json/code";
} catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
log.error("add account error ");
model.addAttribute("code", -6002);
}
return "/data/json/code";
}
public String addAccountJson(HttpServletRequest request, HttpServletResponse response, ModelMap model, Account account) throws Exception {
log.info("update account : account= " + account);
//获取当前操作者id
Long id = CookieUtil.getIdByCookie(request);
log.info("==========>id" + id);
//将创建者id放到createby中
account.setCreateBy(id);
//将account中的username+password进行加密
String md5 = MD5Util.stringToMD5(account.getUsername() + account.getPassword());
account.setPassword(md5);
log.info("------------->account="+account);
try {
account.setId(null);
accountService.insert(account);
model.addAttribute("code", 0);
model.addAttribute("massage", "success");
return "/data/json/code";
} catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
log.error("add account error ");
model.addAttribute("code", -6002);
}
return "/data/json/code";
}
用Postman的输入的数据是这样的

但是控制台的接收不到传过来的值,参数都是空的。
问web的师兄,师兄页是说这样传一个model,不行就改一下返回参数吧。差不多就这样了。
总结:
这周五之前将接口都调试完吧,不想在拖时间了,到了武汉分院,有时真的好想把重新做一个复盘,但是想想还是先把这个做了,不能烂尾吧,这样就很不好了。
评论