Exemplo n.º 1
0
 @Transactional(readOnly = true)
 public String createTableDataSQL(String tablename) {
   StringBuffer buffer = new StringBuffer();
   List<Object[]> results = dao.createTableData(tablename);
   for (Object[] oneResult : results) {
     buffer.append(Constants.ONESQL_PREFIX + INSERT_INTO + tablename + VALUES + LEFTBRACE);
     for (int j = 0; j < oneResult.length; j++) {
       if (oneResult[j] != null) {
         if (oneResult[j] instanceof Date) {
           buffer.append(QUOTES + oneResult[j] + QUOTES);
         } else if (oneResult[j] instanceof String) {
           buffer.append(QUOTES + StrUtils.replaceKeyString((String) oneResult[j]) + QUOTES);
         } else if (oneResult[j] instanceof Boolean) {
           if ((Boolean) oneResult[j]) {
             buffer.append(1);
           } else {
             buffer.append(0);
           }
         } else {
           buffer.append(oneResult[j]);
         }
       } else {
         buffer.append(oneResult[j]);
       }
       buffer.append(COMMA);
     }
     buffer = buffer.deleteCharAt(buffer.lastIndexOf(COMMA));
     buffer.append(RIGHTBRACE + BRANCH + BR);
   }
   return buffer.toString();
 }
Exemplo n.º 2
0
 private String createOneInsertSql(Object[] oneResult, String tablename) {
   StringBuffer buffer = new StringBuffer();
   buffer.append(
       Constants.ONESQL_PREFIX
           + INSERT_INTO
           + SPLIT
           + tablename
           + SPLIT
           + SPACE
           + VALUES
           + LEFTBRACE);
   for (int j = 0; j < oneResult.length; j++) {
     if (oneResult[j] != null) {
       if (oneResult[j] instanceof Date) {
         buffer.append(QUOTES + oneResult[j] + QUOTES);
       } else if (oneResult[j] instanceof String) {
         buffer.append(QUOTES + StrUtils.replaceKeyString((String) oneResult[j]) + QUOTES);
       } else if (oneResult[j] instanceof Boolean) {
         if ((Boolean) oneResult[j]) {
           buffer.append(1);
         } else {
           buffer.append(0);
         }
       } else {
         buffer.append(oneResult[j]);
       }
     } else {
       buffer.append(oneResult[j]);
     }
     buffer.append(COMMA);
   }
   buffer = buffer.deleteCharAt(buffer.lastIndexOf(COMMA));
   buffer.append(RIGHTBRACE + BRANCH + BR);
   return buffer.toString();
 }
Exemplo n.º 3
0
  public String msgSave() {
    Msg msg = new Msg();
    msg.setCtg(ctg);
    log.debug("留言标题:", title);
    String htmlTitle = StringEscapeUtils.escapeHtml(title);
    msg.setTitle(htmlTitle);
    log.debug("留言HTML标题:", msg.getTitle());
    content = StrUtils.getCn(content, getConfig().getMsgMaxSize());
    log.debug("留言内容", content);
    String htmlContent = StrUtils.txt2htm(content);
    msg.setContentMember(htmlContent);
    log.debug("留言HTML内容", msg.getContentMember());

    msg.setEmail(email);

    msg.setWebsite(getWeb());
    msg.setMember(getMember());
    msg.setCreateTime(ComUtils.now());
    msg.setCheck(false);
    msg.setRecommend(false);
    msg.setDisabled(false);
    String ip = contextPvd.getRemoteIp();
    msg.setIp(ip);
    jsonRoot.put("success", true);
    boolean check = getConfig().getMsgNeedCheck();
    jsonRoot.put("isNeedCheck", check);
    if (msgMng.isDuplicated(ip, htmlTitle, htmlContent)) { // 禁止重复留言
      jsonRoot.put("msg", "你已写过类似留言,请等待回复。");
    } else {
      msgMng.save(msg);
      if (check) {
        jsonRoot.put("msg", "留言成功,请等待审核。");
      } else {
        jsonRoot.put("msg", "恭喜您,留言成功!");
      }
    }
    return SUCCESS;
  }
Exemplo n.º 4
0
 @SuppressWarnings("unchecked")
 public void execute(
     Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
     throws TemplateException, IOException {
   String s = DirectiveUtils.getString(PARAM_S, params);
   Integer len = DirectiveUtils.getInt(PARAM_LEN, params);
   String append = DirectiveUtils.getString(PARAM_APPEND, params);
   if (s != null) {
     Writer out = env.getOut();
     if (len != null) {
       out.append(StrUtils.htmlCut(s, len, append));
     } else {
       out.append(s);
     }
   }
 }
Exemplo n.º 5
0
 public String getReplyHtml() {
   return StrUtils.txt2htm(getReply());
 }
Exemplo n.º 6
0
 public String getContentHtml() {
   return StrUtils.txt2htm(getContent());
 }
Exemplo n.º 7
0
 public String getTitleHtml() {
   return StrUtils.txt2htm(getTitle());
 }