我有一個(gè)場(chǎng)景,我必須檢查模板是否已經(jīng)存在于數(shù)據(jù)庫(kù)中。如果存在,我必須根據(jù)現(xiàn)有模板返回一條消息。我有幾個(gè)模板:電子郵件、信件、短信。如果它們都存在,我必須返回“所有模板都已經(jīng)存在”。如果只有電子郵件模板存在,我必須返回只有電子郵件模板存在,信函和短信模板也是如此。代碼:for (EventVO eventVO: eventModuleList) { List <EmailTemplateMaster> emailTemplateList = communicationDAO .checkEmailTemplateExist(eventVO.getEventCode()); if (CollectionUtils.isNotEmpty(emailTemplateList)) { emailTemplateExist = true; } List <LetterTemplateMaster> letterTemplateList = communicationDAO .checkLetterTemplateExist(eventVO.getEventCode()); if (CollectionUtils.isNotEmpty(letterTemplateList)) { letterTemplateExist = true; } List <SmsTemplateMaster> smsTemplateList = communicationDAO .checkSmsTemplateExist(eventVO.getEventCode()); if (CollectionUtils.isNotEmpty(smsTemplateList)) { smsTemplateExist = true; } if (emailTemplateExist && letterTemplateExist && smsTemplateExist) { templateExist = CommunicationConstants.ALL_TEMPLATE_EXIST; } if (emailTemplateExist || !letterTemplateExist && !smsTemplateExist) { templateExist = CommunicationConstants.EMAIL_TEMPLATE_EXIST; } if (!emailTemplateExist && letterTemplateExist && !smsTemplateExist) { templateExist = CommunicationConstants.LETTER_TEMPLATE_EXIST; } if (!emailTemplateExist && !letterTemplateExist && smsTemplateExist) { templateExist = CommunicationConstants.SMS_TEMPLATE_EXIST; }}我可以知道檢查退出模板布爾值的最簡(jiǎn)單方法是否存在?;谕顺?,我必須發(fā)送相應(yīng)的消息。public static final String ALL_TEMPLATE_EXIST = "Email, Letter and Sms Template already exist for the selected event."; public static final String EMAIL_TEMPLATE_EXIST = "Email Template already exist for the selected event.";public static final String SMS_TEMPLATE_EXIST = "Sms Template already exist for the selected event.";public static final String LETTER_TEMPLATE_EXIST = "Email Letter Template already exist for the selected event.";
添加回答
舉報(bào)
0/150
提交
取消