Esempio n. 1
0
  /**
   * 更新运维文章 根据MntArticle的主键更新主键以外的其他字段
   *
   * @param MntArticle
   */
  @Override
  public void updateMntArticleById(MntArticle mntArticle) {

    // 文章分类
    if (mntArticle.getTypeId() == -99) {
      MntArticleType mntArticleType = new MntArticleType();
      mntArticleType.setTypeCn(mntArticle.getTypeCn());
      mntArticleType.setParentTypeId(-1);
      mntArticleTypeMapper.save(mntArticleType);
      mntArticle.setTypeId(mntArticleType.getTypeId());

      addArticleTypeCache(mntArticleType);
    }

    SysUser currentUser = userRealm.getCurrentUser();

    // getAuthor
    if (StringUtils.isEmpty(mntArticle.getAuthor())) {
      mntArticle.setAuthor(currentUser.getUserName());
    }

    mntArticle.setModifier(currentUser.getUserName());
    mntArticle.setModifyDate(new Date());

    mntArticleMapper.updateByPrimaryKey(mntArticle);
  }
Esempio n. 2
0
 /**
  * 根据主键批量删除运维文章 非物理删除 修改删除标识
  *
  * @param id Primary key
  */
 @Override
 public void deleteMntArticleByIds(String ids) {
   SysUser currentUser = userRealm.getCurrentUser();
   MntArticle mntArticle = new MntArticle();
   mntArticle.setDeleteFlag("1");
   mntArticle.setModifier(currentUser.getUserName());
   mntArticle.setModifyDate(new Date());
   String[] idAry = ids.split(",");
   for (String id : idAry) {
     mntArticle.setId(Integer.parseInt(id));
     mntArticleMapper.updateByPrimaryKey(mntArticle);
   }
 }
Esempio n. 3
0
  /**
   * 添加运维文章
   *
   * @param MntArticle
   */
  @Override
  public void saveMntArticle(MntArticle mntArticle) {
    SysUser currentUser = userRealm.getCurrentUser();

    // getSummary
    //        if(StringUtils.isEmpty(mntArticle.getSummary())) {
    //            if(!StringUtils.isEmpty(mntArticle.getContent())) {
    //                if(mntArticle.getContent().length() > 100) {
    //                    mntArticle.setSummary(mntArticle.getContent().substring(0, 100));
    //                }else {
    //                    mntArticle.setSummary(mntArticle.getContent());
    //                }
    //            }
    //        }

    // 文章分类
    if (mntArticle.getTypeId() == -99) {
      MntArticleType mntArticleType = new MntArticleType();
      mntArticleType.setTypeCn(mntArticle.getTypeCn());
      mntArticleType.setParentTypeId(-1);
      mntArticleTypeMapper.save(mntArticleType);
      mntArticle.setTypeId(mntArticleType.getTypeId());

      addArticleTypeCache(mntArticleType);
    }

    // getAuthor
    if (StringUtils.isEmpty(mntArticle.getAuthor())) {
      mntArticle.setAuthor(currentUser.getUserName());
    }
    mntArticle.setReadCount(0);
    mntArticle.setIsTop("0");
    mntArticle.setDeleteFlag("0");
    mntArticle.setCreator(currentUser.getUserName());
    mntArticle.setModifier(currentUser.getUserName());
    mntArticle.setCreateDate(new Date());
    mntArticle.setModifyDate(new Date());
    mntArticleMapper.save(mntArticle);
  }