Search in sources :

Example 1 with TbSysMsgNotice

use of com.netsteadfast.greenstep.po.hbm.TbSysMsgNotice in project bamboobsc by billchen198318.

the class SystemMessagePublishServiceImpl method process.

private String process(String sessionId, String refreshUUID, List<TbSysMsgNotice> sysMsgNotices) throws ServiceException, Exception {
    if (sysMsgNotices == null || sysMsgNotices.size() < 1) {
        return "";
    }
    Date sysDate = new Date();
    StringBuilder sb = new StringBuilder();
    for (TbSysMsgNotice msgNotice : sysMsgNotices) {
        String key = sessionId + ":uuid_" + refreshUUID + ":" + msgNotice.getNoticeId();
        if (messagePublishMap.get(key) != null) {
            continue;
        }
        if (!this.isPublishDateTimeRange(msgNotice, sysDate)) {
            // 日期區間不合
            continue;
        }
        //msgNotice.setTitle( TemplateUtils.processTemplateHtmlContent(msgNotice.getTitle()) );
        //msgNotice.setMessage( TemplateUtils.processTemplateHtmlContent(msgNotice.getMessage()) );
        TbSysMsgNotice dataObj = new TbSysMsgNotice();
        dataObj.setTitle(TemplateUtils.escapeHtml4TemplateHtmlContent(msgNotice.getTitle()));
        dataObj.setMessage(TemplateUtils.escapeHtml4TemplateHtmlContent(msgNotice.getMessage()));
        TemplateResultObj result = TemplateUtils.getResult(TemplateCode.TPLMSG0002, dataObj);
        dataObj = null;
        sb.append(result.getContent());
        messagePublishMap.put(key, YesNo.YES);
    }
    return sb.toString();
}
Also used : TbSysMsgNotice(com.netsteadfast.greenstep.po.hbm.TbSysMsgNotice) TemplateResultObj(com.netsteadfast.greenstep.model.TemplateResultObj) Date(java.util.Date)

Example 2 with TbSysMsgNotice

use of com.netsteadfast.greenstep.po.hbm.TbSysMsgNotice in project bamboobsc by billchen198318.

the class SystemMessagePublishServiceImpl method execute.

@Override
public WebMessagePublishBaseObj execute(SysMsgNoticeConfigVO config, ServletRequest request) throws ServiceException, Exception {
    this.request = request;
    WebMessagePublishBaseObj publishObj = new WebMessagePublishBaseObj();
    String account = request.getParameter("account");
    String refreshUUID = StringUtils.defaultString(request.getParameter("refreshUUID")).trim();
    String sessionId = ((HttpServletRequest) request).getSession().getId();
    AccountVO accountObj = (AccountVO) UserAccountHttpSessionSupport.get((HttpServletRequest) request);
    if (StringUtils.isBlank(this.getId()) || StringUtils.isBlank(account) || accountObj == null) {
        // no login
        return publishObj;
    }
    if (!account.equals(accountObj.getAccount())) {
        // not same account request
        return publishObj;
    }
    List<TbSysMsgNotice> globalSysMsgNoticeList = this.loadGlobalSysMsgNoticeData(config.getMsgId(), "*");
    List<TbSysMsgNotice> accountSysMsgNoticeList = this.loadAccountSysMsgNoticeData(config.getMsgId(), account);
    String globalMsg = this.process(sessionId, refreshUUID, globalSysMsgNoticeList);
    String personalMsg = this.process(sessionId, refreshUUID, accountSysMsgNoticeList);
    publishObj.setIsAuthorize(YesNo.YES);
    publishObj.setLogin(YesNo.YES);
    publishObj.setSuccess(YesNo.YES);
    publishObj.setMessage(globalMsg + personalMsg);
    return publishObj;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) TbSysMsgNotice(com.netsteadfast.greenstep.po.hbm.TbSysMsgNotice) WebMessagePublishBaseObj(com.netsteadfast.greenstep.model.WebMessagePublishBaseObj) AccountVO(com.netsteadfast.greenstep.vo.AccountVO)

Aggregations

TbSysMsgNotice (com.netsteadfast.greenstep.po.hbm.TbSysMsgNotice)2 TemplateResultObj (com.netsteadfast.greenstep.model.TemplateResultObj)1 WebMessagePublishBaseObj (com.netsteadfast.greenstep.model.WebMessagePublishBaseObj)1 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)1 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1