snowy-base/snowy-core/src/main/java/vip/xiaonuo/core/consts/MyConstant.java
@@ -1,17 +1,27 @@ package vip.xiaonuo.core.consts; import java.util.ArrayList; import java.util.List; public interface MyConstant { Integer No = 0; Integer Yes = 1; String limit = " limit 1 "; String privateComment = "(悄悄话已隐藏)******"; String checkComment = "(未审核消息)******"; String inleft= "inleft"; String inleft = "inleft"; String email = "inleft@qq.com"; String url_1 = "http://blog.inleft.com/comment#%d"; String url_2 = "http://blog.inleft.com/mdDetail?id=%d#%d"; List<String> myIds = new ArrayList(3) {{ add(MyConstant.inleft); add("阿墨"); add("笔墨"); }}; interface AuthStatus { int publicCode = 1; int privateCode = 2; snowy-base/snowy-core/src/main/java/vip/xiaonuo/core/context/constant/ConstantContextHolder.java
@@ -139,7 +139,7 @@ * @date 2020/6/19 18:08 */ public static AliyunSmsConfigs getAliyunSmsConfigs() { String snowySmsAccesskeyId = getSysConfig("SNOWY_ALIYUN_SMS_ACCESSKEY_ID", String.class, true); String snowySmsAccesskeyId = getSysConfig("SNOWY_ALIYUN_SMS_ACCESSKEY_ID", String.class, true); String snowySmsAccesskeySecret = getSysConfig("SNOWY_ALIYUN_SMS_ACCESSKEY_SECRET", String.class, true); String snowySmsSignName = getSysConfig("SNOWY_ALIYUN_SMS_SIGN_NAME", String.class, true); String snowySmsLoginTemplateCode = getSysConfig("SNOWY_ALIYUN_SMS_LOGIN_TEMPLATE_CODE", String.class, true); @@ -324,6 +324,7 @@ /** * 获取blog资源地址访问前缀 * * @return */ public static String getBlogSourcePrefix() { @@ -418,4 +419,12 @@ return cryptogramConfigs; } /** * 获取自我认证密码 * * @author inleft */ public static String getAuthCode() { return getSysConfigWithDefault("inleft_AuthCode", String.class, null); } } snowy-main/src/main/java/vip/xiaonuo/modular/blogStatistics/BlogStatisticsController.java
@@ -32,6 +32,7 @@ import vip.xiaonuo.core.annotion.BusinessLog; import vip.xiaonuo.core.consts.MyConstant; import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum; import vip.xiaonuo.core.exception.BlogException; import vip.xiaonuo.core.pojo.response.ResponseData; import vip.xiaonuo.core.pojo.response.SuccessResponseData; import vip.xiaonuo.modular.blogStatistics.vo.BlogArchiveDetailVo; @@ -39,6 +40,8 @@ import vip.xiaonuo.modular.blogStatistics.vo.BlogStatisticsVo; import vip.xiaonuo.modular.blogarticle.entity.BlogArticle; import vip.xiaonuo.modular.blogarticle.service.BlogArticleService; import vip.xiaonuo.modular.blogarticlecomment.entity.BlogArticleComment; import vip.xiaonuo.modular.blogarticlecomment.service.BlogArticleCommentService; import javax.annotation.Resource; import java.util.*; @@ -58,6 +61,9 @@ @Resource private BlogArticleService blogArticleService; @Resource private BlogArticleCommentService commentService; /** * @author inleft * @date 2022-02-09 18:20:22 @@ -67,9 +73,23 @@ public ResponseData statistics() { String updateDate = "--"; BlogArticle lastUpdateBlog = blogArticleService.lambdaQuery().orderByDesc(BlogArticle::getUpdateDate).last(" limit 1 ").one(); BlogArticle lastUpdateBlog = blogArticleService.lambdaQuery().orderByDesc(BlogArticle::getUpdateDate).last(MyConstant.limit).one(); if (lastUpdateBlog != null && lastUpdateBlog.getUpdateDate() != null) { updateDate = DateUtil.formatDate(lastUpdateBlog.getUpdateDate()); } //新增最近的评论时间 BlogArticleComment comment = commentService.lambdaQuery() .eq(BlogArticleComment::getVisitorNickName, MyConstant.inleft) .orderByDesc(BlogArticleComment::getCreateDate) .last(MyConstant.limit) .select(BlogArticleComment::getId,BlogArticleComment::getCreateDate) .one(); if (comment != null && comment.getUpdateDate() != null && lastUpdateBlog != null && lastUpdateBlog.getCreateDate().before(comment.getCreateDate())) { updateDate = DateUtil.formatDate(comment.getCreateDate()); } String startFrom = "从这开始: 2020-05-27 "; @@ -183,4 +203,21 @@ return new SuccessResponseData(res); } @GetMapping("/blog/option") @BusinessLog(title = "外部blog系统_blog统计数据_添加", opType = LogAnnotionOpTypeEnum.EDIT) public ResponseData option(Long articleId, Integer option) { BlogArticle find = blogArticleService.lambdaQuery() .eq(BlogArticle::getIsEnable, MyConstant.Yes) .eq(BlogArticle::getEditorStatus, MyConstant.Yes) .eq(BlogArticle::getId, articleId) .one(); if (find == null) { throw new BlogException("查询不到相关日志"); } /** * 同一个ip,24小时之内只统计一次 访问次数,访问人数(ip) */ return null; } } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/controller/BlogArticleOutsideController.java
@@ -25,6 +25,7 @@ package vip.xiaonuo.modular.blogarticle.controller; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.PageUtil; import cn.hutool.core.util.StrUtil; @@ -41,9 +42,9 @@ import vip.xiaonuo.core.pojo.response.ResponseData; import vip.xiaonuo.core.pojo.response.SuccessResponseData; import vip.xiaonuo.modular.blogarticle.entity.BlogArticle; import vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo; import vip.xiaonuo.modular.blogarticle.param.BlogArticleAddDto; import vip.xiaonuo.modular.blogarticle.param.BlogArticleQueryDto; import vip.xiaonuo.modular.blogarticle.entity.BlogArticleVo; import vip.xiaonuo.modular.blogarticle.service.BlogArticleService; import vip.xiaonuo.modular.blogarticletype.entity.BlogArticleType; import vip.xiaonuo.modular.blogarticletype.service.BlogArticleTypeService; @@ -124,7 +125,7 @@ BlogArticle article = new BlogArticle(); BeanUtil.copyProperties(addDto, article); article.setSeparateYear(DateUtil.year(article.getPublishDate())); article.setSeparateMonth(DateUtil.month(article.getPublishDate())+1); article.setSeparateMonth(DateUtil.month(article.getPublishDate()) + 1); article.setSeparateDay(DateUtil.dayOfMonth(article.getPublishDate())); article.setIsEnable(MyConstant.Yes); @@ -149,6 +150,10 @@ param.put("typeId", queryDto.getTypeId()); String blogSourcePrefix = ConstantContextHolder.getBlogSourcePrefix(); Date now = DateUtil.date(); //空类型查询条件,排除笔记系列,按更新时间倒序 //含有类型查询,按发布时间倒序 List<BlogArticleVo> resList = blogArticleService.searchList(param).stream().map(e -> { if (StrUtil.isNotEmpty(e.getCoverFileURL())) { if (!e.getCoverFileURL().startsWith("http")) { @@ -156,6 +161,15 @@ e.setCoverFileURL(blogSourcePrefix + e.getCoverFileURL()); } } //前端根据条件标注小红点(发布时间和更新时间在7天内) if (e.getPublishDate().before(e.getUpdateDate()) && DateUtil.between(e.getUpdateDate(), now, DateUnit.DAY) <= 7) { e.setIsAnyUpdate(MyConstant.Yes); } else { e.setIsAnyUpdate(MyConstant.No); } return e; }).collect(Collectors.toList()); snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/entity/BlogArticleVo.java
@@ -93,6 +93,12 @@ private Date publishDate; /** * 更新时间 */ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") private Date updateDate; /** * 是否置顶 0:否 1:是 */ private Integer isTop; @@ -108,5 +114,10 @@ */ private Integer isAllowedComment; /** * 是否有任意更新 */ private Integer isAnyUpdate; } snowy-main/src/main/java/vip/xiaonuo/modular/blogarticle/mapper/mapping/BlogArticleMapper.xml
@@ -24,6 +24,7 @@ a.is_top, a.editor_status, a.is_allowed_comment, a.update_date, a.create_date </sql> @@ -35,9 +36,11 @@ <choose> <when test="param.typeId != null"> AND a.article_type_id = #{param.typeId} order by a.is_top desc,a.top_value asc , a.create_date desc </when> <otherwise> AND a.article_type_id != 4 order by a.is_top desc,a.top_value asc , a.update_date desc </otherwise> </choose> </trim> @@ -62,8 +65,6 @@ on f2.id=a.cover_file_id <include refid="queryListCondition"/> order by a.is_top desc,a.top_value asc , a.create_date desc limit #{param.pageNo},#{param.pageSize} </select> snowy-main/src/main/java/vip/xiaonuo/modular/blogarticlecomment/controller/BlogArticleCommentOutsideController.java
@@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.*; import vip.xiaonuo.core.annotion.BusinessLog; import vip.xiaonuo.core.consts.MyConstant; import vip.xiaonuo.core.context.constant.ConstantContextHolder; import vip.xiaonuo.core.email.MailSender; import vip.xiaonuo.core.email.modular.model.SendMailParam; import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum; @@ -81,6 +82,13 @@ public ResponseData add(@RequestBody @Validated(BlogArticleCommentAddDto.add.class) BlogArticleCommentAddDto addDto) { BlogArticle checkArticle = null; //自我认证 if (MyConstant.myIds.contains(addDto.getVisitorNickName())) { if (StrUtil.isEmpty(addDto.getAuthCode()) || !addDto.getAuthCode().equals(ConstantContextHolder.getAuthCode())) { throw new BlogException("不要成为我,你就是真的自己"); } } if (MyConstant.Yes.equals(addDto.getIsReceiveMail()) && StrUtil.isEmpty(addDto.getVisitorEmail())) { throw new BlogException("如果是想接收通知的话,你可能需要填上一个邮箱.."); } @@ -117,11 +125,11 @@ return new SuccessResponseData(); } //前一个留言接收邮件回复(发送给我的本体可以跳过.如果是给评论者自己的追加可以跳过) //前一个留言接收邮件回复(如果是给评论者自己的追加可以跳过) if (MyConstant.Yes.equals(lastComment.getIsReceiveCallback()) && StrUtil.isNotEmpty(lastComment.getVisitorEmail()) && !lastComment.getVisitorNickName().equals(MyConstant.inleft) && !lastComment.getVisitorEmail().equals(MyConstant.email) // && !lastComment.getVisitorNickName().equals(MyConstant.inleft) // && !lastComment.getVisitorEmail().equals(MyConstant.email) && !lastComment.getVisitorNickName().equals(addDto.getVisitorNickName()) && !lastComment.getVisitorEmail().equals(addDto.getVisitorEmail())) { snowy-main/src/main/java/vip/xiaonuo/modular/blogarticlecomment/param/BlogArticleCommentAddDto.java
@@ -109,4 +109,7 @@ @NotNull(message = "是否接收回信为空", groups = {add.class}) private Integer isReceiveMail; private String authCode; }