如何设计javaBean及sql表?
spuSaleAttr的javaBean:
@Data
@ApiModel(description = "销售属性")
@TableName("spu_sale_attr")
public class SpuSaleAttr extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "商品id")
@TableField("spu_id")
private Long spuId;
@ApiModelProperty(value = "销售属性id")
@TableField("base_sale_attr_id")
private Long baseSaleAttrId;
@ApiModelProperty(value = "销售属性名称(冗余)")
@TableField("sale_attr_name")
private String saleAttrName;
// 销售属性对象集合 业务所需 销售属性:销售属性值 1: n
@TableField(exist = false)
List<SpuSaleAttrValue> spuSaleAttrValueList;
表没有外键
spuSaleAttrValue的javaBean:
@Data
@ApiModel(description = "销售属性值")
@TableName("spu_sale_attr_value")
public class SpuSaleAttrValue extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "商品id")
@TableField("spu_id")
private Long spuId;
@ApiModelProperty(value = "销售属性id")
@TableField("base_sale_attr_id")
private Long baseSaleAttrId;
@ApiModelProperty(value = "销售属性值名称")
@TableField("sale_attr_value_name")
private String saleAttrValueName;
@ApiModelProperty(value = "销售属性名称(冗余)")
@TableField("sale_attr_name")
private String saleAttrName;
// 是否是默认选中状态
// @TableField("sale_attr_name")
// String isChecked;
@TableField(exist = false) //游离态字段
String isChecked; //浏览器、内存里有数据,数据库中并没有这个数据
表没有外键
继承的BaseEntity:
@Data
public class BaseEntity implements Serializable {
@ApiModelProperty(value = "id")
@TableId(type = IdType.AUTO)
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}