add
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Schema(title = "DTO示例")
|
||||
public class ExampleDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "字符串")
|
||||
private String strField;
|
||||
|
||||
@Schema(description = "长整数")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long longField;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "日期类型", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private LocalDate dateField;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "时间类型", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime timeField;
|
||||
|
||||
@NotNull
|
||||
@Schema(
|
||||
title = "状态",
|
||||
description = "参考示例值",
|
||||
example = StateEnum.DESC
|
||||
)
|
||||
private StateEnum state;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@TableName(value = "example_table", autoResultMap = true)
|
||||
@Schema(title = "示例表")
|
||||
public class ExampleEntity implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "ID")
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@TableField(value = "id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "字符串")
|
||||
@TableField(value = "str_field")
|
||||
private String strField;
|
||||
|
||||
@Schema(description = "整数", defaultValue = "0")
|
||||
@TableField(value = "int_field")
|
||||
private Integer intField;
|
||||
|
||||
@Schema(description = "长整数")
|
||||
@TableField(value = "long_field")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long longField;
|
||||
|
||||
@Schema(description = "高精度浮点数")
|
||||
@TableField(value = "decimal_field")
|
||||
private BigDecimal decimalField;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "日期类型", pattern = "yyyy-MM-dd")
|
||||
@TableField(value = "date_field")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private LocalDate dateField;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "时间类型", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@TableField(value = "time_field")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime timeField;
|
||||
|
||||
@NotNull
|
||||
@Schema(
|
||||
title = "状态",
|
||||
description = "参考示例值",
|
||||
example = StateEnum.DESC
|
||||
)
|
||||
@TableField(value = "state")
|
||||
private StateEnum state;
|
||||
|
||||
@Schema(description = "JSON类型")
|
||||
@TableField(value = "json_field", typeHandler = JacksonTypeHandler.class)
|
||||
private JsonField jsonField;
|
||||
|
||||
@Data
|
||||
public static class JsonField implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "示例字段1")
|
||||
private String field1;
|
||||
|
||||
@Schema(description = "示例字段2")
|
||||
private Integer field2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@Schema(description = "某某状态")
|
||||
public enum StateEnum {
|
||||
|
||||
ONLY_READ("only_read"),
|
||||
|
||||
READ_WRITE("read_write");
|
||||
|
||||
public static final String DESC = "only_read=只读、read_write=读写";
|
||||
|
||||
@JsonValue
|
||||
@EnumValue
|
||||
private final String value;
|
||||
|
||||
@JsonCreator
|
||||
public static StateEnum deserialize(String input) {
|
||||
return Arrays.stream(values()).filter(e -> e.getValue().equals(input)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
# 智能体使用数据
|
||||
|
||||
以下是关于智能体使用数据的API文档。
|
||||
|
||||
## 累计使用数据卡片
|
||||
|
||||
- 请求地址:/agent/metrics/total
|
||||
- 请求方式:GET
|
||||
|
||||
### 请求参数
|
||||
|
||||
| 参数名称 | 是否必传 | 类型 | 描述 |
|
||||
|:-----|:-----|:-----|:-----|
|
||||
| agentId | 是 | String | 智能体ID |
|
||||
|
||||
### 请求示例
|
||||
|
||||
```bash
|
||||
curl -X GET {gateway}/agent/metrics/total?agentId={agentId}
|
||||
```
|
||||
|
||||
### 响应参数
|
||||
|
||||
| 参数名称 | 类型 | 描述 |
|
||||
|:-----|:-----|:-----|
|
||||
| code | Number | 返回码(200=成功) |
|
||||
| msg | String | 提示信息 |
|
||||
| data | Object | 返回数据 |
|
||||
| data.agentId | String | 智能体 ID |
|
||||
| data.agentName | String | 智能体名称 |
|
||||
| data.inputToken | Number | 累计输入Token |
|
||||
| data.outputToken | Number | 累计输出Token |
|
||||
| data.userNum | Number | 累计用户数 |
|
||||
| data.chatNum | Number | 累计对话数 |
|
||||
|
||||
### 成功示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": {
|
||||
"agentId": "123456",
|
||||
"agentName": "智能体名称",
|
||||
"inputToken": "123243654645",
|
||||
"outputToken": "345645765765",
|
||||
"userNum": 5678,
|
||||
"chatNum": 45678999
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 失败示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 500,
|
||||
"msg": "错误信息"
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE `example_table` (
|
||||
`id` BIGINT NOT NULL COMMENT 'ID',
|
||||
`str_field` VARCHAR(32) NOT NULL COMMENT '字符串`,
|
||||
`int_field` INT DEFAULT NULL COMMENT '整数`,
|
||||
`long_field` BIGINT DEFAULT NULL COMMENT '长整数`,
|
||||
`decimal_field` DECIMAL(14, 2) DEFAULT NULL COMMENT '高精度浮点数`,
|
||||
`date_field` DATE NOT NULL COMMENT '日期类型`,
|
||||
`time_field` DATETIME NOT NULL COMMENT '日期类型`,
|
||||
`state` VARCHAR(32) NOT NULL COMMENT '状态:only_read、read_write',
|
||||
`json_field` JSON DATETIME NULL COMMENT 'JSON类型'
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='示例表';
|
||||
Reference in New Issue
Block a user