調用同一個類中從另一個方法的方法在同一類兩種方法,第一種方法是getEventByEventId
秒方法是addEventUserRealtionMapping
現在我需要調用getEventByEventId方法爲addEventUserRelationMapping方法我怎麼能我做到了。我如何在Java
public EventBO getEventByEventId(long eventId) throws UserServiceException {
try {
EventDO eventDO = eventDAOImpl.getEventByEventId(eventId);
EventBO eventBO = mapper.mapEventDOToBO(eventDO, new EventBO());
return eventBO;
} catch (UserDataException uExp) {
throw new UserServiceException("Error while getting event for event id " + eventId, uExp);
}
}
public int addEventUserRealtionMapping(ArrayList<UserBO> userBOs, long eventId) throws UserServiceException {
List<EventUserRelationDO> totalAddedCount;
ArrayList<UserDO> userDOs = new ArrayList<>();
try {
for (UserBO userBO : userBOs) {
UserDO userDO = mapper.mapUserBOToDO(userBO, new UserDO());
userDOs.add(userDO);
}
EventBO eventBO =new EventBO();
eventBO =getEventByEventId(eventId);//I am try that while call method1 but it doesn't work
MessageBO messageBO = new MessageBO();
messageBO.setEventId(eventBO.getEventId());
messageBO.setEventTitle(eventBO.getText());
messageBO.setMessage(eventBO.getText());
messageBO.setRingeeUserId(eventBO.getRingeeUserId());
messageBO.setMessageType(IRingeeConstants.MESSAGE_TYPE_INVITATION);
totalAddedCount = eventDAOImpl.addEventUserRelationMapping(userDOs, eventId);
if (totalAddedCount.size() == userDOs.size()) {
manageMessageService.sendMessageToGroup(userBOs, messageBO);
}
} catch (UserDataException dExp) {
throw new UserServiceException(" exception while adding user relationship for eventId " + eventId, dExp);
}
return totalAddedCount.size();
}
你不知道如何調用一個方法? – Stultuske
我知道如何調用一個方法,但我在這裏我想調用並設置返回值eventBO ..我不知道該怎麼做。 –
似乎是循環遞歸方法調用?我說明顯? –