From 55744cc645163a6052939880971c7fce654b1a80 Mon Sep 17 00:00:00 2001 From: Koda Date: Mon, 11 Apr 2016 23:05:43 +0900 Subject: [PATCH] #346 modify default value of notify config. --- .../control/protect/NotifyControl.java | 78 ++++++++++++------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/support/project/knowledge/control/protect/NotifyControl.java b/src/main/java/org/support/project/knowledge/control/protect/NotifyControl.java index 614613072..c04e328db 100644 --- a/src/main/java/org/support/project/knowledge/control/protect/NotifyControl.java +++ b/src/main/java/org/support/project/knowledge/control/protect/NotifyControl.java @@ -4,6 +4,7 @@ import net.arnx.jsonic.JSONException; +import org.support.project.common.config.INT_FLAG; import org.support.project.di.DI; import org.support.project.di.Instance; import org.support.project.knowledge.control.Control; @@ -14,35 +15,54 @@ import org.support.project.web.control.service.Post; import org.support.project.web.exception.InvalidParamException; -@DI(instance=Instance.Prototype) +@DI(instance = Instance.Prototype) public class NotifyControl extends Control { - /* (non-Javadoc) - * @see org.support.project.web.control.Control#index() - */ - @Override - @Get - public Boundary index() { - NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); - NotifyConfigsEntity notifyConfigsEntity = notifyConfigsDao.selectOnKey(getLoginUserId()); - if (notifyConfigsEntity == null) { - notifyConfigsEntity = new NotifyConfigsEntity(); - } - setAttributeOnProperty(notifyConfigsEntity); - return super.index(); - } - - @Post - public Boundary save() throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException { - NotifyConfigsEntity entity = super.getParamOnProperty(NotifyConfigsEntity.class); - NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); - entity.setUserId(getLoginUserId()); - notifyConfigsDao.save(entity); - addMsgSuccess("message.success.save"); - return super.index(); - } - - - - + /* + * (non-Javadoc) + * + * @see org.support.project.web.control.Control#index() + */ + @Override + @Get + public Boundary index() { + NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); + NotifyConfigsEntity notifyConfigsEntity = notifyConfigsDao.selectOnKey(getLoginUserId()); + if (notifyConfigsEntity == null) { + notifyConfigsEntity = new NotifyConfigsEntity(); + } + setAttributeOnProperty(notifyConfigsEntity); + return super.index(); + } + + @Post + public Boundary save() throws InstantiationException, IllegalAccessException, JSONException, IOException, InvalidParamException { + NotifyConfigsEntity entity = super.getParamOnProperty(NotifyConfigsEntity.class); + NotifyConfigsDao notifyConfigsDao = NotifyConfigsDao.get(); + if (entity.getNotifyMail() == INT_FLAG.ON.getValue() || entity.getNotifyDesktop() == INT_FLAG.ON.getValue()) { + // 通知はONにしたけどメールが届かないという問い合わせがある + // 通知をONにしても、通知する種類を選択していないとメールが届かないので、通知ONの場合、 + // 通知する種類を明示的にOFFにしない場合以外はONにする + if (entity.getMyItemComment() == null) { + entity.setMyItemComment(INT_FLAG.ON.getValue()); + } + if (entity.getMyItemLike() == null) { + entity.setMyItemLike(INT_FLAG.ON.getValue()); + } + if (entity.getMyItemStock() == null) { + entity.setMyItemStock(INT_FLAG.ON.getValue()); + } + if (entity.getToItemComment() == null) { + entity.setToItemComment(INT_FLAG.ON.getValue()); + } + if (entity.getToItemSave() == null) { + entity.setToItemSave(INT_FLAG.ON.getValue()); + } + } + entity.setUserId(getLoginUserId()); + notifyConfigsDao.save(entity); + addMsgSuccess("message.success.save"); + return super.index(); + } + }