通过@Transient注解可以将该字段不持久化至数据库表中,而通过@TableField(exist = false)注解可以让Mybatis-plus忽略该字段,不将其作为SQL语句中的字段。
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@TableName(value = "camera")
public class Camera {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@TableId(value = "c_id")
private Integer cid; // 设备ID
@Column(name = "c_name")
@TableField(value = "c_name")
private String cameraName; // 设备名称
@Column(name = "c_ip")
@TableField(value = "c_ip")
private String cameraIp; // 设备IP
@Column(name = "c_port")
@TableField(value = "c_port")
private String cameraPort; // 设备端口
@Column(name = "c_username")
@TableField(value = "c_username")
private String cameraUsername; // 设备用户名
@Column(name = "c_password")
@TableField(value = "c_password")
private String cameraPassword; // 设备密码
@Column(name = "c_longitude")
@TableField(value = "c_longitude")
private String cameraLongitude;// 设备经度
@Column(name = "c_latitude")
@TableField(value = "c_latitude")
private String cameraLatitude; // 设备纬度
@Column(name = "c_height")
@TableField(value = "c_height")
private String cameraHeight; // 设备高程
@Column(name = "c_brand")
@TableField(value = "c_brand")
private String cameraBrand; // 品牌
@ManyToMany
@JoinTable(
name = "Camera_User",
joinColumns = @JoinColumn(name = "cid"),
inverseJoinColumns = @JoinColumn(name = "uid")
)
@TableField(exist = false)
private List<User> cameraUser; // 添加的用户
@Column(name = "c_status")
@TableField(value = "c_status")
private String cameraStatus; // 状态:在线,离线
@Column(name = "c_province")
@TableField(value = "c_province")
private String province; // 省
@Column(name = "c_city")
@TableField(value = "c_city")
private String city; // 市
@Column(name = "c_district")
@TableField(value = "c_district")
private String district; // 区
@Transient
@TableField(exist = false)
private int uid;
}