From 257e969523b62de8cf24db8f1701c99879b6be20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Sat, 29 Jul 2023 18:02:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=8A=95=E6=94=BE=E4=B8=9A=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/design/handler/NewCheckHandler.java | 11 ++++++++++- .../design/handler/RecentCheckHandler.java | 10 +++++++++- .../SuggestRequirementHandlerProcess.java | 17 ++++++++++++++++- .../com/study/design/service/UserService.java | 7 +++++++ src/main/resources/application.properties | 6 +++--- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/study/design/handler/NewCheckHandler.java b/src/main/java/com/study/design/handler/NewCheckHandler.java index ceaf65d..eca4940 100644 --- a/src/main/java/com/study/design/handler/NewCheckHandler.java +++ b/src/main/java/com/study/design/handler/NewCheckHandler.java @@ -5,13 +5,22 @@ import com.study.design.pojo.UserInfo; import java.util.ArrayList; import java.util.List; + +/** + * 新用户校验 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/29 17:47 + */ public class NewCheckHandler extends AbstractSuggestRequirementHandler { @Override public void processHandler(UserInfo userInfo, List suggestLists) { //通过获取 userinfo 的 buyProducts 属性 boolean newUser = userInfo.isNewUser(); if (newUser) { - suggestLists = new ArrayList<>(); // 特定的新用户奖励 + //特定的新用户奖励 + suggestLists = new ArrayList<>(); } } } diff --git a/src/main/java/com/study/design/handler/RecentCheckHandler.java b/src/main/java/com/study/design/handler/RecentCheckHandler.java index de2933d..4ad4079 100644 --- a/src/main/java/com/study/design/handler/RecentCheckHandler.java +++ b/src/main/java/com/study/design/handler/RecentCheckHandler.java @@ -4,7 +4,15 @@ import com.study.design.pojo.UserInfo; import java.util.List; -public class RecentCheckHandler extends AbstractSuggestRequirementHandler{ + +/** + * 最近购买校验 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/29 17:46 + */ +public class RecentCheckHandler extends AbstractSuggestRequirementHandler { @Override public void processHandler(UserInfo userInfo, List suggestLists) { //通过获取 userinfo 的 buyProducts 属性 diff --git a/src/main/java/com/study/design/handler/SuggestRequirementHandlerProcess.java b/src/main/java/com/study/design/handler/SuggestRequirementHandlerProcess.java index 2523e8d..90c8955 100644 --- a/src/main/java/com/study/design/handler/SuggestRequirementHandlerProcess.java +++ b/src/main/java/com/study/design/handler/SuggestRequirementHandlerProcess.java @@ -6,17 +6,32 @@ import org.springframework.stereotype.Component; import java.util.List; + +/** + * 封装Handler的执行类,间接调用 + * + * @author : qinyingjie + * @version : 2.2.0 + * @date : 2023/7/29 17:50 + */ @Component public class SuggestRequirementHandlerProcess { @Value("#{'${suggest.requirement.handler}'.split(',')}") private List handlers; + + /** + * 投放业务处理,需要用到配置中心,进行配置 + * + * @param userInfo + * @param suggestLists + */ public void process(UserInfo userInfo, List suggestLists) { // 如果想要实时的进行顺序的调整或者是增减。那必须要使用配置中心进行配置。 // 比如springcloud里边自带的 git 的这种配置中心; applo 配置中心。 try { - for(String handler : handlers) { + for (String handler : handlers) { AbstractSuggestRequirementHandler handle = (AbstractSuggestRequirementHandler) Class.forName(handler).newInstance(); handle.processHandler(userInfo, suggestLists); diff --git a/src/main/java/com/study/design/service/UserService.java b/src/main/java/com/study/design/service/UserService.java index d13847f..666ad15 100644 --- a/src/main/java/com/study/design/service/UserService.java +++ b/src/main/java/com/study/design/service/UserService.java @@ -25,6 +25,13 @@ public class UserService { @Autowired private SuggestRequirementHandlerProcess suggestRequirementHandlerProcess; + + /** + * 投放业务 + * + * @param username + * @return + */ public List suggestRequirement(String username) { //获取用户信息。因为用户已经登录了,那么user的信息是保存在我们的缓存里的。 UserInfo userInfo = getUserInfo(username); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 30d531d..9fd38f4 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,3 @@ -server.port = 8080 -### \u6BD4\u55BB\u6210\u914D\u7F6E\u4E2D\u5FC3 -suggest.requirement.handler = com.study.design.handler.PersonnalCheckHandler,com.study.design.handler.CityCheckHandler,com.study.design.handler.RecentCheckHandler,com.study.design.handler.NewCheckHandler \ No newline at end of file +server.port=8080 +### \u6BD4\u55BB\u6210\u914D\u7F6E\u4E2D\u5FC3,\u914D\u7F6E\u6295\u653E\u4E1A\u52A1\u7C7B +suggest.requirement.handler=com.study.design.handler.PersonnalCheckHandler,com.study.design.handler.CityCheckHandler,com.study.design.handler.RecentCheckHandler,com.study.design.handler.NewCheckHandler \ No newline at end of file -- GitLab