-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#349 Add notification feature for user added
- Loading branch information
1 parent
4cd61a4
commit a200f3a
Showing
7 changed files
with
287 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 18 additions & 17 deletions
35
src/main/java/org/support/project/knowledge/logic/notification/AbstractNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
package org.support.project.knowledge.logic.notification; | ||
|
||
import java.text.DateFormat; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
public abstract class AbstractNotification { | ||
/** date format */ | ||
private static DateFormat getDayFormat() { | ||
return new SimpleDateFormat("yyyyMMddHHmmss"); | ||
} | ||
import org.support.project.knowledge.logic.MailLogic; | ||
import org.support.project.knowledge.logic.NotificationLogic; | ||
import org.support.project.web.dao.UserNotificationsDao; | ||
import org.support.project.web.entity.NotificationsEntity; | ||
import org.support.project.web.entity.UserNotificationsEntity; | ||
|
||
public abstract class AbstractNotification implements Notification { | ||
/** | ||
* メール送信のIDを生成 | ||
* @param string | ||
* @return | ||
*/ | ||
protected String idGen(String label) { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append(label); | ||
builder.append("-"); | ||
builder.append(getDayFormat().format(new Date())); | ||
builder.append("-"); | ||
builder.append(UUID.randomUUID().toString()); | ||
return builder.toString(); | ||
return MailLogic.get().idGen(label); | ||
} | ||
|
||
/** | ||
* 指定の通知をユーザに紐付け | ||
* @param notification | ||
* @param userId | ||
*/ | ||
protected void insertUserNotification(NotificationsEntity notification, int userId) { | ||
UserNotificationsEntity userNotification = new UserNotificationsEntity(notification.getNo(), userId); | ||
userNotification.setStatus(NotificationLogic.STATUS_UNREAD); | ||
UserNotificationsDao.get().insert(userNotification); | ||
} | ||
|
||
} |
Oops, something went wrong.