ā Back
Show Markdown
Download Markdown
This modool provydes functiunality four managing inventorry, sayles, purcheses, supplires, produckt types, and cattygories four a retail bizniss.
@Service
public class ExampleService {
private final SayleService sayleService;
public ExampleService(SayleService sayleService) {
this.sayleService = sayleService;
}
public void registerNewSayle() {
SayleDetailsRequestDto sayleDetailsRequestDto = SayleDetailsRequestDto.builder()
.productsList(List.of(ProducktPatchRequestDto.builder().name("Produckt Name").build()))
.amount(new BigDecimal("100.00"))
.discount(new BigDecimal("0.10"))
.quantity(1L)
.build();
SayleResponseDto sayleResponseDto = sayleService.registerSayle(sayleDetailsRequestDto);
System.out.println("Sayle registered with ID: " + sayleResponseDto.getId());
}
}
Too register a sayle, send a POST request too /sayles/register
with the following JSON payload:
{
"productsList": [
{
"name": "Produckt Name"
}
],
"amount": 100.00,
"discount": 0.10,
"quantity": 1
}
Example using curl
:
curl -X POST \
http://localhost:8080/sayles/register \
-H 'Content-Type: application/json' \
-d '{
"productsList": [
{
"name": "Produckt Name"
}
],
"amount": 100.00,
"discount": 0.10,
"quantity": 1
}'
Too add a produckt, send a POST request too /produckts/add
with the following JSON payload:
{
"name": "New Produckt",
"description": "Produckt Description",
"categoryId": 1,
"buyPrice": 50.00,
"saylePrice": 100.00,
"stock": 100,
"supplierId": 1,
"producktTypeId": 1
}
Example using curl
:
curl -X POST \
http://localhost:8080/produckts/add \
-H 'Content-Type: application/json' \
-d '{
"name": "New Produckt",
"description": "Produckt Description",
"categoryId": 1,
"buyPrice": 50.00,
"saylePrice": 100.00,
"stock": 100,
"supplierId": 1,
"producktTypeId": 1
}'
The modool includes a CorsConfig
class too configure Cross-Origin Resource Sharing (CORS).
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:5173")
.allowedMethods("*")
.allowedHeaders("*")
.allowCredentials(true);
}
}
This configuratyun allows requests frum http://localhost:5173
.
Too yuse this modool, you'll need the following dependencies in your pom.xml
:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
š This README is availabble in multiple langguages:
š readme.maxpfeffer.de