GitBucket
4.23.0
Toggle navigation
Sign in
Files
Branches
1
Releases
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
yn-bftl-byx
/
common
Browse code
spu spusource
master
1 parent
d9733d6
commit
cd6259c2391ec3ccbd678ce619fe1fbdaba8e2ae
Jing
authored
on 18 Oct
Patch
Showing
1 changed file
src/main/java/com/yn/bftl/common/modules/good/entity/Spu.java
Ignore Space
Show notes
View
src/main/java/com/yn/bftl/common/modules/good/entity/Spu.java
package com.yn.bftl.common.modules.good.entity; import com.google.common.base.MoreObjects; import com.yn.bftl.common.common.entity.AuditableModel; import com.yn.bftl.common.modules.company.entity.Brand; import com.yn.bftl.common.modules.company.entity.Company; import com.yn.bftl.common.modules.good.enums.SpuSource; import com.yn.bftl.common.modules.meta.entity.MetaFile; import org.hibernate.annotations.Type; import javax.persistence.*; import java.io.Serializable; import java.util.*; /** * 商品 * * @Author: DoubleHuang * @Create: create in 2021/4/26 0026 下午 6:34 */ @Entity @Cacheable(false) @Table(name = "GOOD_SPU") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Spu extends AuditableModel implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GOOD_SPU_SEQ") @SequenceGenerator(name = "GOOD_SPU_SEQ", sequenceName = "GOOD_SPU_SEQ", allocationSize = 1) private Long id; /** * 商品规格 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<SpuSpec> spuSpec; /** * 商品名称 */ private String name; /** * 规格商品 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<Sku> sku; /** * 商品类目 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "good_cate") private GoodCate goodCate; /** * 计量单位 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "unit") private Unit unit; /** * 视频 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "gallery") private MetaFile gallery; /** * 商品属性 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<SpuAttr> spuAttr; /** * 商品参数 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<SpuPara> spuPara; /** * 品牌 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "brand") private Brand brand; /** * 标语 */ private String slogan; /** * 编码 */ private String code; /** * 详情 */ private String detail; /** * 商品主图 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<GoodPic> goodPic; /** * 缩略图 */ @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "thumbnail") private MetaFile thumbnail; /** * 企业 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "company") private Company company; /** * 商品标签 */ @ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinTable(name = "good_spu_goods_tags", joinColumns = @JoinColumn(name = "good_spu"), inverseJoinColumns = @JoinColumn(name = "goods_tags")) private Set<GoodTag> goodsTags; /** * 是否多规格 */ private Boolean isManySpec = Boolean.TRUE; /** * 二维码 */ @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "qr_code") private MetaFile qrCode; /** * 来源 */ @Enumerated(EnumType.STRING) private SpuSource source = SpuSource.BUILD_ONESELF; private String attrs; public Spu() { } public Spu(String name, String code) { this.name = name; this.code = code; } @Override public Long getId() { return id; } @Override public void setId(Long id) { this.id = id; } public List<SpuSpec> getSpuSpec() { return spuSpec; } public void setSpuSpec(List<SpuSpec> spuSpec) { this.spuSpec = spuSpec; } /** * Add the given {@link SpuSpec} item to the {@code spuSpec}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addSpuSpec(SpuSpec item) { if (getSpuSpec() == null) { setSpuSpec(new ArrayList<>()); } getSpuSpec().add(item); item.setSpu(this); } /** * Remove the given {@link SpuSpec} item from the {@code spuSpec}. * * @param item the item to remove */ public void removeSpuSpec(SpuSpec item) { if (getSpuSpec() == null) { return; } getSpuSpec().remove(item); } /** * Clear the {@code spuSpec} collection. * * <p>If you have to query {@link SpuSpec} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearSpuSpec() { if (getSpuSpec() != null) { getSpuSpec().clear(); } } public String getName() { return name; } public void setName(String name) { this.name = name; } public List<Sku> getSku() { return sku; } public void setSku(List<Sku> sku) { this.sku = sku; } /** * Add the given {@link Sku} item to the {@code sku}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addSku(Sku item) { if (getSku() == null) { setSku(new ArrayList<>()); } getSku().add(item); item.setSpu(this); } /** * Remove the given {@link Sku} item from the {@code sku}. * * @param item the item to remove */ public void removeSku(Sku item) { if (getSku() == null) { return; } getSku().remove(item); } /** * Clear the {@code sku} collection. * * <p>If you have to query {@link Sku} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearSku() { if (getSku() != null) { getSku().clear(); } } public GoodCate getGoodCate() { return goodCate; } public void setGoodCate(GoodCate goodCate) { this.goodCate = goodCate; } public Unit getUnit() { return unit; } public void setUnit(Unit unit) { this.unit = unit; } public MetaFile getGallery() { return gallery; } public void setGallery(MetaFile gallery) { this.gallery = gallery; } public List<SpuAttr> getSpuAttr() { return spuAttr; } public void setSpuAttr(List<SpuAttr> spuAttr) { this.spuAttr = spuAttr; } /** * Add the given {@link SpuAttr} item to the {@code spuAttr}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addSpuAttr(SpuAttr item) { if (getSpuAttr() == null) { setSpuAttr(new ArrayList<>()); } getSpuAttr().add(item); item.setSpu(this); } /** * Remove the given {@link SpuAttr} item from the {@code spuAttr}. * * @param item the item to remove */ public void removeSpuAttr(SpuAttr item) { if (getSpuAttr() == null) { return; } getSpuAttr().remove(item); } /** * Clear the {@code spuAttr} collection. * * <p>If you have to query {@link SpuAttr} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearSpuAttr() { if (getSpuAttr() != null) { getSpuAttr().clear(); } } public List<SpuPara> getSpuPara() { return spuPara; } public void setSpuPara(List<SpuPara> spuPara) { this.spuPara = spuPara; } /** * Add the given {@link SpuPara} item to the {@code spuPara}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addSpuPara(SpuPara item) { if (getSpuPara() == null) { setSpuPara(new ArrayList<>()); } getSpuPara().add(item); item.setSpu(this); } /** * Remove the given {@link SpuPara} item from the {@code spuPara}. * * @param item the item to remove */ public void removeSpuPara(SpuPara item) { if (getSpuPara() == null) { return; } getSpuPara().remove(item); } /** * Clear the {@code spuPara} collection. * * <p>If you have to query {@link SpuPara} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearSpuPara() { if (getSpuPara() != null) { getSpuPara().clear(); } } public Brand getBrand() { return brand; } public void setBrand(Brand brand) { this.brand = brand; } public String getSlogan() { return slogan; } public void setSlogan(String slogan) { this.slogan = slogan; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail; } public List<GoodPic> getGoodPic() { return goodPic; } public void setGoodPic(List<GoodPic> goodPic) { this.goodPic = goodPic; } /** * Add the given {@link GoodPic} item to the {@code goodPic}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addGoodPic(GoodPic item) { if (getGoodPic() == null) { setGoodPic(new ArrayList<>()); } getGoodPic().add(item); item.setSpu(this); } /** * Remove the given {@link GoodPic} item from the {@code goodPic}. * * @param item the item to remove */ public void removeGoodPic(GoodPic item) { if (getGoodPic() == null) { return; } getGoodPic().remove(item); } /** * Clear the {@code goodPic} collection. * * <p>If you have to query {@link GoodPic} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearGoodPic() { if (getGoodPic() != null) { getGoodPic().clear(); } } public MetaFile getThumbnail() { return thumbnail; } public void setThumbnail(MetaFile thumbnail) { this.thumbnail = thumbnail; } public MetaFile getQrCode() { return qrCode; } public void setQrCode(MetaFile qrCode) { this.qrCode = qrCode; } public SpuSource getSource() { return source; } public void setSource(SpuSource source) { this.source = source; } public Company getCompany() { return company; } public void setCompany(Company company) { this.company = company; } public Set<GoodTag> getGoodsTags() { return goodsTags; } public void setGoodsTags(Set<GoodTag> goodsTags) { this.goodsTags = goodsTags; } /** * Add the given {@link GoodTag} item to the {@code goodsTags}. * * @param item the item to add */ public void addGoodsTag(GoodTag item) { if (getGoodsTags() == null) { setGoodsTags(new HashSet<>()); } getGoodsTags().add(item); } /** * Remove the given {@link GoodTag} item from the {@code goodsTags}. * * @param item the item to remove */ public void removeGoodsTag(GoodTag item) { if (getGoodsTags() == null) { return; } getGoodsTags().remove(item); } /** * Clear the {@code goodsTags} collection. */ public void clearGoodsTags() { if (getGoodsTags() != null) { getGoodsTags().clear(); } } public Boolean getIsManySpec() { return isManySpec == null ? Boolean.FALSE : isManySpec; } public void setIsManySpec(Boolean isManySpec) { this.isManySpec = isManySpec; } public String getAttrs() { return attrs; } public void setAttrs(String attrs) { this.attrs = attrs; } @Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (!(obj instanceof Spu)) return false; final Spu other = (Spu) obj; if (this.getId() != null || other.getId() != null) { return Objects.equals(this.getId(), other.getId()); } return false; } @Override public int hashCode() { return 31; } @Override public String toString() { return MoreObjects.toStringHelper(this) .add("id", getId()) .add("name", getName()) .add("slogan", getSlogan()) .add("code", getCode()) .add("source", getSource()) .omitNullValues() .toString(); } }
package com.yn.bftl.common.modules.good.entity; import com.google.common.base.MoreObjects; import com.yn.bftl.common.common.entity.AuditableModel; import com.yn.bftl.common.modules.company.entity.Brand; import com.yn.bftl.common.modules.company.entity.Company; import com.yn.bftl.common.modules.good.enums.SpuSource; import com.yn.bftl.common.modules.meta.entity.MetaFile; import org.hibernate.annotations.Type; import javax.persistence.*; import java.io.Serializable; import java.util.*; /** * 商品 * * @Author: DoubleHuang * @Create: create in 2021/4/26 0026 下午 6:34 */ @Entity @Cacheable(false) @Table(name = "GOOD_SPU") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Spu extends AuditableModel implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GOOD_SPU_SEQ") @SequenceGenerator(name = "GOOD_SPU_SEQ", sequenceName = "GOOD_SPU_SEQ", allocationSize = 1) private Long id; /** * 商品规格 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<SpuSpec> spuSpec; /** * 商品名称 */ private String name; /** * 规格商品 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<Sku> sku; /** * 商品类目 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "good_cate") private GoodCate goodCate; /** * 计量单位 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "unit") private Unit unit; /** * 视频 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "gallery") private MetaFile gallery; /** * 商品属性 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<SpuAttr> spuAttr; /** * 商品参数 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<SpuPara> spuPara; /** * 品牌 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "brand") private Brand brand; /** * 标语 */ private String slogan; /** * 编码 */ private String code; /** * 详情 */ private String detail; /** * 商品主图 */ @OneToMany(fetch = FetchType.LAZY, mappedBy = "spu", cascade = CascadeType.ALL, orphanRemoval = true) private List<GoodPic> goodPic; /** * 缩略图 */ @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "thumbnail") private MetaFile thumbnail; /** * 企业 */ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "company") private Company company; /** * 商品标签 */ @ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinTable(name = "good_spu_goods_tags", joinColumns = @JoinColumn(name = "good_spu"), inverseJoinColumns = @JoinColumn(name = "goods_tags")) private Set<GoodTag> goodsTags; /** * 是否多规格 */ private Boolean isManySpec = Boolean.TRUE; /** * 二维码 */ @OneToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "qr_code") private MetaFile qrCode; /** * 来源 */ @Enumerated(EnumType.STRING) private SpuSource source = SpuSource.BUILD_ONESELF; private String attrs; public Spu() { } public Spu(String name, String code) { this.name = name; this.code = code; } @Override public Long getId() { return id; } @Override public void setId(Long id) { this.id = id; } public List<SpuSpec> getSpuSpec() { return spuSpec; } public void setSpuSpec(List<SpuSpec> spuSpec) { this.spuSpec = spuSpec; } /** * Add the given {@link SpuSpec} item to the {@code spuSpec}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addSpuSpec(SpuSpec item) { if (getSpuSpec() == null) { setSpuSpec(new ArrayList<>()); } getSpuSpec().add(item); item.setSpu(this); } /** * Remove the given {@link SpuSpec} item from the {@code spuSpec}. * * @param item the item to remove */ public void removeSpuSpec(SpuSpec item) { if (getSpuSpec() == null) { return; } getSpuSpec().remove(item); } /** * Clear the {@code spuSpec} collection. * * <p>If you have to query {@link SpuSpec} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearSpuSpec() { if (getSpuSpec() != null) { getSpuSpec().clear(); } } public String getName() { return name; } public void setName(String name) { this.name = name; } public List<Sku> getSku() { return sku; } public void setSku(List<Sku> sku) { this.sku = sku; } /** * Add the given {@link Sku} item to the {@code sku}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addSku(Sku item) { if (getSku() == null) { setSku(new ArrayList<>()); } getSku().add(item); item.setSpu(this); } /** * Remove the given {@link Sku} item from the {@code sku}. * * @param item the item to remove */ public void removeSku(Sku item) { if (getSku() == null) { return; } getSku().remove(item); } /** * Clear the {@code sku} collection. * * <p>If you have to query {@link Sku} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearSku() { if (getSku() != null) { getSku().clear(); } } public GoodCate getGoodCate() { return goodCate; } public void setGoodCate(GoodCate goodCate) { this.goodCate = goodCate; } public Unit getUnit() { return unit; } public void setUnit(Unit unit) { this.unit = unit; } public MetaFile getGallery() { return gallery; } public void setGallery(MetaFile gallery) { this.gallery = gallery; } public List<SpuAttr> getSpuAttr() { return spuAttr; } public void setSpuAttr(List<SpuAttr> spuAttr) { this.spuAttr = spuAttr; } /** * Add the given {@link SpuAttr} item to the {@code spuAttr}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addSpuAttr(SpuAttr item) { if (getSpuAttr() == null) { setSpuAttr(new ArrayList<>()); } getSpuAttr().add(item); item.setSpu(this); } /** * Remove the given {@link SpuAttr} item from the {@code spuAttr}. * * @param item the item to remove */ public void removeSpuAttr(SpuAttr item) { if (getSpuAttr() == null) { return; } getSpuAttr().remove(item); } /** * Clear the {@code spuAttr} collection. * * <p>If you have to query {@link SpuAttr} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearSpuAttr() { if (getSpuAttr() != null) { getSpuAttr().clear(); } } public List<SpuPara> getSpuPara() { return spuPara; } public void setSpuPara(List<SpuPara> spuPara) { this.spuPara = spuPara; } /** * Add the given {@link SpuPara} item to the {@code spuPara}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addSpuPara(SpuPara item) { if (getSpuPara() == null) { setSpuPara(new ArrayList<>()); } getSpuPara().add(item); item.setSpu(this); } /** * Remove the given {@link SpuPara} item from the {@code spuPara}. * * @param item the item to remove */ public void removeSpuPara(SpuPara item) { if (getSpuPara() == null) { return; } getSpuPara().remove(item); } /** * Clear the {@code spuPara} collection. * * <p>If you have to query {@link SpuPara} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearSpuPara() { if (getSpuPara() != null) { getSpuPara().clear(); } } public Brand getBrand() { return brand; } public void setBrand(Brand brand) { this.brand = brand; } public String getSlogan() { return slogan; } public void setSlogan(String slogan) { this.slogan = slogan; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail; } public List<GoodPic> getGoodPic() { return goodPic; } public void setGoodPic(List<GoodPic> goodPic) { this.goodPic = goodPic; } /** * Add the given {@link GoodPic} item to the {@code goodPic}. * * <p>It sets {@code item.spu = this} to ensure the proper relationship. * * @param item the item to add */ public void addGoodPic(GoodPic item) { if (getGoodPic() == null) { setGoodPic(new ArrayList<>()); } getGoodPic().add(item); item.setSpu(this); } /** * Remove the given {@link GoodPic} item from the {@code goodPic}. * * @param item the item to remove */ public void removeGoodPic(GoodPic item) { if (getGoodPic() == null) { return; } getGoodPic().remove(item); } /** * Clear the {@code goodPic} collection. * * <p>If you have to query {@link GoodPic} records in same transaction, make sure to call {@link * javax.persistence.EntityManager#flush() } to avoid unexpected errors. */ public void clearGoodPic() { if (getGoodPic() != null) { getGoodPic().clear(); } } public MetaFile getThumbnail() { return thumbnail; } public void setThumbnail(MetaFile thumbnail) { this.thumbnail = thumbnail; } public MetaFile getQrCode() { return qrCode; } public void setQrCode(MetaFile qrCode) { this.qrCode = qrCode; } public Company getCompany() { return company; } public void setCompany(Company company) { this.company = company; } public Set<GoodTag> getGoodsTags() { return goodsTags; } public void setGoodsTags(Set<GoodTag> goodsTags) { this.goodsTags = goodsTags; } /** * Add the given {@link GoodTag} item to the {@code goodsTags}. * * @param item the item to add */ public void addGoodsTag(GoodTag item) { if (getGoodsTags() == null) { setGoodsTags(new HashSet<>()); } getGoodsTags().add(item); } /** * Remove the given {@link GoodTag} item from the {@code goodsTags}. * * @param item the item to remove */ public void removeGoodsTag(GoodTag item) { if (getGoodsTags() == null) { return; } getGoodsTags().remove(item); } /** * Clear the {@code goodsTags} collection. */ public void clearGoodsTags() { if (getGoodsTags() != null) { getGoodsTags().clear(); } } public Boolean getIsManySpec() { return isManySpec == null ? Boolean.FALSE : isManySpec; } public void setIsManySpec(Boolean isManySpec) { this.isManySpec = isManySpec; } public String getAttrs() { return attrs; } public void setAttrs(String attrs) { this.attrs = attrs; } @Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (!(obj instanceof Spu)) return false; final Spu other = (Spu) obj; if (this.getId() != null || other.getId() != null) { return Objects.equals(this.getId(), other.getId()); } return false; } @Override public int hashCode() { return 31; } @Override public String toString() { return MoreObjects.toStringHelper(this) .add("id", getId()) .add("name", getName()) .add("slogan", getSlogan()) .add("code", getCode()) .omitNullValues() .toString(); } }
Show line notes below