parent
01061c6093
commit
15220b5cee
@ -0,0 +1,52 @@
|
||||
package com.java3y.austin.handler;
|
||||
|
||||
import com.java3y.austin.domain.AnchorInfo;
|
||||
import com.java3y.austin.domain.TaskInfo;
|
||||
import com.java3y.austin.enums.AnchorState;
|
||||
import com.java3y.austin.utils.LogUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @author 3y
|
||||
* 发送各个渠道的handler
|
||||
*/
|
||||
public abstract class BaseHandler implements Handler {
|
||||
|
||||
/**
|
||||
* 标识渠道的Code
|
||||
* 子类初始化的时候指定
|
||||
*/
|
||||
protected Integer channelCode;
|
||||
|
||||
|
||||
@Autowired
|
||||
private HandlerHolder handlerHolder;
|
||||
|
||||
/**
|
||||
* 初始化渠道与Handler的映射关系
|
||||
*/
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
handlerHolder.putHandler(channelCode, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doHandler(TaskInfo taskInfo) {
|
||||
if (handler(taskInfo)) {
|
||||
LogUtils.print(AnchorInfo.builder().state(AnchorState.SEND_SUCCESS.getCode()).businessId(taskInfo.getBusinessId()).ids(taskInfo.getReceiver()).build());
|
||||
return;
|
||||
}
|
||||
LogUtils.print(AnchorInfo.builder().state(AnchorState.SEND_FAIL.getCode()).businessId(taskInfo.getBusinessId()).ids(taskInfo.getReceiver()).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一处理的handler接口
|
||||
*
|
||||
* @param taskInfo
|
||||
* @return
|
||||
*/
|
||||
public abstract boolean handler(TaskInfo taskInfo);
|
||||
|
||||
}
|
@ -1,51 +1,17 @@
|
||||
package com.java3y.austin.handler;
|
||||
|
||||
import com.java3y.austin.domain.AnchorInfo;
|
||||
import com.java3y.austin.domain.TaskInfo;
|
||||
import com.java3y.austin.enums.AnchorState;
|
||||
import com.java3y.austin.utils.LogUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @author 3y
|
||||
* 发送各个渠道的handler
|
||||
*/
|
||||
public abstract class Handler {
|
||||
|
||||
/**
|
||||
* 标识渠道的Code
|
||||
* 子类初始化的时候指定
|
||||
* 消息处理器
|
||||
*/
|
||||
protected Integer channelCode;
|
||||
|
||||
|
||||
@Autowired
|
||||
private HandlerHolder handlerHolder;
|
||||
|
||||
/**
|
||||
* 初始化渠道与Handler的映射关系
|
||||
*/
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
handlerHolder.putHandler(channelCode, this);
|
||||
}
|
||||
|
||||
public void doHandler(TaskInfo taskInfo) {
|
||||
if (handler(taskInfo)) {
|
||||
LogUtils.print(AnchorInfo.builder().state(AnchorState.SEND_SUCCESS.getCode()).businessId(taskInfo.getBusinessId()).ids(taskInfo.getReceiver()).build());
|
||||
return;
|
||||
}
|
||||
LogUtils.print(AnchorInfo.builder().state(AnchorState.SEND_FAIL.getCode()).businessId(taskInfo.getBusinessId()).ids(taskInfo.getReceiver()).build());
|
||||
}
|
||||
public interface Handler {
|
||||
|
||||
/**
|
||||
* 统一处理的handler接口
|
||||
*
|
||||
* 处理器
|
||||
* @param taskInfo
|
||||
* @return
|
||||
*/
|
||||
public abstract boolean handler(TaskInfo taskInfo);
|
||||
void doHandler(TaskInfo taskInfo);
|
||||
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
package com.java3y.austin.controller;
|
||||
|
||||
import com.ctrip.framework.apollo.Config;
|
||||
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class ApolloController {
|
||||
|
||||
@ApolloConfig("boss.austin")
|
||||
private Config config;
|
||||
|
||||
@RequestMapping("/apollo")
|
||||
public String testApollo() {
|
||||
return config.getProperty("a", "b");
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.java3y.austin.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author 3y
|
||||
* @date 2021/12/9
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
public class RedisController {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
|
||||
@RequestMapping("/redis")
|
||||
public void testRedis() {
|
||||
log.info(redisTemplate.opsForValue().get("1"));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue