| | |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import vip.xiaonuo.core.consts.CommonConstant; |
| | | import vip.xiaonuo.core.enums.CommonStatusEnum; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import vip.xiaonuo.core.exception.ServiceException; |
| | | import vip.xiaonuo.core.factory.PageFactory; |
| | | import vip.xiaonuo.core.pojo.page.PageResult; |
| | | import vip.xiaonuo.core.util.PoiUtil; |
| | | import vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo; |
| | | import vip.xiaonuo.modular.blogarticle.entity.BlogArticle; |
| | | import vip.xiaonuo.modular.blogarticle.enums.BlogArticleExceptionEnum; |
| | | import vip.xiaonuo.modular.blogarticle.mapper.BlogArticleMapper; |
| | | import vip.xiaonuo.modular.blogarticle.param.BlogArticleParam; |
| | | import vip.xiaonuo.modular.blogarticle.service.BlogArticleService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import javax.annotation.Resource; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * blog文章主体service接口实现类 |
| | | * blog文章service接口实现类 |
| | | * |
| | | * @author inleft |
| | | * @date 2022-01-22 16:53:06 |
| | | * @date 2022-02-09 18:20:46 |
| | | */ |
| | | @Service |
| | | public class BlogArticleServiceImpl extends ServiceImpl<BlogArticleMapper, BlogArticle> implements BlogArticleService { |
| | |
| | | |
| | | // 根据文章标题 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getTitle())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getTitle, blogArticleParam.getTitle()); |
| | | queryWrapper.lambda().like(BlogArticle::getTitle, blogArticleParam.getTitle()); |
| | | } |
| | | // 根据文章文件id 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getArticleFileId())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getArticleFileId, blogArticleParam.getArticleFileId()); |
| | | } |
| | | // 根据文件类型 1:markdown 2:html 查询 |
| | | // 根据文件类型 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getArticleFileType())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getArticleFileType, blogArticleParam.getArticleFileType()); |
| | | } |
| | | // 根据文章分类id 0:没有分类 查询 |
| | | // 根据文章分类 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getArticleTypeId())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getArticleTypeId, blogArticleParam.getArticleTypeId()); |
| | | } |
| | | // 根据文章引言 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getIntroduce())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getIntroduce, blogArticleParam.getIntroduce()); |
| | | } |
| | | // 根据封面文件地址(id) 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getCoverFileId())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getCoverFileId, blogArticleParam.getCoverFileId()); |
| | | } |
| | | // 根据上次编辑时间 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getLastEditorDate())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getLastEditorDate, blogArticleParam.getLastEditorDate()); |
| | | queryWrapper.lambda().like(BlogArticle::getIntroduce, blogArticleParam.getIntroduce()); |
| | | } |
| | | // 根据发布时间 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getPublishDate())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getPublishDate, blogArticleParam.getPublishDate()); |
| | | queryWrapper.lambda().ge(BlogArticle::getPublishDate, blogArticleParam.getPublishDate()); |
| | | } |
| | | // 根据是否置顶 0:否 1:是 查询 |
| | | // 根据是否置顶 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getIsTop())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getIsTop, blogArticleParam.getIsTop()); |
| | | } |
| | | // 根据置顶值(越小越靠前) 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getTopValue())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getTopValue, blogArticleParam.getTopValue()); |
| | | } |
| | | // 根据公开状态 1:公开 2:私密 3:密码授权 查询 |
| | | // 根据公开状态 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getAuthStatus())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getAuthStatus, blogArticleParam.getAuthStatus()); |
| | | } |
| | | // 根据授权密码(在密码授权状态时) 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getAuthPassword())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getAuthPassword, blogArticleParam.getAuthPassword()); |
| | | } |
| | | // 根据编辑状态 0:草稿 1:发布 查询 |
| | | // 根据编辑状态 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getEditorStatus())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getEditorStatus, blogArticleParam.getEditorStatus()); |
| | | } |
| | | // 根据归档年份(以初次发布时间为准) 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getSeparateYear())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getSeparateYear, blogArticleParam.getSeparateYear()); |
| | | } |
| | | // 根据归档月份 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getSeparateMonth())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getSeparateMonth, blogArticleParam.getSeparateMonth()); |
| | | } |
| | | // 根据归档日 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getSeparateDay())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getSeparateDay, blogArticleParam.getSeparateDay()); |
| | | } |
| | | // 根据是否启用 0:否 1:是 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getIsEnable())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getIsEnable, blogArticleParam.getIsEnable()); |
| | | } |
| | | // 根据更新时间 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getUpdateDate())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getUpdateDate, blogArticleParam.getUpdateDate()); |
| | | } |
| | | // 根据创建时间 查询 |
| | | if (ObjectUtil.isNotEmpty(blogArticleParam.getCreateDate())) { |
| | | queryWrapper.lambda().eq(BlogArticle::getCreateDate, blogArticleParam.getCreateDate()); |
| | | queryWrapper.lambda().ge(BlogArticle::getCreateDate, blogArticleParam.getCreateDate()); |
| | | } |
| | | } |
| | | return new PageResult<>(this.page(PageFactory.defaultPage(), queryWrapper)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取blog文章主体 |
| | | * 获取blog文章 |
| | | * |
| | | * @author inleft |
| | | * @date 2022-01-22 16:53:06 |
| | | * @date 2022-02-09 18:20:46 |
| | | */ |
| | | private BlogArticle queryBlogArticle(BlogArticleParam blogArticleParam) { |
| | | BlogArticle blogArticle = this.getById(blogArticleParam.getId()); |
| | |
| | | PoiUtil.exportExcelWithStream("SnowyBlogArticle.xls", BlogArticle.class, list); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List searchList(Map<String, Object> param) { |
| | | return this.baseMapper.searchList(param); |
| | | } |
| | | |
| | | @Override |
| | | public long searchListCount(Map<String, Object> param) { |
| | | return this.baseMapper.searchListCount(param); |
| | | } |
| | | |
| | | @Override |
| | | public List<BlogArchiveDetailVo> searchMonthCount(Integer separateYear) { |
| | | return this.baseMapper.searchMonthCount(separateYear); |
| | | |
| | | } |
| | | } |