[monitor] 新增banner,定义监控类型管理接口
This commit is contained in:
@@ -48,4 +48,8 @@ public class Message<T> {
|
||||
public Message(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Message(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<properties>
|
||||
<mysql.version>8.0.16</mysql.version>
|
||||
<snake.yaml.version>1.26</snake.yaml.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -68,6 +69,12 @@
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<!-- yaml file load -->
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>${snake.yaml.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.usthe.manager.controller;
|
||||
|
||||
import com.usthe.common.entity.dto.Message;
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.manager.service.AppService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 监控类型管理API
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 16:47
|
||||
*/
|
||||
@Api(tags = "监控类型管理API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/apps")
|
||||
public class AppController {
|
||||
|
||||
@Autowired
|
||||
private AppService appService;
|
||||
|
||||
@GetMapping(path = "/{app}/params")
|
||||
@ApiOperation(value = "查询监控类型的参数结构", notes = "根据app查询指定监控类型的需要输入参数的结构")
|
||||
public ResponseEntity<Message<List<ParamDefine>>> queryAppParamDefines(@PathVariable("app") String app) {
|
||||
List<ParamDefine> paramDefines = appService.getAppParamDefines(app);
|
||||
return ResponseEntity.ok(new Message<>(paramDefines));
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询全部层级的监控类型", notes = "查询所有监控类型,以层级结构输出")
|
||||
public ResponseEntity<Message<Object>> queryAppsHierarchy() {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.usthe.common.entity.dto.Message;
|
||||
import com.usthe.manager.pojo.dto.MonitorDto;
|
||||
import com.usthe.manager.service.MonitorService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@@ -23,7 +24,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 10:57
|
||||
*/
|
||||
@Api(tags = "监控管理接口")
|
||||
@Api(tags = "监控管理API")
|
||||
@RestController
|
||||
@RequestMapping(path = "/monitor", consumes = {APPLICATION_JSON_VALUE}, produces = {APPLICATION_JSON_VALUE})
|
||||
public class MonitorController {
|
||||
@@ -32,6 +33,7 @@ public class MonitorController {
|
||||
private MonitorService monitorService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增监控", notes = "新增一个监控应用")
|
||||
public ResponseEntity<Message<Void>> addNewMonitor(@RequestBody MonitorDto monitorDto) {
|
||||
// 校验请求数据
|
||||
monitorService.validate(monitorDto, false);
|
||||
@@ -44,6 +46,7 @@ public class MonitorController {
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改监控", notes = "修改一个已存在监控应用")
|
||||
public ResponseEntity<Message<Void>> modifyMonitor(@RequestBody MonitorDto monitorDto) {
|
||||
// 校验请求数据
|
||||
monitorService.validate(monitorDto, true);
|
||||
@@ -56,6 +59,7 @@ public class MonitorController {
|
||||
}
|
||||
|
||||
@GetMapping(path = "/{id}")
|
||||
@ApiOperation(value = "查询监控", notes = "根据监控ID获取监控信息")
|
||||
public ResponseEntity<Message<MonitorDto>> getMonitor(@PathVariable("id") long id) {
|
||||
// 获取监控信息
|
||||
MonitorDto monitorDto = monitorService.getMonitor(id);
|
||||
@@ -69,6 +73,7 @@ public class MonitorController {
|
||||
}
|
||||
|
||||
@DeleteMapping(path = "/{id}")
|
||||
@ApiOperation(value = "删除监控", notes = "根据监控ID删除监控应用,监控不存在也是删除成功")
|
||||
public ResponseEntity<Message<Void>> deleteMonitor(@PathVariable("id") long id) {
|
||||
// 删除监控,监控不存在或删除成功都返回成功
|
||||
monitorService.deleteMonitor(id);
|
||||
@@ -76,6 +81,7 @@ public class MonitorController {
|
||||
}
|
||||
|
||||
@PostMapping(path = "/detect")
|
||||
@ApiOperation(value = "探测监控", notes = "根据监控信息去对此监控进行可用性探测")
|
||||
public ResponseEntity<Message<Void>> detectMonitor(@RequestBody MonitorDto monitorDto) {
|
||||
monitorService.validate(monitorDto, false);
|
||||
monitorService.detectMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.usthe.manager.dao;
|
||||
|
||||
import com.usthe.manager.pojo.entity.Monitor;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import sun.security.util.AuthResources;
|
||||
|
||||
/**
|
||||
* AuthResources 数据库操作
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 11:24
|
||||
*/
|
||||
public interface MonitorDao extends JpaRepository<AuthResources, Long> {
|
||||
public interface MonitorDao extends JpaRepository<Monitor, Long> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.usthe.manager.dao;
|
||||
|
||||
import com.usthe.manager.pojo.entity.Param;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
@@ -7,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 11:26
|
||||
*/
|
||||
public interface ParamDao extends JpaRepository<ParamDao, Long> {
|
||||
public interface ParamDao extends JpaRepository<Param, Long> {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.usthe.manager.pojo.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -12,6 +14,9 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* 监控参数值
|
||||
* @author tomsun28
|
||||
@@ -23,40 +28,48 @@ import java.time.LocalDateTime;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "参数实体")
|
||||
public class Param {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "参数ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 监控ID
|
||||
*/
|
||||
@ApiModelProperty(value = "监控ID", example = "875846754543", accessMode = READ_WRITE, position = 1)
|
||||
private Long monitorId;
|
||||
|
||||
/**
|
||||
* 参数字段标识符
|
||||
*/
|
||||
@ApiModelProperty(value = "参数标识符字段", example = "port", accessMode = READ_WRITE, position = 2)
|
||||
private String field;
|
||||
|
||||
/**
|
||||
* 参数值
|
||||
*/
|
||||
@ApiModelProperty(value = "参数值", example = "8080", accessMode = READ_WRITE, position = 3)
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 参数类型 0:数字 1:字符串 2:加密串
|
||||
*/
|
||||
@ApiModelProperty(value = "参数类型 0:数字 1:字符串 2:加密串", example = "0", accessMode = READ_WRITE, position = 4)
|
||||
private byte type;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 5)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 6)
|
||||
private LocalDateTime gmtUpdate;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.usthe.manager.pojo.entity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -13,6 +15,9 @@ import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||
|
||||
/**
|
||||
* 监控参数定义
|
||||
* @author tomsun28
|
||||
@@ -24,41 +29,49 @@ import java.time.LocalDateTime;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(description = "参数结构定义实体")
|
||||
public class ParamDefine {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ApiModelProperty(value = "参数结构ID", example = "87584674384", accessMode = READ_ONLY, position = 0)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 监控应用类型名称
|
||||
*/
|
||||
@ApiModelProperty(value = "监控类型", example = "api", accessMode = READ_WRITE, position = 1)
|
||||
private String app;
|
||||
|
||||
/**
|
||||
* 参数字段对外显示名称
|
||||
*/
|
||||
@ApiModelProperty(value = "参数字段显示名称", example = "端口", accessMode = READ_WRITE, position = 2)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 参数字段标识符
|
||||
*/
|
||||
@ApiModelProperty(value = "参数字段标识符", example = "port", accessMode = READ_WRITE, position = 3)
|
||||
private String field;
|
||||
|
||||
/**
|
||||
* 字段类型,样式(大部分映射input标签type属性)
|
||||
*/
|
||||
@ApiModelProperty(value = "字段类型,样式(大部分映射input标签type属性)", example = "number", accessMode = READ_WRITE, position = 4)
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 当type为number时,用range表示范围 eg: 0-233
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为number时,用range表示范围", example = "0-233", accessMode = READ_WRITE, position = 5)
|
||||
@Column(name = "param_range")
|
||||
private String range;
|
||||
|
||||
/**
|
||||
* 当type为text时,用limit表示字符串限制大小.最大255
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为text时,用limit表示字符串限制大小.最大255", example = "30", accessMode = READ_WRITE, position = 6)
|
||||
@Column(name = "param_limit")
|
||||
private short limit;
|
||||
|
||||
@@ -66,26 +79,31 @@ public class ParamDefine {
|
||||
* 当type为radio单选框,checkbox复选框时,option表示可选项值列表
|
||||
* eg: param3,param4,param5
|
||||
*/
|
||||
@ApiModelProperty(value = "当type为radio单选框,checkbox复选框时,option表示可选项值列表", example = "10,20,30", accessMode = READ_WRITE, position = 7)
|
||||
@Column(name = "param_option")
|
||||
private String option;
|
||||
|
||||
/**
|
||||
* 此条记录创建者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录创建者", example = "tom", accessMode = READ_ONLY, position = 8)
|
||||
private String creator;
|
||||
|
||||
/**
|
||||
* 此条记录最新修改者
|
||||
*/
|
||||
@ApiModelProperty(value = "此条记录最新修改者", example = "tom", accessMode = READ_ONLY, position = 9)
|
||||
private String modifier;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录创建时间(毫秒时间戳)", example = "1612198922000", accessMode = READ_ONLY, position = 10)
|
||||
private LocalDateTime gmtCreate;
|
||||
|
||||
/**
|
||||
* 记录最新修改时间
|
||||
*/
|
||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 11)
|
||||
private LocalDateTime gmtUpdate;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.usthe.manager.service;
|
||||
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 监控类型管理接口
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 17:12
|
||||
*/
|
||||
public interface AppService {
|
||||
|
||||
/**
|
||||
* 根据监控类型查询定义的参数结构
|
||||
* @param app 监控类型
|
||||
* @return 参数结构列表
|
||||
*/
|
||||
List<ParamDefine> getAppParamDefines(String app);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.usthe.manager.service.impl;
|
||||
|
||||
import com.usthe.manager.pojo.entity.ParamDefine;
|
||||
import com.usthe.manager.service.AppService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 监控类型管理实现
|
||||
* @author tomsun28
|
||||
* @date 2021/11/14 17:17
|
||||
*/
|
||||
@Service
|
||||
public class AppServiceImpl implements AppService {
|
||||
|
||||
@Override
|
||||
public List<ParamDefine> getAppParamDefines(String app) {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
6
manager/src/main/resources/banner.txt
Normal file
6
manager/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
████████╗ █████╗ ███╗ ██╗ ██████╗██╗ ██████╗ ██╗ ██╗██████╗
|
||||
╚══██╔══╝██╔══██╗████╗ ██║ ██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗
|
||||
██║ ███████║██╔██╗ ██║ ██║ ██║ ██║ ██║██║ ██║██║ ██║
|
||||
██║ ██╔══██║██║╚██╗██║ ██║ ██║ ██║ ██║██║ ██║██║ ██║ Profile: ${spring.profiles.active}
|
||||
██║ ██║ ██║██║ ╚████║ ╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝ Name: ${spring.application.name} Port: ${server.port} Pid: ${pid}
|
||||
╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝
|
||||
@@ -1,4 +1,4 @@
|
||||
use tom ;
|
||||
use usthe ;
|
||||
-- ----------------------------
|
||||
-- Records of auth_resource
|
||||
-- ----------------------------
|
||||
|
||||
Reference in New Issue
Block a user