Commit ecbb1686 authored by Bhargava Rellu's avatar Bhargava Rellu

initial commit

parents
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
# Order Management System springboot rest
OMS done with Spring boot rest
----------------------------------------------------------
H2 Database:
Open databse using this url = http://localhost:8080/h2/
Login Credentials:
JDBC URL = jdbc:h2:mem:oms
Driver Class = org.h2.Driver
User Name = user
Password =
----------------------------------------------------------
Spring doc OpenAPI = http://localhost:8080/v3/api-docs/
Spring doc OpenAPI using Swagger UI = http://localhost:8080/swagger-ui/index.html
----------------------------------------------------------
Actuator url = http://localhost:8080/actuator
This diff is collapsed.
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.12</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.nisum</groupId>
<artifactId>splitmerchantpayment</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>splitmerchantpayment</name>
<description>Worker Bees - Split Merchant Payment</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<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>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</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>com.razorpay</groupId>
<artifactId>razorpay-java</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.15</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.nisum.splitmerchantpayment;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SplitmerchantpaymentApplication {
public static void main(String[] args) {
SpringApplication.run(SplitmerchantpaymentApplication.class, args);
}
}
package com.nisum.splitmerchantpayment.configuration;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.razorpay.RazorpayClient;
import com.razorpay.RazorpayException;
@Configuration
public class BeanConfiguration {
@Value("${razorpay.key.id}")
public String keyId;
@Value("${razorpay.key.secret}")
public String keySecret;
@Bean
public RazorpayClient createRazorpayClient() throws RazorpayException {
return new RazorpayClient(keyId, keySecret, true);
}
}
package com.nisum.splitmerchantpayment.controllers;
import com.nisum.splitmerchantpayment.entity.OrderDao;
import com.nisum.splitmerchantpayment.entity.Product;
import com.nisum.splitmerchantpayment.model.ProductDto;
import com.nisum.splitmerchantpayment.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Admin controller class where we give all
* our rest API's and various endpoints
*/
@RestController
public class AdminController {
@Autowired
private AdminService adminService;
/**
* This method is used to give endpoint to save the product
* details given using post mapping.
* @param productDto
* @return String with response message
*/
@PostMapping(value = "/products")
public ResponseEntity<String> save(@RequestBody ProductDto productDto) {
Product product = adminService.addProduct(productDto);
return product != null ? ResponseEntity.status(HttpStatus.OK).body("product is saved") :
ResponseEntity.status(HttpStatus.BAD_REQUEST).body("unable to save product");
}
/**
* This method is to get the product of particular id
* with endpoint of rest product with id using get mapping
* @param id
* @return Product response request
*/
@GetMapping(value = "/products/{id}")
public ResponseEntity<Product> getById(@PathVariable(name = "id") String id) {
Product product = adminService.getProductById(id);
return product != null ? ResponseEntity.status(HttpStatus.OK).body(product) :
ResponseEntity.status(HttpStatus.BAD_REQUEST).body(product);
}
/**
* This method is used to get all products available or which
* present in the data base by using the endpoint get mapping of products
* @return Products with iterating all its fields
*/
@GetMapping("/products")
public ResponseEntity<Iterable<Product>> getAllProducts() {
Iterable<Product> product = adminService.getAllProducts();
return new ResponseEntity<>(product, HttpStatus.OK);
}
/**
* This method is used to give the rest endpoint of the products which
* perform soft-delete operation of particular given id using delete mapping
* @param id
*/
@DeleteMapping("/products/{id}")
public ResponseEntity<String> softDeleteProduct(@PathVariable String id) {
adminService.deleteProductById(id);
return new ResponseEntity<String>("product deleted",HttpStatus.OK);
}
/**
* This method is used to give the list of orders using the endpoint of
* get mapping to all orders of every customer.
* @return orders of list
*/
@GetMapping("/allOrders")
public ResponseEntity<List<OrderDao>> getAllOrders() {
List<OrderDao> orderDaoList = adminService.getAllOrders();
return new ResponseEntity<>(orderDaoList, HttpStatus.OK);
}
/**
* This method is used to give the response of the endpoint by using put-mapping
* to update a particular product
* @param id
* @param productDto
* @return
*/
@PutMapping("/products/{id}")
public ResponseEntity<String> updateProduct(@PathVariable String id,@RequestBody ProductDto productDto) {
Product product= adminService.updateProductById(id, productDto);
return product != null ? ResponseEntity.status(HttpStatus.OK).body("product is Updated") :
ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body("unable to update the product");
}
}
package com.nisum.splitmerchantpayment.controllers;
import com.nisum.splitmerchantpayment.entity.CartProduct;
import com.nisum.splitmerchantpayment.entity.OrderDao;
import com.nisum.splitmerchantpayment.model.CartDto;
import com.nisum.splitmerchantpayment.model.CustomerOrderDto;
import com.nisum.splitmerchantpayment.model.CustomerPaymentDto;
import com.nisum.splitmerchantpayment.model.ProductToCartDto;
import com.nisum.splitmerchantpayment.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* This is User Controller class we present all different API's
* and various endpoints
*/
@RestController
public class UserController {
@Autowired
private UserService userService;
/**
* This method is used to add products to the cart with using the endpoint
* as post-mapping
*
* @param productToCartDto
* @return String with response message
*/
@PostMapping(value = "/carts")
public ResponseEntity<String> addToCart(@RequestBody ProductToCartDto productToCartDto) {
String message = userService.addToCart(productToCartDto);
return ResponseEntity.status(HttpStatus.OK).body(message);
}
/**
* This method is used to get the products added in cart
* by giving a specific customer phone-number as id by using
* get-mapping endpoint
*
* @param customerPhoneNumber
* @return cartDto
*/
@GetMapping(value = "/carts")
public ResponseEntity<CartDto> getCart(@RequestParam String customerPhoneNumber) {
List<CartProduct> orderedProducts = userService.getCartList(customerPhoneNumber);
Double amountPayable = orderedProducts
.stream()
.map(cartProductDto -> cartProductDto.getQuantity() * cartProductDto.getPrice())
.reduce(0.00, (init, cost) -> init + cost);
return ResponseEntity.status(HttpStatus.OK).body(CartDto.builder()
.cartProducts(orderedProducts).amountPayable(amountPayable).build());
}
/**
* This method is used to place the order which are present in the
* cart by using post-mapping and providing specific customer's phone-number
* and total amount
*
* @param customerPaymentDto
* @return order with generation of orderId
*/
@PostMapping(value = "/orders")
public ResponseEntity<OrderDao> placeOrder(@RequestBody CustomerPaymentDto customerPaymentDto) {
return ResponseEntity.status(HttpStatus.OK)
.body(userService
.placeOrder(customerPaymentDto.getPhoneNumber(), customerPaymentDto.getAmount()));
}
/**
* This method is used to give the list of orders according to their
* specific customer phone-number by using endpoint get-mapping
*
* @param customerPhoneNumber
* @return ordersList
*/
@GetMapping(value = "/orders")
public ResponseEntity<List<OrderDao>> ordersByCustomer(@RequestParam String customerPhoneNumber) {
List<OrderDao> orderDaoList = userService.getOrdersByCustomer(customerPhoneNumber);
return ResponseEntity.status(HttpStatus.OK).body(orderDaoList);
}
/**
* This method is used to give the order details by providing specific orderId
*
* @param customerOrderDto
* @return order
*/
@GetMapping(value = "/customerorders")
public ResponseEntity<OrderDao> ordersBYId(@RequestBody CustomerOrderDto customerOrderDto) {
OrderDao orderDao = userService.getOrderByCustomerIdAndOrderId(customerOrderDto.getPhoneNumber
(), customerOrderDto.getOrderId());
return ResponseEntity.status(HttpStatus.OK).body(orderDao);
}
}
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "brand")
/**
* This is Brand class which has
* all setters and getters
* constructors
* toString methods by single lombok annotation
*/
public class Brand {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "name")
@NotNull
private String name;
}
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "cart_product")
/**
* This is Cart-Product class which has
* all setters and getters
* constructors
* toString methods by single lombok annotation
*/
public class CartProduct {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Column(name = "product_id")
@NotNull
private String productId;
@Column(name = "product_name")
@NotNull
private String productName;
@Column(name = "product_brand")
@NotNull
private String productBrand;
@Column(name = "category")
@NotNull
private String category;
@Column(name = "ideal_for")
@NotNull
private String idealFor;
@Column(name = "size")
@NotNull
private String size;
@Column(name = "price")
@NotNull
private Double price;
@Column(name = "quantity")
@NotNull
private Integer quantity;
@Column(name = "customer_phone_number")
@NotNull
private String customerPhoneNumber;
}
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "category")
/**
* This is Category class which has
* all setters and getters
* constructors
* toString methods by single lombok annotation
*/
public class Category {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "name")
@NotNull
private String name;
}
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "customer")
/**
* This is Customer class which has
* all setters and getters
* constructors
* toString methods by single lombok annotation
*/
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Integer id;
@Column(name = "name")
@NotNull
private String name;
@Column(name = "phone_number", unique = true, nullable = false)
@NotNull
private String phoneNumber;
@Column(name = "address_lane1")
@NotNull
private String addressLane1;
@Column(name = "address_lane2")
@NotNull
private String addressLane2;
@Column(name = "city")
@NotNull
private String city;
@Column(name = "state")
@NotNull
private String state;
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "customer_id")
@NotNull
private List<OrderDao> orderDao;
}
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "orders")
/**
* This is Order class which has
* all setters and getters
* constructors
* toString methods by single lombok annotation
*/
public class OrderDao {
@Id
@Column(name = "order_id")
private String orderId;
// @ManyToOne(cascade = CascadeType.ALL)
// @JoinColumn(name = "customer_Id")
// private Customer customer;
@Column(name = "bill")
@NotNull
private Double bill;
@Column(name = "order_date")
@NotNull
private final LocalDate LOCAL_DATE = LocalDate.now();
@Column(name = "order_time")
@NotNull
private final LocalTime LOCAL_TIME = LocalTime.now().truncatedTo(ChronoUnit.SECONDS);
@OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = "order_id")
@NotNull
private List<OrderedProduct> orderedProductList;
}
\ No newline at end of file
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "ordered_products")
/**
* This is Order-Product class which has all setters and getters constructors
* toString methods by single lombok annotation
*/
public class OrderedProduct {
@Id
@Column(name = "s_no")
@GeneratedValue(strategy = GenerationType.AUTO)
private Long serialNo;
@Column(name = "product_id")
private String productId;
@Column(name = "product_name")
private String productName;
@Column(name = "product_brand")
private String productBrand;
@Column(name = "category")
private String category;
@Column(name = "gender")
private String idealFor;
@Column(name = "size")
private String size;
@Column(name = "price")
private Double price;
@Column(name = "Quantity")
private Integer quantity;
// @ManyToOne(targetEntity = Order.class)
// @JoinColumn(name = "Order_Id")
//
// private Order order;
}
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "product")
@SQLDelete(sql = "update Product set is_active = false where product_id=? and is_active = true")
/**
* This is Product class which has all setters and getters constructors
* toString methods by single lombok annotation
*/
public class Product {
@Id
@Column(name = "product_id")
private String productId;
@OneToOne(targetEntity = ProductName.class, cascade = CascadeType.DETACH)
@JoinColumn(name = "product_name_id")
@NotNull
private ProductName productName;
@OneToOne(targetEntity = Brand.class, cascade = CascadeType.DETACH)
@JoinColumn(name = "brand_id")
@NotNull
private Brand brand;
@OneToOne(targetEntity = Category.class, cascade = CascadeType.DETACH)
@JoinColumn(name = "category_id")
@NotNull
private Category category;
@Column(name = "ideal_for")
@NotNull
private String idealFor;
@Column(name = "price")
@NotNull
private Double price;
@Column(name = "is_active", nullable = false, columnDefinition = "boolean default TRUE")
@NotNull
private Boolean isActive;
@Column(name = "size")
@Embedded
@NotNull
private Size size;
@Column(name = "vendor_account")
@NotNull
private String vendorAccount;
@Column(name = "platform_charge")
@NotNull
private Double platformCharge;
}
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "product_name")
/**
* This is Product-Name class which has
* all setters and getters
* constructors
* toString methods by single lombok annotation
*/
public class ProductName {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "name")
@NotNull
private String name;
}
package com.nisum.splitmerchantpayment.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Embeddable
/**
* This is Size class which has
* all setters and getters
* constructors
* toString methods by single lombok annotation
*/
public class Size {
@NotNull
private Integer s, m, l, xl, xxl;
}
package com.nisum.splitmerchantpayment.exception;
public class BrandNotFoundException extends RuntimeException{
public BrandNotFoundException(String message) {
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
public class CategoryNotFoundException extends RuntimeException{
public CategoryNotFoundException(String message) {
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
public class CustomerNotFoundException extends RuntimeException {
public CustomerNotFoundException(String message) {
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
/**
* This class handles all the exceptions raised and returns response entity based on the exception
*/
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler({ProductNotAvailableException.class,
SizeTypeNotAvailableException.class,
QuantityNotAvailableException.class,
CustomerNotFoundException.class,
InvalidAmountException.class,
OrderListEmptyException.class,
OrderNotFoundException.class,
OrderNotFoundException.class,
CategoryNotFoundException.class,
ProductNotAvailableException.class})
public ResponseEntity<String> handleException(Exception e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
}
}
\ No newline at end of file
package com.nisum.splitmerchantpayment.exception;
public class InvalidAmountException extends RuntimeException {
public InvalidAmountException(String message) {
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
public class OrderListEmptyException extends RuntimeException {
public OrderListEmptyException(String message){
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
public class OrderNotFoundException extends RuntimeException {
public OrderNotFoundException(String message) {
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
public class ProductNameNotFoundException extends RuntimeException{
public ProductNameNotFoundException(String message) {
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
public class ProductNotAvailableException extends RuntimeException{
public ProductNotAvailableException(String message){
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
public class QuantityNotAvailableException extends RuntimeException{
public QuantityNotAvailableException(String message) {
super(message);
}
}
package com.nisum.splitmerchantpayment.exception;
public class SizeTypeNotAvailableException extends RuntimeException{
public SizeTypeNotAvailableException(String message){
super(message);
}
}
package com.nisum.splitmerchantpayment.model;
import com.nisum.splitmerchantpayment.entity.CartProduct;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CartDto {
List<CartProduct> cartProducts;
Double amountPayable;
}
package com.nisum.splitmerchantpayment.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CartProductDto {
private String productId;
private String productName;
private String productBrand;
private String category;
private String idealFor;
private String size;
private Double price;
private Integer quantity;
}
package com.nisum.splitmerchantpayment.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CustomerOrderDto {
private String phoneNumber;
private String orderId;
}
package com.nisum.splitmerchantpayment.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CustomerPaymentDto {
private String phoneNumber;
private Double amount;
}
package com.nisum.splitmerchantpayment.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OrderDto {
private String orderId;
private String customerName;
private String phoneNumber;
private Double bill;
private LocalDate orderDate;
private LocalTime orderTime;
private List<OrderedProductDto> productDtoList;
}
\ No newline at end of file
package com.nisum.splitmerchantpayment.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class OrderedProductDto {
private String productId;
private String productName;
private String productBrand;
private String category;
private String idealFor;
private String size;
private Double price;
private String orderId;
}
package com.nisum.splitmerchantpayment.model;
import com.nisum.splitmerchantpayment.entity.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ProductDto {
private String productId;
private Integer productName;
private Integer brand;
private Integer category;
private String idealFor;
private Double price;
private Size size;
private Boolean isActive;
private String vendorAccount;
private Double platformCharge;
}
package com.nisum.splitmerchantpayment.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ProductToCartDto {
private String productId;
private String size;
private Integer quantity;
private String customerPhoneNumber;
}
package com.nisum.splitmerchantpayment.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SizeDto {
private Integer s, m, l, xl, xxl;
}
package com.nisum.splitmerchantpayment.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class UserDto {
private String name;
private String phoneNumber;
private String email;
private String password;
}
package com.nisum.splitmerchantpayment.repository;
import com.nisum.splitmerchantpayment.entity.Size;
import com.nisum.splitmerchantpayment.exception.SizeTypeNotAvailableException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
* This is a customized repository with updateProduct that helps to update
* product irrespective of different product properties
*/
@Repository
public class BaseRepository {
@PersistenceContext
private EntityManager getEntityManger;
@Autowired
private ProductRepository productRepo;
/**
* This method will updates product table irrespective of different columns
* @param columnName
* @param id
* @param quantity
* @return
*/
public int updateProduct(String columnName, String id, Integer quantity) {
Integer orginalQuantity = getQuantity(columnName, id) - quantity;
return getEntityManger.createQuery("update Product set " + columnName + "= :quantity where productId=:id")
.setParameter("quantity", orginalQuantity)
.setParameter("id", id)
.executeUpdate();
}
/**
* This helps to give product quantity irrespective of different sizes
* @param columnName
* @param id
* @return
*/
private Integer getQuantity(String columnName, String id) {
Size size = productRepo.findById(id).get().getSize();
Integer quantity = 0;
switch (columnName) {
case "s":
quantity = size.getS();
break;
case "m":
quantity = size.getM();
break;
case "l":
quantity = size.getL();
break;
case "xl":
quantity = size.getXl();
break;
case "xxl":
quantity = size.getXxl();
break;
default:
throw new SizeTypeNotAvailableException("Product not available for the size ");
}
return quantity;
}
}
\ No newline at end of file
package com.nisum.splitmerchantpayment.repository;
import com.nisum.splitmerchantpayment.entity.Brand;
import org.springframework.data.jpa.repository.JpaRepository;
public interface BrandRepository extends JpaRepository<Brand, Integer> {
}
package com.nisum.splitmerchantpayment.repository;
import com.nisum.splitmerchantpayment.entity.CartProduct;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface CartProductRepository extends JpaRepository<CartProduct, Long> {
public List<CartProduct> findAllByCustomerPhoneNumber(String phoneNumber);
public void deleteAllByCustomerPhoneNumber(String phoneNumber);
}
package com.nisum.splitmerchantpayment.repository;
import com.nisum.splitmerchantpayment.entity.Category;
import org.springframework.data.jpa.repository.JpaRepository;
public interface CategoryRepository extends JpaRepository<Category, Integer> {
}
package com.nisum.splitmerchantpayment.repository;
import com.nisum.splitmerchantpayment.entity.Customer;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface CustomerRepository extends JpaRepository<Customer, Integer> {
public Optional<Customer> findByPhoneNumber(String phoneNumber);
}
\ No newline at end of file
package com.nisum.splitmerchantpayment.repository;
import com.nisum.splitmerchantpayment.entity.OrderDao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface OrderRepository extends JpaRepository<OrderDao, String> {
}
package com.nisum.splitmerchantpayment.repository;
import com.nisum.splitmerchantpayment.entity.ProductName;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ProductNameRepository extends JpaRepository<ProductName, Integer> {
}
package com.nisum.splitmerchantpayment.repository;
import com.nisum.splitmerchantpayment.entity.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import javax.transaction.Transactional;
import java.util.List;
public interface ProductRepository extends JpaRepository<Product, String> {
List<Product> findAllByIsActive(Boolean isActive);
@Modifying
@Transactional
@Query(value = "update Product set isActive = true where productId = ?1")
void unDeleteById(String productId);
}
package com.nisum.splitmerchantpayment.service;
import com.nisum.splitmerchantpayment.entity.OrderDao;
import com.nisum.splitmerchantpayment.entity.Product;
import com.nisum.splitmerchantpayment.model.ProductDto;
import java.util.List;
public interface AdminService {
/**
* This is an abstract method gives the
* Admin Operations for adding products and save them
* @param productDto
* @return Product
*/
public Product addProduct(ProductDto productDto);
/**
* This abstract method is used to
* soft-delete the product by its specific id
* @param productId
*/
public void deleteProductById(String productId);
/**
* This is an abstract method which performs
* get the product by its id.
* @param productId
* @return Product
*/
public Product getProductById(String productId);
/**
* This is an abstract method
* This method behaviour is to display list of products
* @return ProductsList
*/
public List<Product> getAllProducts();
/**
* This an abstract method and its
* behaviour is to give the list of orders which placed by the
* customers
* @return OrdersList
*/
public List<OrderDao> getAllOrders();
/**
* This is the abstract method used to
* update a product by giving the respective Id.
* @param productId
* @param productDto
* @return Product
*/
public Product updateProductById(String productId, ProductDto productDto);
}
package com.nisum.splitmerchantpayment.service;
import com.nisum.splitmerchantpayment.entity.ProductName;
import com.nisum.splitmerchantpayment.exception.BrandNotFoundException;
import com.nisum.splitmerchantpayment.exception.CategoryNotFoundException;
import com.nisum.splitmerchantpayment.exception.OrderListEmptyException;
import com.nisum.splitmerchantpayment.exception.ProductNameNotFoundException;
import com.nisum.splitmerchantpayment.exception.ProductNotAvailableException;
import com.nisum.splitmerchantpayment.model.ProductDto;
import com.nisum.splitmerchantpayment.repository.BrandRepository;
import com.nisum.splitmerchantpayment.repository.CategoryRepository;
import com.nisum.splitmerchantpayment.repository.OrderRepository;
import com.nisum.splitmerchantpayment.repository.ProductNameRepository;
import com.nisum.splitmerchantpayment.repository.ProductRepository;
import com.nisum.splitmerchantpayment.utils.IDGeneratorUtility;
import com.nisum.splitmerchantpayment.entity.Brand;
import com.nisum.splitmerchantpayment.entity.Category;
import com.nisum.splitmerchantpayment.entity.OrderDao;
import com.nisum.splitmerchantpayment.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
import java.util.Optional;
@Service
public class AdminServiceImpl implements AdminService {
@Autowired
private ProductRepository productRepository;
@Autowired
private CategoryRepository categoryRepo;
@Autowired
private BrandRepository brandRepo;
@Autowired
private ProductNameRepository productNameRepo;
@Autowired
private OrderRepository orderRepository;
@Autowired
private IDGeneratorUtility idGeneratorUtility;
@PersistenceContext
private EntityManager getEntityManager;
@Override
public Product addProduct(ProductDto productDto) throws RuntimeException {
Brand brand = brandRepo.findById(productDto.getBrand())
.orElseThrow(() -> new BrandNotFoundException("Brand is not found with id : " + productDto.getBrand()));
Category category = categoryRepo.findById(productDto.getCategory())
.orElseThrow(() -> new CategoryNotFoundException("Category is not found with id : " + productDto.getCategory()));
ProductName productName = productNameRepo.findById(productDto.getProductName())
.orElseThrow(() -> new ProductNameNotFoundException("Product is not found with id : " + productDto.getProductName()));
if (brand == null || category == null || productName == null) {
throw new NullPointerException("Please Enter Valid Brand ID or Category ID or ProductName ID");
} else {
String productId = idGeneratorUtility.productIdGenerator();
Product product = Product.builder().productId(productId).brand(brand).category(category).productName(productName).isActive(productDto.getIsActive())
.size(productDto.getSize()).price(productDto.getPrice()).idealFor(productDto.getIdealFor()).vendorAccount(productDto.getVendorAccount())
.platformCharge(productDto.getPlatformCharge()).build();
return productRepository.save(product);
}
}
@Override
public Product updateProductById(String productId, ProductDto productDto) {
Optional<Product> product = productRepository.findById(productId);
if (product.isPresent()) {
Product existingProduct = product.get();
existingProduct.setIdealFor(productDto.getIdealFor().equals(Optional.empty()) ? existingProduct.getIdealFor() : productDto.getIdealFor());
existingProduct.setSize(productDto.getSize().equals(Optional.empty()) ? existingProduct.getSize() : productDto.getSize());
existingProduct.setPrice(productDto.getPrice().equals(Optional.empty()) ? existingProduct.getPrice() : productDto.getPrice());
Product updateProductById = productRepository.save(existingProduct);
return updateProductById;
} else
return null;
}
@Override
public void deleteProductById(String productId) {
if (productId == null) {
throw new NullPointerException("Enter a Valid Product ID");
} else {
Boolean active = productRepository.findById(productId).get().getIsActive();
if (active) {
productRepository.deleteById(productId);
} else {
productRepository.unDeleteById(productId);
}
}
}
@Override
public Product getProductById(String productId) {
Optional<Product> product = productRepository.findById(productId);
return product
.orElseThrow(() -> new ProductNotAvailableException("product is not available with the id " + productId));
}
@Override
public List<Product> getAllProducts() {
List<Product> products = productRepository.findAllByIsActive(true);
if (!products.isEmpty()) {
return products;
} else
throw new ProductNotAvailableException("Product List Empty");
}
@Override
public List<OrderDao> getAllOrders() {
List<OrderDao> orderDaoList = orderRepository.findAll();
if (!orderDaoList.isEmpty()) {
return orderDaoList;
} else
throw new OrderListEmptyException("Order List Empty");
}
}
package com.nisum.splitmerchantpayment.service;
import com.nisum.splitmerchantpayment.entity.CartProduct;
import com.nisum.splitmerchantpayment.entity.OrderDao;
import com.nisum.splitmerchantpayment.entity.Product;
import com.nisum.splitmerchantpayment.model.ProductToCartDto;
import java.util.List;
/**
* UserService is an Interface.
* It's providing five features to implement user operations
* Those are : getProductById(String productId)
* checkAvailability(ProductToCartDto productToCartDto)
* addToCart(ProductToCartDto productToCartDto)
* getCartList(String customerPhoneNumber)
* placeOrder(String customerPhoneNumber, Double amount)
* getOrdersByCustomer(String customerPhoneNumber)
*/
public interface UserService {
/**
* getProductById method helpful to find by productId
* @param productId
* @return
*/
public Product getProductById(String productId);
/**
* checkAvailability will check quantity which all existed in database to user required quantity.
* @param productToCartDto
* @return
*/
public Product checkAvailability(ProductToCartDto productToCartDto);
/**
* addToCart method is helpful to add product to cart
* and condition checks will be done here before adding to the cart
* @param productToCartDto
* @return String
*/
public String addToCart(ProductToCartDto productToCartDto);
/**
* getCartList method helpful to get cart list what all products customer ordered previously
* @param customerPhoneNumber
* @return
*/
public List<CartProduct> getCartList(String customerPhoneNumber);
/**
* placeOrder is helpful to place order what all products added to cart, and it returns order details.
* @param customerPhoneNumber
* @param amount
* @return
*/
public OrderDao placeOrder(String customerPhoneNumber, Double amount);
/**
* getOrdersByCustomer method helpful to get Ordered history of customer by id,
* and it returns order history of specific customer
* @param customerPhoneNumber
* @return
*/
public List<OrderDao> getOrdersByCustomer(String customerPhoneNumber);
/**
* getOrdersByCustomer method helpful to get Ordered history of customer by id and order id,
* and it returns order history of customer to specific order id
* @param customerPhoneNumber
* @param orderId
* @return
*/
public OrderDao getOrderByCustomerIdAndOrderId(String customerPhoneNumber, String orderId);
}
\ No newline at end of file
package com.nisum.splitmerchantpayment.utils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.UUID;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Component
public class IDGeneratorUtility {
public String orderIdGenerator() {
return "order#" + UUID.randomUUID().toString().split("-")[0];
}
public String productIdGenerator() {
return "prod#" + UUID.randomUUID().toString().split("-")[2];
}
}
spring.jpa.show-sql = true
spring.h2.console.path=/h2
spring.jpa.hibernate.ddl-auto = update
spring.datasource.url=jdbc:h2:mem:oms
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=user
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
#enabling the H2 console
spring.h2.console.enabled=true
#persist the data
#spring.datasource.url=jdbc:h2:file:/data/sampledata
#spring.datasource.url=jdbc:h2:C:/data/sampledata
flyway.enabled=true
flyway.locations=classpath:/db/migration
razorpay.currency = INR
razorpay.key.id = rzp_test_dCF28jdNzvmMBt
razorpay.key.secret = 4nqJkM5odnnRdwqCBfosqYXZ
\ No newline at end of file
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
spring.jpa.database-platform=
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql = true
\ No newline at end of file
spring.profiles.active=dev
spring.devtools.restart.enabled=true
management.endpoints.web.exposure.include=*
\ No newline at end of file
create table brand (id integer not null, name varchar(255), primary key (id));
create table category (id integer not null, name varchar(255), primary key (id));
create table product_name (id integer not null, name varchar(255), primary key (id));
create table customer (id integer not null,phone_number varchar(255),name varchar(255), address_lane1 varchar(255), address_lane2 varchar(255), city varchar(255), state varchar(255), primary key (id));
create table product (brand_id integer, category_id integer, vendor_account varchar(255), platform_charge integer, ideal_for varchar(255),price double,product_name_id integer,l integer, m integer, s integer, xl integer, xxl integer,product_id varchar(255) not null,primary key (product_id));
--drop table if exists testing;
--create table testing(id integer, name varchar(255));
--INSERT into testing values(1,'hello world');
--drop table if exists category;
Insert into category values (1, 'SHIRTS');
Insert into category values(2,'T-SHIRTS');
Insert into category values(3,'TROUSERS');
Insert into category values(4,'JEANS');
Insert into category values(5,'SWEATSHIRT');
--drop table if exists brands;
Insert into brand values(1,'PUMA');
Insert into brand values(2,'USPA');
Insert into brand values(3,'GAP');
Insert into brand values(4,'TOMMY');
Insert into brand values(5,'CELIO');
--drop table if exits product_name;
Insert into product_name values(1,'Men Reqular Fit Checkered Spread Collar Casual Shirt');
Insert into product_name values(2,'Men Regular Fit Striped Ribbed Collar Casual Shirt');
Insert into product_name values(3,'Men Slim Fit Printed Checkered Casual Shirt');
Insert into product_name values(4,'Women Regular Fit Striped Mandarin Collar Casual Shirt');
Insert into product_name values(5,'Women Regular Fit Solid Spread Collar Casual Shirt');
Insert into product_name values(6,'Women Regular Fit Checkered Formal Shirt');
Insert into product_name values(7,'Printed Men Hooded Neck Black T-Shirt');
Insert into product_name values(8,'Striped Men Round Neck Dark Blue, White, Brown T-Shirt');
Insert into product_name values(9,'Solid Women Round Neck Black Pink T-Shirt');
Insert into product_name values(10,'Graphic Print Women Round Neck White T-Shirt');
Insert into product_name values(11,'Regular Fit Men Black Cotton Blend Trousers');
Insert into product_name values(12,'Regular Fit Men Grey Cotton Blend Trousers');
Insert into product_name values(13,'Tapered Women Multicolor Cotton Blend Trousers');
Insert into product_name values(14,'Regular Fit Women Black Lycra Blend Trousers');
Insert into product_name values(15,'Regular Men Light Blue Jeans');
Insert into product_name values(16,'Skinny Men Black Jeans');
Insert into product_name values(17,'High Waist Flared Fit Regular Length Clean Look Denim Flared Women Blue Jeans');
Insert into product_name values(18,'Boyfriend Women Dark Blue Jeans');
Insert into product_name values(19,'Full Sleeve Color Block Men Sweatshirt');
Insert into product_name values(20,'Full Sleeve Printed Men Sweatshirt');
Insert into product_name values(21,'Full Sleeve Solid Women Sweatshirt');
Insert into product_name values(22,'Full Sleeve Solid Pink Women Sweatshirt');
--products
--Insert into products values(1,'male',2199.00,2,3,4,2,2,2,3,4);
--customer
Insert into customer values(1,8834567890,'Brahmi','flat-201','Street 3 DSNR','Hyderabad','Telangana');
Insert into customer values(2,9977881234,'Suresh','flat-210','Street 1 Kukutpally','Hyderabad','Telangana');
Insert into customer values(3,9876564567,'Mahesh','flat-214','Housing Villas L.B.Nagar','Hyderabad','Telangana');
Insert into customer values(4,8764456788,'Soundarya','flat-202','Road-3 KPHB','Hyderabad','Telangana');
Insert into customer values(5,7747892211,'Sneha','flat-311 B.ARaju Apartments','Near Hanuman Temple Chandha Nagar','Hyderabad','Telangana');
Insert into customer values(6,8897564532,'Malesh','flat-101','Road-6 Singh Nagar','Vijayawada','Andhra Pradesh');
Insert into customer values(7,9908090989,'Naresh','flat-103','Road-5 Madhura Nagar','Khammam','Telangana');
Insert into customer values(8,9876789090,'Sunder','flat-105','YSR apartments Gandhi Nagar','Kurnool','Andhra Pradesh');
Insert into customer values(9,9712432211,'Sridevi','flat-201 SRI Sai Apartments','MLAs Colony','Vizag','Andhra Pradesh');
Insert into customer values(10,8228782739,'Smitha','flat-501','Street 3 Bharath Nagar','Hyderabad','Telangana');
insert into product (brand_id, category_id, vendor_account, platform_charge, ideal_for, price, product_name_id, l, m, s, xl, xxl, product_id) values
(1, 2, 'acc_LwyPZKX1DO4H8Q', 5, 'men', 1560.00, 2, 4, 5, 5, 5, 3, '111');
insert into product (brand_id, category_id, vendor_account, platform_charge, ideal_for, price, product_name_id, l, m, s, xl, xxl, product_id) values
(1, 2, 'acc_Lz0gYn3h45RCnH', 3, 'women', 2240.00, 2, 4, 5, 5, 5, 3, '112');
insert into product (brand_id, category_id, vendor_account, platform_charge, ideal_for, price, product_name_id, l, m, s, xl, xxl, product_id) values
(1, 2, 'acc_LwyPZKX1DO4H8Q', 5, 'men', 1300.00, 2, 4, 5, 5, 5, 3, '113');
insert into product (brand_id, category_id, vendor_account, platform_charge, ideal_for, price, product_name_id, l, m, s, xl, xxl, product_id) values
(1, 2, null, 0, 'men', 1280.00, 2, 4, 5, 5, 5, 3, '114');
\ No newline at end of file
package com.nisum.splitmerchantpayment;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SplitmerchantpaymentApplicationTests {
@Test
void contextLoads() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment