Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package moja.refrigerator.aggregate.ingredient;

import jakarta.persistence.*;
import lombok.Data;
import moja.refrigerator.aggregate.user.User;

@Table(name = "tbl_ingredient_bookmark")
@Entity
@Data
public class IngredientBookmark {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ingredient_bookmark_pk")
private long ingredientBookmarkPk;

@ManyToOne
@JoinColumn(name = "user")
private User user;

@ManyToOne
@JoinColumn(name = "ingredient_management")
private IngredientManagement ingredientManagement;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
package moja.refrigerator.aggregate.ingredient;

import jakarta.persistence.*;
import lombok.Data;

@Entity
@Table(name = "tbl_ingredient_category")
@Data
public class IngredientCategory {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ingredient_category_pk")
private int IngredientCategoryPk;

@Column(name = "ingredient_category")
private String IngredientCategory;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package moja.refrigerator.aggregate.ingredient;

import jakarta.persistence.*;
import lombok.Data;

@Data
@Entity
@Table(name = "tbl_ingredient_management")
public class IngredientManagement {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ingredient_management_pk")
private long ingredientManagementPk;

@Column(name = "ingredient_name")
private String ingredientName;

@Column(name = "expiration_date")
private String expirationDate;

@Column(name = "registration_date")
private String registrationDate;

@Column(name = "season_date")
private int seasonDate;

@JoinColumn(name = "ingredient_category")
@ManyToOne
private IngredientCategory ingredientCategory;

@JoinColumn(name = "ingredient_storage")
@ManyToOne
private IngredientStorage ingredientStorage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package moja.refrigerator.aggregate.ingredient;

import jakarta.persistence.*;
import lombok.Data;

@Data
@Entity
@Table(name="tbl_ingredient_storage")
public class IngredientStorage {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ingredient_storage_pk")
private int IngredientStoragePk;

@Column(name = "ingredient_storage")
private String IngredientStorage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package moja.refrigerator.aggregate.user;

import jakarta.persistence.*;
import lombok.Data;

@Entity
@Table(name = "tbl_user")
@Data
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_pk")
private long userPk;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package moja.refrigerator.controller.ingredient;

import moja.refrigerator.service.ingredient.IngredientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ingredient")
public class IngredientController {
private IngredientService ingredientService;

@Autowired
public IngredientController(IngredientService ingredientService) {
this.ingredientService = ingredientService;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package moja.refrigerator.repository.ingredient;

import moja.refrigerator.aggregate.ingredient.IngredientManagement;
import org.springframework.data.jpa.repository.JpaRepository;

public interface IngredientManagementRepository extends JpaRepository<IngredientManagement, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package moja.refrigerator.service.ingredient;

public interface IngredientService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package moja.refrigerator.service.ingredient;

import moja.refrigerator.repository.ingredient.IngredientManagementRepository;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IngredientServiceImpl implements IngredientService{

private IngredientManagementRepository ingredientManagementRepository;
private ModelMapper mapper;

@Autowired
public IngredientServiceImpl(IngredientManagementRepository ingredientManagementRepository,
ModelMapper mapper) {
this.ingredientManagementRepository = ingredientManagementRepository;
this.mapper = mapper;
}
}