fix:投放业务

上级 3f2f6a70
......@@ -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<String> suggestLists) {
//通过获取 userinfo 的 buyProducts 属性
boolean newUser = userInfo.isNewUser();
if (newUser) {
suggestLists = new ArrayList<>(); // 特定的新用户奖励
//特定的新用户奖励
suggestLists = new ArrayList<>();
}
}
}
......@@ -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<String> suggestLists) {
//通过获取 userinfo 的 buyProducts 属性
......
......@@ -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<String> handlers;
/**
* 投放业务处理,需要用到配置中心,进行配置
*
* @param userInfo
* @param suggestLists
*/
public void process(UserInfo userInfo, List<String> suggestLists) {
// 如果想要实时的进行顺序的调整或者是增减。那必须要使用配置中心进行配置。
// 比如springcloud里边自带的 git 的这种配置中心; applo 配置中心。
try {
for(String handler : handlers) {
for (String handler : handlers) {
AbstractSuggestRequirementHandler handle =
(AbstractSuggestRequirementHandler) Class.forName(handler).newInstance();
handle.processHandler(userInfo, suggestLists);
......
......@@ -25,6 +25,13 @@ public class UserService {
@Autowired
private SuggestRequirementHandlerProcess suggestRequirementHandlerProcess;
/**
* 投放业务
*
* @param username
* @return
*/
public List<String> suggestRequirement(String username) {
//获取用户信息。因为用户已经登录了,那么user的信息是保存在我们的缓存里的。
UserInfo userInfo = getUserInfo(username);
......
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册