Browse Source

1.7 修改飞书报警

milestone-20251215-红包修改
huangqizhen 17 hours ago
parent
commit
b7551f7e7a
  1. 4
      src/main/java/com/example/demo/Util/FeiShuAlertUtil.java
  2. 14
      src/main/java/com/example/demo/config/EnvConfig.java
  3. 28
      src/main/java/com/example/demo/controller/Temporary/RedController.java

4
src/main/java/com/example/demo/Util/FeiShuAlertUtil.java

@ -28,7 +28,7 @@ public class FeiShuAlertUtil {
private static String webhookUrl;
private static final String FEISHU_WEBHOOK_URL_PROD = "https://open.feishu.cn/open-apis/bot/v2/hook/1a515b19-b64f-46b7-9486-35842b9539fe";
private static final String FEISHU_WEBHOOK_URL_TEST = webhookUrl;
private static final String FEISHU_WEBHOOK_URL_TEST = "https://open.feishu.cn/open-apis/bot/v2/hook/8dd2bcc4-6492-487b-9dc5-bb7b27d43ccf";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
static {
@ -115,7 +115,7 @@ public class FeiShuAlertUtil {
String FEISHU_WEBHOOK_URL;
String environment = EnvConfig.ENV;
System.out.println("当前环境变量:" + environment);
if (Objects.equals(environment, "unknown") || environment.equals("dev")) {
if (Objects.equals(environment, "unknown") || environment.equals("dev")|| environment.equals("test")) {
FEISHU_WEBHOOK_URL = FEISHU_WEBHOOK_URL_TEST;
} else {
FEISHU_WEBHOOK_URL = FEISHU_WEBHOOK_URL_PROD;

14
src/main/java/com/example/demo/config/EnvConfig.java

@ -1,6 +1,9 @@
package com.example.demo.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
/**
* @program: GOLD
@ -10,9 +13,12 @@ import org.springframework.context.annotation.Configuration;
* @create: 202506-29 13:55
* @Version 1.0
**/
@Configuration
@Component
public class EnvConfig {
public static final String ENV = "dev";
public static final String ENV_PROD = "prod";
public static final String ENV_TEST = "test";
public static String ENV;
@Value("${spring.profiles.active}")
public void setEnv(String env) {
EnvConfig.ENV = env;
}
}

28
src/main/java/com/example/demo/controller/Temporary/RedController.java

@ -1,8 +1,10 @@
package com.example.demo.controller.Temporary;
import com.example.demo.config.GlobalExceptionHandler;
import com.example.demo.domain.vo.Red;
import com.example.demo.domain.vo.coin.AuditRequest;
import com.example.demo.domain.vo.coin.Result;
import com.example.demo.exception.SystemException;
import com.example.demo.service.Temporary.RedService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -27,26 +29,29 @@ import java.math.BigDecimal;
public class RedController {
@Autowired
private RedService redService;
@Autowired
private GlobalExceptionHandler globalExceptionHandler;
@RequestMapping("/Red")
public Result selectSum(@RequestBody Red red) {
try {
redService.selectSum(red.getJwcode(),red.getType());
}
catch (Exception e) {
return Result.error(e.getMessage());
redService.selectSum(red.getJwcode(), red.getType());
} catch (Exception e) {
return Result.error(e.getMessage());
}
return Result.success(redService.selectSum(red.getJwcode(),red.getType()));
return Result.success(redService.selectSum(red.getJwcode(), red.getType()));
}
@RequestMapping("/RedList")
public Result selectRedList(@RequestBody Red red) {
try {
redService.selectRedList(red.getJwcode());
}
catch (Exception e) {
return Result.error(e.getMessage());
} catch (Exception e) {
return Result.error(e.getMessage());
}
return Result.success(redService.selectRedList(red.getJwcode()));
}
@RequestMapping("/RedTest")
public Result selectRedTest(@RequestBody AuditRequest request) throws Exception {
try {
@ -55,8 +60,15 @@ public class RedController {
}
catch (Exception e) {
return Result.error(e.getMessage());
//redService.checkRed(request.getPrice(), request.getLinkId());
}
return Result.success(redService.checkRed(request.getPrice(),request.getLinkId()));
// return Result.success(redService.consumeRed(request.getLinkId()));
//return Result.success(redService.checkRed(request.getPrice(), request.getLinkId()));
}
@RequestMapping("/ceshi")
public Result ceshi() {
throw new SystemException("测试异常");
}
}
Loading…
Cancel
Save