From 837cdec2e60cd983eeb36908a76f9bb366017659 Mon Sep 17 00:00:00 2001 From: ronger Date: Sat, 10 Jul 2021 09:47:23 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:bug:=20=E5=85=BC=E5=AE=B9=20token=20?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E6=83=85=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../forest/core/service/log/VisitAspect.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/rymcu/forest/core/service/log/VisitAspect.java b/src/main/java/com/rymcu/forest/core/service/log/VisitAspect.java index 0f51467..809e7ff 100644 --- a/src/main/java/com/rymcu/forest/core/service/log/VisitAspect.java +++ b/src/main/java/com/rymcu/forest/core/service/log/VisitAspect.java @@ -22,13 +22,11 @@ import org.springframework.web.servlet.HandlerMapping; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * 浏览 + * * @author ronger */ @Aspect @@ -43,7 +41,8 @@ public class VisitAspect { private VisitService visitService; @Pointcut("@annotation(com.rymcu.forest.core.service.log.annotation.VisitLogger)") - public void pointCut() {} + public void pointCut() { + } /** * 保存系统操作日志 @@ -52,7 +51,7 @@ public class VisitAspect { * @return 方法执行结果 * @throws Throwable 调用出错 */ - @AfterReturning(value = "pointCut()", returning="obj") + @AfterReturning(value = "pointCut()", returning = "obj") public void save(JoinPoint joinPoint, Object obj) { logger.info("保存访问记录 start ..."); HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); @@ -69,9 +68,11 @@ public class VisitAspect { visit.setVisitRefererUrl(referer); visit.setCreatedTime(new Date()); String authHeader = request.getHeader(JwtConstants.AUTHORIZATION); - if(StringUtils.isNotBlank(authHeader)){ + if (StringUtils.isNotBlank(authHeader)) { TokenUser tokenUser = UserUtils.getTokenUser(authHeader); - visit.setVisitUserId(tokenUser.getIdUser()); + if (Objects.nonNull(tokenUser)) { + visit.setVisitUserId(tokenUser.getIdUser()); + } } visitService.save(visit); From 745389caaee5149c57b1c35145688e4392414961 Mon Sep 17 00:00:00 2001 From: ronger Date: Thu, 5 Aug 2021 10:51:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:art:=20=E4=B8=93=E9=A2=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java | 2 +- src/main/java/com/rymcu/forest/service/PortfolioService.java | 2 +- .../com/rymcu/forest/service/impl/PortfolioServiceImpl.java | 2 +- .../com/rymcu/forest/web/api/common/CommonApiController.java | 4 ++-- src/main/java/mapper/PortfolioMapper.xml | 5 +++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java b/src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java index d90c0b0..c926b1c 100644 --- a/src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/PortfolioMapper.java @@ -78,5 +78,5 @@ public interface PortfolioMapper extends Mapper { * 获取作品集列表数据 * @return */ - List selectPortfolios(); + List selectPortfolios(); } diff --git a/src/main/java/com/rymcu/forest/service/PortfolioService.java b/src/main/java/com/rymcu/forest/service/PortfolioService.java index db6d67c..bae6059 100644 --- a/src/main/java/com/rymcu/forest/service/PortfolioService.java +++ b/src/main/java/com/rymcu/forest/service/PortfolioService.java @@ -82,5 +82,5 @@ public interface PortfolioService extends Service { * 获取作品集列表数据 * @return */ - List findPortfolios(); + List findPortfolios(); } diff --git a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java index c7a9c1d..e82539e 100644 --- a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java @@ -199,7 +199,7 @@ public class PortfolioServiceImpl extends AbstractService implements } @Override - public List findPortfolios() { + public List findPortfolios() { return portfolioMapper.selectPortfolios(); } diff --git a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java index 27980fa..7bd8e3b 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/CommonApiController.java @@ -147,8 +147,8 @@ public class CommonApiController { @GetMapping("/portfolios") public GlobalResult portfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows) { PageHelper.startPage(page, rows); - List list = portfolioService.findPortfolios(); - PageInfo pageInfo = new PageInfo(list); + List list = portfolioService.findPortfolios(); + PageInfo pageInfo = new PageInfo(list); Map map = new HashMap(2); map.put("portfolios", pageInfo.getList()); Map pagination = Utils.getPagination(pageInfo); diff --git a/src/main/java/mapper/PortfolioMapper.xml b/src/main/java/mapper/PortfolioMapper.xml index ad1ebbc..815be1c 100644 --- a/src/main/java/mapper/PortfolioMapper.xml +++ b/src/main/java/mapper/PortfolioMapper.xml @@ -17,6 +17,7 @@ + insert into forest_portfolio_article (id_portfolio, id_article, sort_no) values (#{idPortfolio}, #{idArticle}, #{maxSortNo}) @@ -51,8 +52,8 @@ - + select fp.*,fpa.numbers from forest_portfolio fp left join (select id_portfolio, count(id_portfolio) numbers from forest_portfolio_article group by id_portfolio) fpa on fp.id = fpa.id_portfolio order by fpa.numbers desc, updated_time desc \ No newline at end of file From 5f95797faa596f729f4180923f12e42f623e729f Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 11 Aug 2021 13:31:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:art:=20=E4=B8=93=E9=A2=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/forest/service/impl/PortfolioServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java index e82539e..ea40a5f 100644 --- a/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/PortfolioServiceImpl.java @@ -45,6 +45,8 @@ public class PortfolioServiceImpl extends AbstractService implements Author author = userService.selectAuthor(userDTO.getIdUser()); list.forEach(portfolioDTO -> { genPortfolioAuthor(portfolioDTO,author); + Integer articleNumber = portfolioMapper.selectCountArticleNumber(portfolioDTO.getIdPortfolio()); + portfolioDTO.setArticleNumber(articleNumber); }); return list; }