Skip to content

Commit

Permalink
fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Sep 15, 2023
1 parent 51a0172 commit 4cf518f
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public class JobAlerts extends BaseSchedule {
*/
@PostConstruct
public void init() {
refeshRulesData();
refreshRulesData();
addSchedule(AlertRuleOptions.JOB_ALERT_SCHEDULE, this::check, new PeriodicTrigger(1000 * 30));
}

Expand Down Expand Up @@ -170,7 +170,7 @@ protected void check() {
/**
* Refreshes the alert rules and related data.
*/
public void refeshRulesData() {
public void refreshRulesData() {
ruleFacts.put(AlertRuleOptions.JOB_ALERT_RULE_REFRESH_RULES_DATA, new ExceptionRule());
ruleFacts.put(AlertRuleOptions.JOB_ALERT_RULE_CHECKPOINT_RULES, new CheckpointsRule());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import com.fasterxml.jackson.databind.JsonNode;

import io.swagger.annotations.ApiImplicitParam;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
Expand All @@ -62,16 +63,31 @@ public ProTableResult<AlertRule> list(@RequestBody JsonNode para) {
}

@PutMapping
@ApiImplicitParam(
name = "alertRule",
value = "alertRule",
required = true,
dataType = "AlertRule",
paramType = "body",
dataTypeClass = AlertRule.class)
public Result<Boolean> saveOrUpdateAlertRule(@RequestBody AlertRule alertRule) {
boolean saved = alertRuleService.saveOrUpdate(alertRule);
if (saved) {
jobAlerts.refeshRulesData();
jobAlerts.refreshRulesData();
return Result.succeed(Status.MODIFY_SUCCESS);
}
return Result.failed(Status.MODIFY_FAILED);
}

@DeleteMapping
@ApiImplicitParam(
name = "id",
value = "id",
required = true,
dataType = "Integer",
paramType = "query",
dataTypeClass = Integer.class,
example = "1")
public Result<Boolean> deleteAlertRuleById(@RequestParam Integer id) {
if (alertRuleService.removeById(id)) {
return Result.succeed(Status.DELETE_SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiImplicitParam;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
Expand All @@ -50,14 +52,31 @@ public Result<List<AlertTemplate>> list() {
}

@DeleteMapping
@Log(title = "Delete AlertTemplate ", businessType = BusinessType.INSERT_OR_UPDATE)
public Result<Boolean> delete(int id) {
return Result.succeed(alertTemplateService.removeById(id));
@Log(title = "Delete AlertTemplate ", businessType = BusinessType.DELETE)
@ApiImplicitParam(
name = "id",
value = "AlertTemplate ID",
required = true,
dataType = "Integer",
paramType = "query",
example = "1")
public Result<Boolean> deleteAlertTemplateById(@RequestParam Integer id) {
if (alertTemplateService.removeById(id)) {
return Result.succeed(Status.DELETE_SUCCESS);
}
return Result.failed(Status.DELETE_FAILED);
}

@PutMapping
@Log(title = "Insert OR Update AlertTemplate ", businessType = BusinessType.INSERT_OR_UPDATE)
public Result<Void> put(@RequestBody AlertTemplate alertTemplate) {
@ApiImplicitParam(
name = "alertTemplate",
value = "AlertTemplate",
required = true,
dataType = "AlertTemplate",
paramType = "body",
dataTypeClass = AlertTemplate.class)
public Result<Void> saveOrUpdateAlertTemplate(@RequestBody AlertTemplate alertTemplate) {
if (alertTemplateService.saveOrUpdate(alertTemplate)) {
return Result.succeed(Status.SAVE_SUCCESS);
} else {
Expand Down
22 changes: 22 additions & 0 deletions dinky-admin/src/main/java/org/dinky/data/model/AlertRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import com.baomidou.mybatisplus.annotation.TableName;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
Expand All @@ -31,11 +33,31 @@
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("dinky_alert_rules")
@ApiModel(value = "AlertRule", description = "AlertRule")
public class AlertRule extends SuperEntity {

@ApiModelProperty(value = "rule", required = true, dataType = "String", example = "rule")
String rule;

@ApiModelProperty(value = "templateId", required = true, dataType = "int", example = "1")
int templateId;

@ApiModelProperty(
value = "ruleType",
required = true,
dataType = "String",
example = "ruleType",
allowableValues = "CUSTOM,SYSTEM")
String ruleType;

@ApiModelProperty(
value = "triggerConditions",
required = true,
dataType = "String",
example = "or",
allowableValues = "or,and")
String triggerConditions;

@ApiModelProperty(value = "description", required = true, dataType = "String", example = "description")
String description;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@

import com.baomidou.mybatisplus.annotation.TableName;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
@TableName("dinky_alert_template")
@ApiModel(value = "AlertTemplate", description = "AlertTemplate")
public class AlertTemplate extends SuperEntity {
@ApiModelProperty(value = "name", required = true, dataType = "String", example = "# 11 \n > 11")
String templateContent;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

import java.io.IOException;

import freemarker.template.TemplateException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import freemarker.template.TemplateException;

/**
* DingTalkAlert
*
* @since 2022/2/23 19:28
*/
public class DingTalkAlert extends AbstractAlert {

private static final Logger log = LoggerFactory.getLogger(DingTalkAlert.class);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
*
*/
public class DingTalkSender {

private static final Logger logger = LoggerFactory.getLogger(DingTalkSender.class);
private final String url;
private final String keyword;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
import org.commonmark.node.Node;
import org.commonmark.parser.Parser;
import org.commonmark.renderer.html.HtmlRenderer;

import freemarker.template.TemplateException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import freemarker.template.TemplateException;

/** EmailAlert */
public class EmailAlert extends AbstractAlert {
private static final Logger log = LoggerFactory.getLogger(EmailAlert.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class EmailConstants extends AlertBaseConstant {
public static final String XLS_FILE_PATH = "xls.file.path";
public static final String MAIL_TRANSPORT_PROTOCOL = "mail.transport.protocol";
public static final String XLS_FILE_DEFAULT_PATH = "/tmp/xls";

public static final String ALERT_TEMPLATE_TITLE = "title";
public static final String ALERT_TEMPLATE_CONTENT = "content";
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

/** FeiShuAlert */
public class FeiShuAlert extends AbstractAlert {

private static final Logger logger = LoggerFactory.getLogger(FeiShuAlert.class);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
/** FeiShuConstants */
public class FeiShuConstants extends AlertBaseConstant {
public static final String TYPE = "FeiShu";

public static final String SIGN_TMESTAMP = "timestamp";
public static final String SIGN = "sign";

public static final String ALERT_TEMPLATE_TITLE = "title";
public static final String ALERT_TEMPLATE_CONTENT = "content";
public static final String ALERT_TEMPLATE_KEYWORD = "keyword";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
* fei shu sender
*/
public final class FeiShuSender {

private static final Logger logger = LoggerFactory.getLogger(FeiShuSender.class);
private final String url;
private final String secret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.text.StrFormatter;
import freemarker.template.TemplateException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* WeChatAlert
*
* @since 2022/2/23 21:09
*/
public class WeChatAlert extends AbstractAlert {

private static final Logger logger = LoggerFactory.getLogger(WeChatAlert.class);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class WeChatConstants extends AlertBaseConstant {

public static final String WECHAT_TOKEN_URL =
"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}";

public static final String CORP_ID = "corpId";
public static final String TEAM_SEND_MSG = "teamSendMsg";
public static final String AGENT_ID = "agentId";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
* @since 2022/2/23 21:11
*/
public class WeChatSender {

private static final Logger logger = LoggerFactory.getLogger(WeChatSender.class);
private static final String CORP_ID_REGEX = "{corpId}";
private static final String SECRET_REGEX = "{secret}";
Expand Down

0 comments on commit 4cf518f

Please sign in to comment.