Skip to content

Commit

Permalink
#346 modify default value of notify config.
Browse files Browse the repository at this point in the history
  • Loading branch information
koda-masaru committed Apr 11, 2016
1 parent 95b77fc commit 55744cc
Showing 1 changed file with 49 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}

}

0 comments on commit 55744cc

Please sign in to comment.