Package com.iqbon.jcms.domain

Examples of com.iqbon.jcms.domain.Doc


    int number = docDAO.insertDoc(doc);
    logger.info(number);
  }

  public void testQueryDocById() {
    Doc one = docDAO.queryDocById("11111111111");
    logger.info(ToStringBuilder.reflectionToString(one));
  }
View Full Code Here


   * @param docid
   * @return
   * @throws NotFoundException
   */
  public Doc getDocById(String docid) throws NotFoundException {
    Doc doc = docDAO.queryDocById(docid);
    if (doc.getDelete() == 1) {
      throw new NotFoundException();
    }
    return doc;
  }
View Full Code Here

   * @return
   * @throws IOException
   * @throws NotFoundException
   */
  public String publishDoc(String docid, String indexid) throws IOException, NotFoundException {
    Doc doc = docDAO.queryDocById(docid);
    if(doc==null){
      logger.error("文章" + docid + "不存在");
      return null;
    }

    PushRecord pushRecord = new PushRecord();
    if (StringUtils.isNotBlank(indexid)) {
      pushRecord = pushRecordDAO.queryPushRecordById(indexid);
    } else {//如果没有传indexid,获取文章的第一个推送记录
      List<PushRecord> pushList = pushRecordDAO.queryPushRecordByDocid(docid);
      if (CollectionUtils.isNotEmpty(pushList)) {
        pushRecord = pushList.get(0);
      }
    }

    String modelName = doc.getModelName();
    Model model = modelService.getModelInfoByModelName(modelName);
    if (model == null) {
      logger.error("文章模板" + modelName + "不存在");
      return null;
    }
    String docContent = velocityService.parseDoc(model.getContent(), doc, pushRecord);
    String encoding = jcmsProperties.getOutFileCoding();
    File file = JCMSConstant.createDocOutputFile(doc.getUrl());
    if (file == null) {
      throw new IOException("获取模板uri出错");
    }
    FileUtils.write(file, docContent, encoding);

    //如果文章不是发布状态,设置文章状态
    setDocStatus(docid, Doc.docStatus.publish);

    //写日志
    DocLog docLog = new DocLog();
    docLog.setContent(DocLog.DOC_PUBLISH_COMMON);
    docLog.setTime(new Date());
    docLog.setUserName(doc.getLastModify());
    return docContent;
  }
View Full Code Here

  /**
   * 更新文章的状态
   * @param status
   */
  public void setDocStatus(String docid, Doc.docStatus status) {
    Doc doc = new Doc();
    doc.setDocid(docid);
    doc.setStatus(status.ordinal());
    docDAO.updateDocStatus(doc);
  }
View Full Code Here

    if (CollectionUtils.isNotEmpty(docModelList)) {
      view.addObject("docModelList", docModelList);
    }
    if (StringUtils.isNotEmpty(docid)) {
      try {
      Doc doc = docService.getDocById(docid);
      List<DocLog> logList = docService.getDocLogByDocid(docid);
      view.addObject("doc", doc);
      view.addObject("logList", logList);
      } catch (NotFoundException e) {
        logger.error("修改文章失败", e);
View Full Code Here

  String reporter, @RequestParam("keyword")
  String keyword, @RequestParam("modelName")
  String modelName, @RequestParam("status")
  int status, HttpSession session) {
    User user = getUserFromSession(session);
    Doc doc = new Doc();
    String docid = RandomStringUtils.randomAlphanumeric(11);
    doc.setDocid(docid);
    doc.setTitle(title);
    doc.setContent(content);
    doc.setDigest(digest);
    doc.setReporter(reporter);
    doc.setModifyUser(user.getUserName());
    doc.setType(Doc.docType.normal.ordinal());
    doc.setKeyword(keyword);
    doc.setModelName(modelName);
    doc.setStatus(status);
    String url = JCMSConstant.createDocUrl(docid, Doc.docType.normal.ordinal());
    doc.setUrl(url);
    int number = docService.addDoc(doc);
    if (number > 0) {//增加推送记录
      PushRecord pushRecord = new PushRecord();
      pushRecord.setIndexid(JCMSConstant.createPushRecordId());
      pushRecord.setDocid(docid);
View Full Code Here

  String modelName, @RequestParam("status")
  int status, @RequestParam("docid")
  String docid, @RequestParam("url")
  String url, HttpSession session) {
    User user = getUserFromSession(session);
    Doc doc = new Doc();
    doc.setDocid(docid);
    doc.setTitle(title);
    doc.setContent(content);
    doc.setDigest(digest);
    doc.setReporter(reporter);
    doc.setModifyUser(user.getUserName());
    doc.setType(Doc.docType.normal.ordinal());
    doc.setKeyword(keyword);
    doc.setModelName(modelName);
    doc.setStatus(status);
    doc.setUrl(url);
    int number = docService.modifyDoc(doc);
    if (number > 0) {
      if (status == Doc.docStatus.publish.ordinal()) {//发布文章
        try {
          docService.publishDoc(docid, null);
View Full Code Here

  String keyword, @RequestParam("modelName")
  String modelName, @RequestParam("clientName")
  String clientName, @RequestParam("password")
  String password) {
    Map<String, String> result = new HashMap<String, String>();
    Doc doc = new Doc();
    String docid = RandomStringUtils.randomAlphanumeric(11);
    doc.setDocid(docid);
    doc.setTitle(title);
    doc.setContent(content);
    doc.setDigest(digest);
    doc.setReporter(reporter);
    doc.setModifyUser(clientName);
    doc.setType(Doc.docType.normal.ordinal());
    doc.setKeyword(keyword);
    doc.setModelName(modelName);
    doc.setStatus(Doc.docStatus.unPublish.ordinal());
    String url = JCMSConstant.createDocUrl(docid, Doc.docType.normal.ordinal());
    doc.setUrl(url);
    logger.info("增加文章:" + ToStringBuilder.reflectionToString(doc));
    int number = 0;
    try {
      number = docService.addDoc(doc);
    } catch (Exception e) {
View Full Code Here

public class DocMapper implements RowMapper<Doc> {

  @Override
  public Doc mapRow(ResultSet rs, int rowNum) throws SQLException {
    Doc doc = new Doc();
    doc.setDocid(rs.getString("docid"));
    doc.setTitle(rs.getString("title"));
    doc.setContent(rs.getString("content"));
    doc.setDigest(rs.getString("digest"));
    doc.setModifyUser(rs.getString("modify_user"));
    doc.setDelete(rs.getInt("del"));
    doc.setReporter(rs.getString("reporter"));
    doc.setLastModify(rs.getString("last_modify"));
    doc.setUrl(rs.getString("url"));
    doc.setType(rs.getInt("type"));
    doc.setKeyword(rs.getString("keyword"));
    doc.setModelName(rs.getString("model_name"));
    doc.setStatus(rs.getInt("status"));
    return doc;
  }
View Full Code Here

TOP

Related Classes of com.iqbon.jcms.domain.Doc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.