add Stock Entity, Repositoy and Service

This commit is contained in:
Olivier PARPAILLON
2025-07-09 10:54:45 +02:00
parent 36b6313335
commit 76736405a3
4 changed files with 61 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
package fr.eni.demo.bll;
import fr.eni.demo.bo.Stock;
import fr.eni.demo.dal.StockRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class StockService {
@Autowired
private StockRepository stockRepository;
public void add(Stock stock) {
stockRepository.save(stock);
}
}

View File

@@ -0,0 +1,34 @@
package fr.eni.demo.bo;
import jakarta.persistence.*;
import lombok.*;
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@ToString
@Builder
@Entity
@Table(name="GAME")
public class Stock {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "GAME_ID")
private Integer id;
@Column(name="GAME_NAME", nullable = false)
private String name;
@Column(name="GAME_DESCRIPTION")
private String description;
@Column(name="GAME_REF", nullable = false)
private String ref;
@Column(name="GAME_DAILY_PRICE", nullable = false)
private Long dailyPrice;
}

View File

@@ -5,5 +5,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@Repository @Repository
public interface ClientRepository extends JpaRepository<Client, Integer> { public interface ClientRepository extends JpaRepository<Client, Long> {
} }

View File

@@ -0,0 +1,9 @@
package fr.eni.demo.dal;
import fr.eni.demo.bo.Stock;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface StockRepository extends JpaRepository<Stock,Long> {
}