inleft
2022-08-22 1e152bbcfb357073d8bcf0b51fe701e3fb81540d
修正邮箱拉取条数
添加日志上下篇
6 files modified
114 ■■■■■ changed files
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java 6 ●●●● patch | view | raw | blame | history
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/BlogArticleMapper.java 4 ●●●● patch | view | raw | blame | history
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/mapping/BlogArticleMapper.xml 13 ●●●●● patch | view | raw | blame | history
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/service/impl/BlogArticleServiceImpl.java 72 ●●●● patch | view | raw | blame | history
snowy-main/src/main/java/vip/xiaonuo/modular/task/EMailTaskRunner.java 17 ●●●●● patch | view | raw | blame | history
snowy-main/src/main/resources/templates/remindMe.ftl 2 ●●● patch | view | raw | blame | history
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java
@@ -229,13 +229,9 @@
        vo.setArticleFileURL(tempURL);
        vo.setCoverFileURL(this.getBlogSourceURL(vo.getCoverFileId()));
        //特殊类型强制关联类型(如前方高能分类)
        //如果有typeId,上下篇查询关联类型(默认按首页自然排序)
        while (!adjoiningRecord.isDone()) {
            try {
                Thread.sleep(100);
                Thread.sleep(50);
            } catch (InterruptedException e) {
            }
        }
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/BlogArticleMapper.java
@@ -28,6 +28,7 @@
import org.apache.ibatis.annotations.Param;
import vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo;
import vip.xiaonuo.modular.blogarticle.entity.BlogArticle;
import vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo;
import java.util.List;
import java.util.Map;
@@ -45,4 +46,7 @@
    long searchListCount(@Param("param") Map<String, Object> param);
    List<BlogArchiveDetailVo> searchMonthCount(@Param("separateYear") Integer separateYear);
    List<BlogArticleVo> getAdjoiningRecord(@Param("param") Map<String, Object> param);
}
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/mapping/BlogArticleMapper.xml
@@ -35,9 +35,11 @@
            and a.editor_status=1
            and a.publish_date &lt; now()
            <choose>
                <!-- 月台查询用 -->
                <when test="param.fileType != null">
                    and a.article_file_type = #{param.fileType}
                </when>
                <!-- 指定排除 视频类在首页显示,但需要在分类栏目列表显示 -->
                <when test="param.fileType == null and param.typeId == null">
                    and a.article_file_type not in (3,4)
                </when>
@@ -47,6 +49,8 @@
                    AND a.article_type_id = #{param.typeId}
                    order by a.is_top desc,a.top_value asc , a.publish_date desc
                </when>
                <!-- 指定排除 笔记类在首页显示 -->
                <otherwise>
                    AND a.article_type_id != 4
                    order by a.is_top desc,a.top_value asc , a.update_date desc
@@ -106,4 +110,13 @@
    </select>
    <select id="getAdjoiningRecord"  resultType="vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo">
        select
        a.id,
        a.title
        from
        blog_article a
        <include refid="queryListCondition"/>
        limit #{param.pageNo},#{param.pageSize}
    </select>
</mapper>
snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/service/impl/BlogArticleServiceImpl.java
@@ -28,6 +28,7 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -51,6 +52,7 @@
import vip.xiaonuo.modular.blogarticle.service.BlogArticleService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
@@ -185,59 +187,53 @@
    @Async
    @Override
    public Future<List<BlogArticleVo>> getAdjoiningRecord(BlogArticleQueryDto queryDto) {
        int pageNum = 1;
        Page<BlogArticle> queryPage = new Page<>(pageNum, 10);
        int pageNo = 0;
        int pageSize = 100;
        Map<String, Object> param = new HashMap<>(16);
        param.put("pageNo", PageUtil.getStart(pageNo, pageSize));
        param.put("pageSize", pageSize);
        param.put("typeId", queryDto.getTypeId());
        param.put("fileType", queryDto.getFileType());
        LambdaQueryWrapper<BlogArticle> queryWrapper = new LambdaQueryWrapper();
        List<BlogArticleVo> result = new ArrayList(2) {{
            add(null);
            add(null);
        }};
        queryWrapper.eq(BlogArticle::getIsEnable, MyConstant.Yes)
                .eq(BlogArticle::getEditorStatus, MyConstant.EditorStatus.status_1)
                .le(BlogArticle::getPublishDate, DateUtil.date())
                .eq(queryDto.getTypeId() != null, BlogArticle::getArticleTypeId, queryDto.getTypeId())
                .eq(queryDto.getFileType() != null, BlogArticle::getArticleFileType, queryDto.getFileType())
                .notIn(queryDto.getFileType() == null && queryDto.getTypeId() == null, BlogArticle::getArticleFileType, new Integer[]{3, 4})
                .orderByDesc(BlogArticle::getIsTop)
                .orderByAsc(BlogArticle::getTopValue)
                .orderByAsc(queryDto.getTypeId() != null, BlogArticle::getPublishDate)
                .orderByAsc(queryDto.getTypeId() == null, BlogArticle::getUpdateDate)
                .select(BlogArticle::getId);
        Long[] recordId = new Long[]{null, null};
        List<BlogArticle> tempRecordList;
        List<BlogArticleVo> tempRecordList;
        while (true) {
            tempRecordList = this.page(queryPage, queryWrapper).getRecords();
            tempRecordList = this.baseMapper.getAdjoiningRecord(param);
            if (CollUtil.isEmpty(tempRecordList)) {
                break;
            }
            for (int i = 0; i < tempRecordList.size(); i++) {
                if (queryDto.getId().equals(tempRecordList.get(i))) {
                if (queryDto.getId().equals(tempRecordList.get(i).getId())) {
                    //防止边界
                    recordId[0] = i - 1 >= 0 ? tempRecordList.get(i - 1).getId() : recordId[0];
                    recordId[1] = i + 1 < tempRecordList.size() ? tempRecordList.get(i + 1).getId() : recordId[1];
                    if (i - 1 >= 0) {
                        result.set(0, tempRecordList.get(i - 1));
                    }
                    if (i + 1 < tempRecordList.size()) {
                        result.set(1, tempRecordList.get(i + 1));
                    } else {
                        //记录恰好在队尾
                        param.put("pageNo", PageUtil.getStart(++pageNo, pageSize));
                        tempRecordList = this.baseMapper.getAdjoiningRecord(param);
                        if (CollUtil.isNotEmpty(tempRecordList)) {
                            result.set(1, tempRecordList.get(0));
                        }
                    }
                    return new AsyncResult<>(result);
                }
                //记录此页最后一条作为下一页起始记录
                recordId[0] = tempRecordList.get(i).getId();
                //记录此页最后一条作为下一页起始记录(记录恰好在队头)
                result.set(0, tempRecordList.get(i));
            }
            queryPage = new Page<>(++pageNum, 10);
            //下一页
            param.put("pageNo", PageUtil.getStart(++pageNo, pageSize));
        }
        List<BlogArticleVo> result = new ArrayList<>(2);
        for (int i = 0; i < recordId.length; i++) {
            if (recordId[i] != null) {
                result.add(this.lambdaQuery()
                        .eq(BlogArticle::getId, recordId[i])
                        .oneOpt().map(e -> {
                            BlogArticleVo vo = new BlogArticleVo();
                            BeanUtil.copyProperties(e, vo);
                            return vo;
                        }).orElse(null));
            } else {
                result.add(null);
            }
        }
        return new AsyncResult<>(result);
    }
snowy-main/src/main/java/vip/xiaonuo/modular/task/EMailTaskRunner.java
@@ -2,6 +2,7 @@
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.template.Template;
import cn.hutool.extra.template.TemplateConfig;
import cn.hutool.extra.template.TemplateEngine;
@@ -47,8 +48,15 @@
                .eq(BlogArticleComment::getIsRemind, MyConstant.No)
                .ge(BlogArticleComment::getCreateDate, DateUtil.offsetDay(DateUtil.date(), -1))
                .select(BlogArticleComment::getId, BlogArticleComment::getVisitorNickName, BlogArticleComment::getCommentContent)
                .last("limit 100")
                .last("limit 10")
                .list();
        int unReadCount = commentService.lambdaQuery()
                .ne(BlogArticleComment::getVisitorNickName, MyConstant.inleft)
                .eq(BlogArticleComment::getIsRead, MyConstant.No)
                .eq(BlogArticleComment::getIsRemind, MyConstant.No)
                .ge(BlogArticleComment::getCreateDate, DateUtil.offsetDay(DateUtil.date(), -1))
                .count();
        if (commentList.size() == 0) {
            log.info("本次无提醒消息条数。。");
@@ -60,12 +68,12 @@
        //发送邮件
        Dict dict = Dict.create()
                .set("contentList", commentList)
                .set("sendContent", commentList.size());
                .set("sendContent", StrUtil.format("新增了 {} 条未读信息", unReadCount));
        String result = template.render(dict);
        SendMailParam param = new SendMailParam();
        param.setContent(result);
        param.setTitle("邮箱自提醒任务..\n");
        param.setTitle(StrUtil.format("邮箱定时任务(msg:{})..\n", unReadCount));
        param.setTo(MyConstant.email);
        mailSender.sendMailHtml(param);
@@ -81,8 +89,5 @@
    }
    public static void main(String[] args) {
        System.out.println(DateUtil.offsetDay(DateUtil.date(), -1));
    }
}
snowy-main/src/main/resources/templates/remindMe.ftl
@@ -11,7 +11,7 @@
        </h2>
        <div style="padding:0 12px 0 12px;margin-top:18px">
            <p style="background:#fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow:0 2px 5px rgba(0,0,0,.15);margin:20px 0;padding:15px;border-radius:5px;font-size:14px;color:#555">
                新增了 ${sendContent} 条未读信息
                 ${sendContent}
            </p>
            <#list contentList as item>
                <p><strong>${item.visitorNickName!''}</strong>&nbsp;留言:</p>