添加 example_entity.md
This commit is contained in:
95
example_entity.md
Normal file
95
example_entity.md
Normal file
@@ -0,0 +1,95 @@
|
||||
```java
|
||||
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 AgentUsageStats 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;
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user