Compare commits

...

3 Commits

Author SHA1 Message Date
雷欧(林平凡)
78e32fbbf1 1 2025-07-29 16:28:29 +08:00
雷欧(林平凡)
3edd22705e 1 2025-07-29 16:04:54 +08:00
雷欧(林平凡)
5a412dc22e 1 2025-02-11 16:01:56 +08:00
8 changed files with 19 additions and 29 deletions

View File

@@ -3,7 +3,10 @@ package cn.van333.wxsend.aop.annotation;
import cn.van333.wxsend.constant.CacheConstants; import cn.van333.wxsend.constant.CacheConstants;
import cn.van333.wxsend.enums.LimitType; 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 * @author Leo

View File

@@ -1,9 +1,5 @@
package cn.van333.wxsend.aop.aspectj; 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.aop.annotation.RateLimiter;
import cn.van333.wxsend.enums.LimitType; import cn.van333.wxsend.enums.LimitType;
import cn.van333.wxsend.exception.ServiceException; 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.data.redis.core.script.RedisScript;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
/** /**
* 限流处理 * 限流处理

View File

@@ -1,16 +1,13 @@
package cn.van333.wxsend.business.controller; package cn.van333.wxsend.business.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.van333.wxsend.aop.annotation.RateLimiter; import cn.van333.wxsend.aop.annotation.RateLimiter;
import cn.van333.wxsend.business.model.R; import cn.van333.wxsend.business.model.R;
import cn.van333.wxsend.business.service.LogService; import cn.van333.wxsend.business.service.LogService;
import cn.van333.wxsend.enums.WXMessageType; import cn.van333.wxsend.enums.WXMessageType;
import cn.van333.wxsend.util.SourceForQLUtil;
import cn.van333.wxsend.util.TokenUtil; import cn.van333.wxsend.util.TokenUtil;
import cn.van333.wxsend.util.WxSendUtil; import cn.van333.wxsend.util.WxSendUtil;
import cn.van333.wxsend.util.request.MessageRequest; import cn.van333.wxsend.util.request.MessageRequest;
import com.alibaba.fastjson2.JSON;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody; 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.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/** /**
* @author Leo * @author Leo
* @version 1.0 * @version 1.0

View File

@@ -5,17 +5,19 @@ import cn.hutool.core.util.StrUtil;
import cn.van333.wxsend.aop.annotation.RateLimiter; import cn.van333.wxsend.aop.annotation.RateLimiter;
import cn.van333.wxsend.business.model.R; import cn.van333.wxsend.business.model.R;
import cn.van333.wxsend.business.service.LogService; import cn.van333.wxsend.business.service.LogService;
import cn.van333.wxsend.util.TokenUtil;
import cn.van333.wxsend.enums.WXMessageType; 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.WxSendUtil;
import cn.van333.wxsend.util.request.MessageRequest; import cn.van333.wxsend.util.request.MessageRequest;
import cn.van333.wxsend.util.SourceForQLUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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; import javax.servlet.http.HttpServletRequest;
/** /**
@@ -82,6 +84,7 @@ public class WXController {
logger.info("vanToken 打印---{}",vanToken); logger.info("vanToken 打印---{}",vanToken);
logger.info("source 打印---{}",source); logger.info("source 打印---{}",source);
String sourceForQL = SourceForQLUtil.transferSource(source); String sourceForQL = SourceForQLUtil.transferSource(source);
String a = "";
if (!StrUtil.isAllNotEmpty(message.getTitle(), message.getText())) { if (!StrUtil.isAllNotEmpty(message.getTitle(), message.getText())) {
return R.error("缺少标题和内容"); return R.error("缺少标题和内容");
} }
@@ -155,7 +158,7 @@ public class WXController {
return R.ok(result); return R.ok(result);
} }
@RequestMapping(value = "/send/lf") @RequestMapping(value = "/send/jenkins")
@ResponseBody @ResponseBody
@RateLimiter(time = 5, count = 60) @RateLimiter(time = 5, count = 60)
public R sendToLF(HttpServletRequest request, @RequestBody MessageRequest message) throws Exception { public R sendToLF(HttpServletRequest request, @RequestBody MessageRequest message) throws Exception {
@@ -180,7 +183,7 @@ public class WXController {
if (!StrUtil.isAllNotEmpty(message.getTitle(), message.getText())) { if (!StrUtil.isAllNotEmpty(message.getTitle(), message.getText())) {
return R.error("缺少标题和内容"); 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); logger.info("result 打印---{}",result);
return R.ok(result); return R.ok(result);

View File

@@ -19,7 +19,7 @@ public enum WXMessageType {
// TY // TY
TY("TY","1000006","ww929e7d6493c6336e","sGrNc8uBd_Wp6hmme2oP_Rh37scmgGulPuCHiQ9PYcc"), TY("TY","1000006","ww929e7d6493c6336e","sGrNc8uBd_Wp6hmme2oP_Rh37scmgGulPuCHiQ9PYcc"),
JD("JD","1000008","ww929e7d6493c6336e","neXT6KJ8FYVLR-LN455MAcFaeUYkVaTsAkIOqXx3wLA"), JD("JD","1000008","ww929e7d6493c6336e","neXT6KJ8FYVLR-LN455MAcFaeUYkVaTsAkIOqXx3wLA"),
LF("LF","1000009","ww929e7d6493c6336e","msWg3ugSSRFIXeWZuoGKN2MI2Kg9AJVAG6pCWFEeH5E"),; JENKINS("JENKINS","1000009","ww929e7d6493c6336e","msWg3ugSSRFIXeWZuoGKN2MI2Kg9AJVAG6pCWFEeH5E"),;

View File

@@ -1,8 +1,6 @@
package cn.van333.wxsend.exception; package cn.van333.wxsend.exception;
import cn.van333.wxsend.business.model.R; 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.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;

View File

@@ -1,16 +1,9 @@
package cn.van333.wxsend.util; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment; 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 org.springframework.web.util.HtmlUtils;
import javax.activation.DataSource; import javax.activation.DataSource;
@@ -55,7 +48,7 @@ public class QCUtil {
* @param msg * @param msg
*/ */
public static final void consume(long start, long end, String 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);
} }
/** /**

View File

@@ -1,7 +1,5 @@
package cn.van333.wxsend.util.str; package cn.van333.wxsend.util.str;
import cn.van333.wxsend.util.str.StringUtils;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;