コード例 #1
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);
   }
 }
コード例 #2
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);
  }