/** * 更新用户信息 * * @param headers * @param content * @return */ @Path("/update/userInfo") @POST @Produces("application/json;charset=utf-8") public String updateUserInfo(String content) { if (StringUtils.isEmpty(content)) { return OpenResult.parameterError("无参数").buildJson(); } JSONObject json = JSONObject.parseObject(content); String userId = json.getString("userId"); String sessionId = json.getString("sessionId"); String validdate = json.getString("validdate"); String postcode = json.getString("postcode"); String regioncode = json.getString("regioncode"); String address = json.getString("address"); Integer sex = json.getInteger("sex"); String description = json.getString("description"); String reservedinfo = json.getString("reservedinfo"); if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(sessionId)) { return OpenResult.parameterError("参数错误").buildJson(); } // 校验性别 if (sex != null) { if (sex > 1 || sex < 0) { return OpenResult.parameterError("性别参数错误").buildJson(); } } if (StringUtils.isNotEmpty(postcode)) { // 校验邮政编码 boolean flag = registService.checkPostCode(postcode); if (!flag) { return OpenResult.parameterError("请输入正确的邮编").buildJson(); } } if (checkSessionId(userId, sessionId)) { try { JSONObject userRes = registService.updateUserInfo( userId, validdate, postcode, regioncode, address, sex, description, reservedinfo); if (userRes != null) { int retcode = userRes.getIntValue("retcode"); String msg = userRes.getString("msg"); if (retcode != 0) { return OpenResult.parameterError(retcode, msg).buildJson(); } return userRes.toJSONString(); } else { return OpenResult.unknown("服务异常").buildJson(); } } catch (StockServiceException e) { return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson(); } } else { return OpenResult.noAccess("未授权").buildJson(); } }