Skip to content

Commit

Permalink
java-module: Fix API errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Oct 14, 2024
1 parent 134494f commit 4176096
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ public ResBody<List<InfluxDBInfo>> list() {

@GetMapping("/measurement")
public ResBody<List<MeasurementFieldInfo>> measurement() {
InfluxDBInfo influxDBInfo = influxDBMapper.getInfluxDBInfoList().get(1);
InfluxDBInfo influxDBInfo = influxDBMapper.getInfluxDBInfoList().get(0);
return influxDBService.getFields(influxDBInfo);
}

@GetMapping("/tag")
public ResBody<List<MeasurementTagInfo>> tag() {
InfluxDBInfo influxDBInfo = influxDBMapper.getInfluxDBInfoList().get(1);
InfluxDBInfo influxDBInfo = influxDBMapper.getInfluxDBInfoList().get(0);
return influxDBService.getTags(influxDBInfo);
}

@PostMapping("/metric")
public ResBody<List<MetricInfo>> metric(@RequestBody MetricsInfo metricsInfo) {
ResBody<List<MetricInfo>> resBody = new ResBody<>();
InfluxDBInfo influxDBInfo = influxDBMapper.getInfluxDBInfoList().get(1);
InfluxDBInfo influxDBInfo = influxDBMapper.getInfluxDBInfoList().get(0);
resBody.setData(influxDBService.getMetrics(influxDBInfo, metricsInfo));
return resBody;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public ResBody update(@PathVariable String nsId, @PathVariable String mciId, @Pa
monitoringConfigInfo.setNsId(nsId);
monitoringConfigInfo.setMciId(mciId);
monitoringConfigInfo.setTargetId(targetId);
monitoringConfigInfo.setName(itemUpdateInfo.getName());
monitoringConfigInfo.setPluginSeq(itemUpdateInfo.getPluginSeq());
monitoringConfigInfo.setPluginConfig(itemUpdateInfo.getPluginConfig());

return monitoringConfigService.update(nsId, mciId, targetId, monitoringConfigInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ public ResBody update(@PathVariable String nsId, @PathVariable String mciId, @Pa
monitoringConfigInfo.setNsId(nsId);
monitoringConfigInfo.setMciId(mciId);
monitoringConfigInfo.setTargetId(targetId);
monitoringConfigInfo.setName(storageUpdateInfo.getName());
monitoringConfigInfo.setPluginSeq(storageUpdateInfo.getPluginSeq());
monitoringConfigInfo.setPluginConfig(storageUpdateInfo.getPluginConfig());

return monitoringConfigService.update(nsId, mciId, targetId, monitoringConfigInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ public class MonitoringConfigInfoUpdateDTO {
@JsonProperty(value = "seq")
private Long seq;

@Base64EncodeField
@Base64DecodeField
@JsonProperty("name")
private String name;

@JsonProperty("plugin_seq")
private Long pluginSeq;

@Base64EncodeField
@Base64DecodeField
@JsonProperty("plugin_config")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import mcmp.mc.observability.mco11yagent.monitoring.annotation.Base64EncodeField;
import mcmp.mc.observability.mco11yagent.monitoring.enums.ResultCode;

@Setter
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResBody<T> {
@Builder.Default
@JsonIgnore
private ResultCode code = ResultCode.SUCCESS;
private ResultCode code;

@Base64EncodeField
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand All @@ -35,6 +32,19 @@ public class ResBody<T> {
@JsonProperty("rs_msg")
private String rsMsg;

public ResBody() {
this.setCode(ResultCode.SUCCESS);
}

public ResBody(ResultCode code) {
this.setCode(code);
}

public ResBody(ResultCode code, T data) {
this.setCode(code);
this.data = data;
}

public void setCode(ResultCode code) {
this.code = code;
this.rsCode = code.getCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ResBody update(String nsId, String mciId, String targetId, MonitoringConf
monitoringConfigInfo.setMciId(mciId);
monitoringConfigInfo.setTargetId(targetId);

PluginDefInfo pluginDefInfo = pluginMapper.getPlugin(monitoringConfigInfo.getPluginSeq());
PluginDefInfo pluginDefInfo = pluginMapper.getPlugin(originalConfig.getPluginSeq());
monitoringConfigInfo.setPluginName(pluginDefInfo.getName());
monitoringConfigInfo.setPluginType(pluginDefInfo.getPluginType());

Expand Down

0 comments on commit 4176096

Please sign in to comment.