Compare commits
3 Commits
fd399c53b5
...
78e32fbbf1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78e32fbbf1 | ||
|
|
3edd22705e | ||
|
|
5a412dc22e |
@@ -3,7 +3,10 @@ package cn.van333.wxsend.aop.annotation;
|
||||
import cn.van333.wxsend.constant.CacheConstants;
|
||||
import cn.van333.wxsend.enums.LimitType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author Leo
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package cn.van333.wxsend.aop.aspectj;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import cn.van333.wxsend.aop.annotation.RateLimiter;
|
||||
import cn.van333.wxsend.enums.LimitType;
|
||||
import cn.van333.wxsend.exception.ServiceException;
|
||||
@@ -20,6 +16,10 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.script.RedisScript;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 限流处理
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package cn.van333.wxsend.business.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.van333.wxsend.aop.annotation.RateLimiter;
|
||||
import cn.van333.wxsend.business.model.R;
|
||||
import cn.van333.wxsend.business.service.LogService;
|
||||
import cn.van333.wxsend.enums.WXMessageType;
|
||||
import cn.van333.wxsend.util.SourceForQLUtil;
|
||||
import cn.van333.wxsend.util.TokenUtil;
|
||||
import cn.van333.wxsend.util.WxSendUtil;
|
||||
import cn.van333.wxsend.util.request.MessageRequest;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -18,8 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author Leo
|
||||
* @version 1.0
|
||||
|
||||
@@ -5,17 +5,19 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.van333.wxsend.aop.annotation.RateLimiter;
|
||||
import cn.van333.wxsend.business.model.R;
|
||||
import cn.van333.wxsend.business.service.LogService;
|
||||
import cn.van333.wxsend.util.TokenUtil;
|
||||
import cn.van333.wxsend.enums.WXMessageType;
|
||||
import cn.van333.wxsend.util.SourceForQLUtil;
|
||||
import cn.van333.wxsend.util.TokenUtil;
|
||||
import cn.van333.wxsend.util.WxSendUtil;
|
||||
import cn.van333.wxsend.util.request.MessageRequest;
|
||||
import cn.van333.wxsend.util.SourceForQLUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.rmi.CORBA.Util;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
@@ -82,6 +84,7 @@ public class WXController {
|
||||
logger.info("vanToken 打印---{}",vanToken);
|
||||
logger.info("source 打印---{}",source);
|
||||
String sourceForQL = SourceForQLUtil.transferSource(source);
|
||||
String a = "";
|
||||
if (!StrUtil.isAllNotEmpty(message.getTitle(), message.getText())) {
|
||||
return R.error("缺少标题和内容");
|
||||
}
|
||||
@@ -155,7 +158,7 @@ public class WXController {
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/send/lf")
|
||||
@RequestMapping(value = "/send/jenkins")
|
||||
@ResponseBody
|
||||
@RateLimiter(time = 5, count = 60)
|
||||
public R sendToLF(HttpServletRequest request, @RequestBody MessageRequest message) throws Exception {
|
||||
@@ -180,7 +183,7 @@ public class WXController {
|
||||
if (!StrUtil.isAllNotEmpty(message.getTitle(), message.getText())) {
|
||||
return R.error("缺少标题和内容");
|
||||
}
|
||||
String result = WxSendUtil.sendNotify("("+sourceForQL+") "+message.getTitle(), message.getText(), message.getTouser(), WXMessageType.LF);
|
||||
String result = WxSendUtil.sendNotify("("+sourceForQL+") "+message.getTitle(), message.getText(), message.getTouser(), WXMessageType.JENKINS);
|
||||
logger.info("result 打印---{}",result);
|
||||
return R.ok(result);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public enum WXMessageType {
|
||||
// TY
|
||||
TY("TY","1000006","ww929e7d6493c6336e","sGrNc8uBd_Wp6hmme2oP_Rh37scmgGulPuCHiQ9PYcc"),
|
||||
JD("JD","1000008","ww929e7d6493c6336e","neXT6KJ8FYVLR-LN455MAcFaeUYkVaTsAkIOqXx3wLA"),
|
||||
LF("LF","1000009","ww929e7d6493c6336e","msWg3ugSSRFIXeWZuoGKN2MI2Kg9AJVAG6pCWFEeH5E"),;
|
||||
JENKINS("JENKINS","1000009","ww929e7d6493c6336e","msWg3ugSSRFIXeWZuoGKN2MI2Kg9AJVAG6pCWFEeH5E"),;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package cn.van333.wxsend.exception;
|
||||
|
||||
import cn.van333.wxsend.business.model.R;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package cn.van333.wxsend.util;
|
||||
|
||||
|
||||
import cn.hutool.extra.template.Template;
|
||||
import cn.hutool.extra.template.engine.velocity.VelocityEngine;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import javax.activation.DataSource;
|
||||
@@ -55,7 +48,7 @@ public class QCUtil {
|
||||
* @param msg
|
||||
*/
|
||||
public static final void consume(long start, long end, String msg) {
|
||||
System.err.println(String.format("%s consume times: %s=%s-%s", msg, (end - start), end, start));
|
||||
System.err.printf("%s consume times: %s=%s-%s%n", msg, (end - start), end, start);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package cn.van333.wxsend.util.str;
|
||||
|
||||
import cn.van333.wxsend.util.str.StringUtils;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user