From d7f47f077ffd0b1c5f44053bdc38312adde17874 Mon Sep 17 00:00:00 2001 From: Alok Kumar <59380269+AlokSP@users.noreply.github.com> Date: Thu, 9 Jan 2025 17:24:19 +0530 Subject: [PATCH] resolved conflicts --- src/main/java/com/health/model/Category.java | 12 ++ .../java/com/health/model/SubCategory.java | 125 ++++++++++++++++++ .../repository/SubCategoryRepository.java | 13 ++ .../health/service/SubCategoryService.java | 11 ++ .../service/impl/SubCategoryServiceImpl.java | 28 ++++ 5 files changed, 189 insertions(+) create mode 100644 src/main/java/com/health/model/SubCategory.java create mode 100644 src/main/java/com/health/repository/SubCategoryRepository.java create mode 100644 src/main/java/com/health/service/SubCategoryService.java create mode 100644 src/main/java/com/health/service/impl/SubCategoryServiceImpl.java diff --git a/src/main/java/com/health/model/Category.java b/src/main/java/com/health/model/Category.java index c81b26fc..ea365385 100644 --- a/src/main/java/com/health/model/Category.java +++ b/src/main/java/com/health/model/Category.java @@ -83,6 +83,9 @@ public class Category implements Comparable, Serializable { @OneToMany(mappedBy = "cat", cascade = CascadeType.ALL, fetch = FetchType.LAZY) private Set userRoles = new HashSet(); + @OneToMany(mappedBy = "category", cascade = CascadeType.ALL, fetch = FetchType.LAZY) + private Set subCategoriess = new HashSet(); + @OneToMany(mappedBy = "catId", cascade = CascadeType.ALL) private Set brochures = new HashSet(); @@ -118,6 +121,15 @@ public void setOrder(int order) { this.order = order; } + public Set getSubCategoriess() { + return subCategoriess; + } + + public void setSubCategoriess(Set subCategoriess) { + this.subCategoriess = subCategoriess; + + } + public Timestamp getDateAdded() { return dateAdded; } diff --git a/src/main/java/com/health/model/SubCategory.java b/src/main/java/com/health/model/SubCategory.java new file mode 100644 index 00000000..bc8c0a2d --- /dev/null +++ b/src/main/java/com/health/model/SubCategory.java @@ -0,0 +1,125 @@ +package com.health.model; + +import java.io.Serializable; +import java.sql.Timestamp; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "sub_category") +public class SubCategory implements Comparable, Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "sub_category_id", nullable = false, updatable = false) + private int subCategoryId; + + @Column(name = "sub_category_name", nullable = false, unique = true) + private String subCategoryName; + + @Column(name = "date_added", nullable = false) + private Timestamp dateAdded; + + @Column(name = "status", nullable = false) + private boolean status = true; + + @Column(name = "Image_path", nullable = true) + private String posterPath; + + @Column(name = "Description", nullable = true, length = 2000) + private String description; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "category_id") + private Category category; + + public Timestamp getDateAdded() { + return dateAdded; + } + + public void setDateAdded(Timestamp dateAdded) { + this.dateAdded = dateAdded; + } + + public boolean isStatus() { + return status; + } + + public void setStatus(boolean status) { + this.status = status; + } + + public String getPosterPath() { + return posterPath; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public int getSubCategoryId() { + return subCategoryId; + } + + public void setSubCategoryId(int subCategoryId) { + this.subCategoryId = subCategoryId; + } + + public String getSubCategoryName() { + return subCategoryName; + } + + public void setSubCategoryName(String subCategoryName) { + this.subCategoryName = subCategoryName; + } + + public SubCategory(String subCategoryName, Timestamp dateAdded, boolean status, String posterPath, + String description, Category category) { + super(); + this.subCategoryName = subCategoryName; + this.dateAdded = dateAdded; + this.status = status; + this.posterPath = posterPath; + this.description = description; + this.category = category; + + } + + public SubCategory() { + + } + + @Override + public int compareTo(SubCategory o) { + + return this.getSubCategoryName().compareTo(o.getSubCategoryName()); + + } + +} diff --git a/src/main/java/com/health/repository/SubCategoryRepository.java b/src/main/java/com/health/repository/SubCategoryRepository.java new file mode 100644 index 00000000..dabde45f --- /dev/null +++ b/src/main/java/com/health/repository/SubCategoryRepository.java @@ -0,0 +1,13 @@ +package com.health.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.health.model.SubCategory; + +public interface SubCategoryRepository extends JpaRepository { + + SubCategory findBySubCategoryName(String subCatName); + + SubCategory findBySubCategoryId(int subCatId); + +} diff --git a/src/main/java/com/health/service/SubCategoryService.java b/src/main/java/com/health/service/SubCategoryService.java new file mode 100644 index 00000000..3181b673 --- /dev/null +++ b/src/main/java/com/health/service/SubCategoryService.java @@ -0,0 +1,11 @@ +package com.health.service; + +import com.health.model.SubCategory; + +public interface SubCategoryService { + + SubCategory findBySubCategoryName(String subCatName); + + SubCategory findBySubCategoryId(int subCatId); + +} diff --git a/src/main/java/com/health/service/impl/SubCategoryServiceImpl.java b/src/main/java/com/health/service/impl/SubCategoryServiceImpl.java new file mode 100644 index 00000000..8bb40dcb --- /dev/null +++ b/src/main/java/com/health/service/impl/SubCategoryServiceImpl.java @@ -0,0 +1,28 @@ +package com.health.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.health.model.SubCategory; +import com.health.repository.SubCategoryRepository; +import com.health.service.SubCategoryService; + +@Service +public class SubCategoryServiceImpl implements SubCategoryService { + + @Autowired + private SubCategoryRepository repo; + + @Override + public SubCategory findBySubCategoryName(String subCatName) { + + return repo.findBySubCategoryName(subCatName); + } + + @Override + public SubCategory findBySubCategoryId(int subCatId) { + + return repo.findBySubCategoryId(subCatId); + } + +}