diff --git a/aizuda-robot-example/build.gradle b/aizuda-robot-example/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..168d674011b7cddec220bfb9ff63b7a5aeabd5de --- /dev/null +++ b/aizuda-robot-example/build.gradle @@ -0,0 +1,5 @@ +description "测试异常推送" + +dependencies { + implementation('com.aizuda:aizuda-robot:0.0.1') +} diff --git a/aizuda-robot-example/src/main/java/com/aizuda/exception/ExceptionApplication.java b/aizuda-robot-example/src/main/java/com/aizuda/exception/ExceptionApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..390ba40768acf021d2abe763dea90602df918cd7 --- /dev/null +++ b/aizuda-robot-example/src/main/java/com/aizuda/exception/ExceptionApplication.java @@ -0,0 +1,18 @@ +package com.aizuda.exception; + +import com.aizuda.robot.annotation.EnableRobot; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author LoveHuahua + * @date 2021年11月21日 21:44 + * @description believe in yourself + */ +@SpringBootApplication +@EnableRobot +public class ExceptionApplication { + public static void main(String[] args) { + SpringApplication.run(ExceptionApplication.class, args); + } +} diff --git a/aizuda-robot-example/src/main/java/com/aizuda/exception/controller/TestController.java b/aizuda-robot-example/src/main/java/com/aizuda/exception/controller/TestController.java new file mode 100644 index 0000000000000000000000000000000000000000..bd1d356f22fcd07df3f8f40b79b098bd28c64c5c --- /dev/null +++ b/aizuda-robot-example/src/main/java/com/aizuda/exception/controller/TestController.java @@ -0,0 +1,36 @@ +package com.aizuda.exception.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * @author LoveHuahua + * @date 2021年11月21日 21:41 + * @description believe in yourself + */ +@RestController +public class TestController { + + /** + * 测试controller的异常 + * + * @param param 参数 + * @return {@link Object} + */ + @GetMapping("testException") + public Object test(Integer param) { + //这里测试空指针 + if (param == null) { + return param.intValue(); + } + //这里测试除以0的异常 + if (param == 0) { + return 1 / param; + } + if (param == 100) { + return "运行成功"; + } + throw new RuntimeException("运行时异常"); + } +} diff --git a/aizuda-robot-example/src/main/resources/application.yml b/aizuda-robot-example/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..3a09bbfb3bed3218e04625acf9a7ed7fcbc99c7c --- /dev/null +++ b/aizuda-robot-example/src/main/resources/application.yml @@ -0,0 +1,10 @@ +spring: + main: + allow-bean-definition-overriding: true +logging: + level: + com.aizuda: debug +aizuda: + robot: + wechatKey: 05dd1746-7719-4548-bbb9-xxxxxxxx + dingToken: 85f737a9e8cefbd78712762c9a5ffxxxxxxxxxx diff --git a/settings.gradle b/settings.gradle index 756142ad22ec2c75fb0a68b33ddc1528ab7ca15f..2165cca1acac1e14b5527ea8529d0a5098827adc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,4 +4,5 @@ rootProject.name = 'aizuda-components-examples' // 每个人都是架构师 include 'aizuda-limiter-example' include 'aizuda-security-example' +include 'aizuda-robot-example'