1 Introduction
In JavaWeb, an entity class is used as a mapping of fields in a database table. The annotations that are often used when constructing entity classes are listed below. Then let everyone search for its function by themselves, so I won’t explain it one by one
2. Annotation example
Without further ado, let’s start with the code
(1)@Data
(2)@AllArgsConstructor
(3)@NoArgsConstructor
(4) @TableName
(5)@TableId
(6)@TableField
(7)@Column
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("person")
public class Person {
@TableId(type = IdType.AUTO)
@Column(name = "id")
private Long Id;
private String name;
private String gender;
private Integer age;
@TableField(exist = false)
private List<Long> ids;
public Person(List<Long> ids) {
this.ids = ids;
}
}
(8)@ApiModel
(9)@ApiModelProperty
(10) @JsonIgnoreProperties(ignoreUnknown=true)
(11) @JsonIgnore
@Data
@ApiModel(value="人员")
@JsonIgnoreProperties(ignoreUnknown=true)
public class IwpPerson {
@JsonIgnore
//主键id
private String id;
//单位
@ApiModelProperty(value = "单位")
private String unit;
//人员
@ApiModelProperty(value = "人员")
private String person;
//管理员类型
@ApiModelProperty(value = "管理员类型 0 集团 1 部门")
private int iwpLevel;
//角色
@ApiModelProperty(value = "角色 0 管理员 1 人员")
private int role;
//用户ID
@ApiModelProperty(value = "用户ID")
private String userId;
//所属部门
@ApiModelProperty(value = "部门")
private String department;
//是否默认
@ApiModelProperty(value = "是否默认 0 否 1 是")
private int isDefault;
//类型
@ApiModelProperty(value = "类型 0 日例会、1 周例会、2 月例会、3 年度、4 日常、5 专项")
private int iwpType;
// 创建时间
@ApiModelProperty(value = "创建时间")
private LocalDateTime creationTime;
// 创建人
@ApiModelProperty(value = "创建人")
private String createdBy;
// 最后更新时间
@ApiModelProperty(value = "最后更新时间")
private LocalDateTime lastUpdateTime;
// 最后更新人
@ApiModelProperty(value = "最后更新人")
private String lastUpdatedBy;
}