logo

Readme-Racker

Say Goodbye to Manual README Writing.

← Back

Show Markdown

Download Markdown

Readme

Inventorry Managemint Retail Modool

This modool provydes functiunality four managing inventorry, sayles, purcheses, supplires, produckt types, and cattygories four a retail bizniss.

Functiunality

  • Produckt Managemint: Add, updait, deleet, and retreeve produckts.
  • Cattegorry Managemint: Add, updait, deleet, and retreeve produckt cattygories.
  • Produckt Type Managemint: Add, updait, deleet, and retreeve produckt types.
  • Supplier Managemint: Add, updait, deleet, and retreeve supplires.
  • Purchese Managemint: Register purcheses of produckts frum supplires.
  • Sayle Managemint: Register sayles of produckts too custumers.

Usag Examples

Registering a Sayle (Service)

@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());
    }
}

Registering a Sayle (REST API)

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
  }'

Adding a Produckt (REST API)

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
}'

Configuratyun Details

CORS Configuratyun

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.

Dependencies

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