KKSU
2024-01-09 cf68ee0531ebadbc7b27b8e6e56b9f3c4e893e05
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ArticleServiceImpl.java
@@ -115,6 +115,9 @@
        String atlas = adminAddArticleDto.getAtlas();
            articleEntity.setAtlas(atlas);
        Date releaseTime = adminAddArticleDto.getReleaseTime();
        if (releaseTime == null) {
            releaseTime = new Date();
        }
            articleEntity.setReleaseTime(releaseTime);
        Integer isTop = adminAddArticleDto.getIsTop();
        articleEntity.setIsTop(isTop);
@@ -128,7 +131,12 @@
        articleEntity.setArticleUrl(adminAddArticleDto.getArticleUrl());
        articleEntity.setType(adminAddArticleDto.getType());
        articleEntity.setContentType(adminAddArticleDto.getContentType());
        articleEntity.setDraftState(adminAddArticleDto.getDraftState());
        this.baseMapper.insert(articleEntity);
        if (adminAddArticleDto.getSaveState() == 2) {
            releaseService.releaseArticle(articleEntity.getId(), articleEntity.getCompanyId());
        }
        return Result.ok("添加成功");
    }
@@ -178,7 +186,12 @@
        if(ObjectUtil.isEmpty(columnEntity)){
            return Result.fail("请选择文章栏目");
        }
        if (!articleEntity.getColumnId().equals(columnId) && articleEntity.getBeforeColumnId() == -1) {
            articleEntity.setBeforeColumnId(articleEntity.getColumnId());
        }
        articleEntity.setColumnId(columnId);
        Integer visits = adminUpdateArticleDto.getVisits() == null ? 0 : adminUpdateArticleDto.getVisits();
        articleEntity.setVisits(visits);
        String mainDiagram = adminUpdateArticleDto.getMainDiagram();
@@ -199,9 +212,15 @@
        articleEntity.setArticleUrl(adminUpdateArticleDto.getArticleUrl());
        articleEntity.setType(adminUpdateArticleDto.getType());
        articleEntity.setContentType(adminUpdateArticleDto.getContentType());
        String authorBelong = adminUpdateArticleDto.getAuthorBelong();
        articleEntity.setAuthorBelong(authorBelong);
        articleEntity.setDraftState(adminUpdateArticleDto.getDraftState());
        this.baseMapper.updateById(articleEntity);
        if (adminUpdateArticleDto.getSaveState() == 2) {
            releaseService.releaseArticle(articleEntity.getId(), articleEntity.getCompanyId());
        }
        return Result.ok("更新成功");
    }
@@ -214,8 +233,13 @@
                Long articleId = Long.valueOf(articleIdStr);
                ArticleEntity articleEntity = this.baseMapper.selectById(articleId);
                articleEntity.setDelStatus(ArticleEntity.DELETE_STATUS_YES);
                this.baseMapper.updateById(articleEntity);
//                articleEntity.setDelStatus(ArticleEntity.DELETE_STATUS_YES);
//                this.baseMapper.updateById(articleEntity);
                if (articleEntity != null) {
                    this.baseMapper.deleteById(articleId);
                    releaseService.releaseColumn(articleEntity.getColumnId(), 2, articleEntity.getCompanyId());
                }
            }
        }
        return Result.ok("删除成功");
@@ -229,6 +253,8 @@
        }
        articleEntity.setReleaseStatus(ArticleEntity.RELEASE_STATUS_NO);
        this.baseMapper.updateById(articleEntity);
        releaseService.releaseColumn(articleEntity.getColumnId(), 2, articleEntity.getCompanyId());
        return Result.ok("操作成功");
    }
@@ -295,14 +321,16 @@
    @Override
    public Result updateStatusOn(Long id) {
        Long companyId = LoginUserUtil.getCompanyId();
        ArticleEntity articleEntity = this.baseMapper.selectById(id);
        if(ObjectUtil.isEmpty(articleEntity)){
            return Result.fail("文章不存在");
        }
        articleEntity.setDraftState(2);
        articleEntity.setReleaseStatus(ArticleEntity.RELEASE_STATUS_YES);
        this.baseMapper.updateById(articleEntity);
        releaseService.releaseArticle(articleEntity.getId());
        releaseService.releaseArticle(articleEntity.getId(), companyId);
        return Result.ok("操作成功");
    }