@Override public String execute() throws Exception { int userId = loginHelper.getUserId(); publisher = publisherContactService.viewPublisherContactInfo(userId); if (publisher.getUserId() == 0) { hasContactInfo = false; publisher.setUserId(userId); addActionMessage("请填写相应的联系人信息"); } return SUCCESS; }
public String update() { results = new JsonResults(); if (!validatePubInfo()) { results.fail("信息不完整"); return JsonResults.JSON_RESULT_NAME; } if (hasSpecialChars(publisher.getName()) || hasSpecialChars(publisher.getEmail()) || hasSpecialChars(publisher.getMobile()) || hasSpecialChars(publisher.getReceiveAccount()) || hasSpecialChars(publisher.getReceiveName()) || hasSpecialChars(publisher.getQq())) { results.fail("含有非法字符"); return JsonResults.JSON_RESULT_NAME; } try { publisherContactService.saveOrUpdatePublisher(publisher); results.success(); } catch (ServiceException e) { results.fail(e.getMessage()); } catch (Exception e) { results.fail("系统异常"); } return JsonResults.JSON_RESULT_NAME; }
private boolean validatePubInfo() { // 检验完整性 if (StringUtils.isBlank(publisher.getName()) || StringUtils.isBlank(publisher.getEmail()) || StringUtils.isBlank(publisher.getMobile()) || publisher.getReceiveMethod() == null || StringUtils.isBlank(publisher.getReceiveAccount()) || StringUtils.isBlank(publisher.getReceiveName())) { return false; } return true; }