发表于: 2017-06-18 23:55:31
1 1325
今天完成的事情:
白天爬香山,
晚上重新写了一遍职业模块的Put接口
Put更新资源,Post创建资源。使用Put方法,需要对比之前数据是否相同。
@RequestMapping(value = "/a/u/profession/{id}", method = RequestMethod.PUT)
public String updateProfessionJson(HttpServletRequest request,
HttpServletResponse response, ModelMap model,
@PathVariable Long id,
@RequestBody ProfessionAndTags professionAndTags) throws Exception
log.info(" professionAndTag : professionAndTag= " + professionAndTags);
Profession profession = professionAndTags.getProfession();
Profession professionOld = null;
Company company = new Company();
/*获取职位的creatBy,createAt
try {
professionOld = professionService.getObjectById(id);
profession.setCreateBy(professionOld.getCreateBy());
profession.setCreateAt(professionOld.getCreateAt());
} catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
log.error("get professionOld error,id is " + id);
model.addAttribute("code", -6003);
}
try {
log.info("update profession : profession= " + profession);
company = companyService.getObjectById(profession.getCompanyId());
log.info("update profession : profession= " + profession)
profession.setId(id);
profession.setProvince(company.getProvince());// 从company获取
profession.setCity(company.getCity());
profession.setCounty(company.getCounty())
if (company.getFreezed() == 1L) {
profession.setStatus(0L);
} else if (company.getFreezed() == 0L) {
/*设置原职位状态
profession.setStatus(professionOld.getStatus());
}
log.info(" profession date is: profession =========" + profession);
Long uid = Long.valueOf(cookieUtil.getKeyIdentity(request,
com.qding.common.util.http.cookie.CookieUtil.USER_ID));
profession.setUpdateBy(uid);
log.info(" profession date is: profession =========" + profession);
professionService.update(profession);
model.addAttribute("code", 0);
} catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
log.error("update profession error,id is " + profession.getId());
model.addAttribute("code", -6003);
}
try {
log.info(" company date is: company ============" + company);
company.setProfessionUpdateAt(System.currentTimeMillis());
companyService.updateWithoutChangeUpdateAt(company);
} catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());
log.error("update company professionNum error");
model.addAttribute("code", -6004);
}
return "/data/json";
}
明天计划的事情:
和启辰师兄修改前端页面
遇到的问题:
暂无
收获:
暂无
评论