This ia a Functional Backend Stack Coupon System. This is targeting large-scale services. It is built using Java, PostgreSQL, and Spring Boot framework.
- Programming Language : Java 14
- Database : PostgreSQL
- Framework : Spring Boot 2.3.0
- Gradle
- JPA
- Junit 5
- IDE : IntelliJ IDEA Ultimate
- OS : Windows
- Version Control : Git
- Terminal Environment
$ ./gradlew clean build
$ java -jar kakao-0.0.1-SNAPSHOT.jar
- Access URI
http://localhost:5000
- Swagger
http://localhost:5000/swagger-ui.html
URL : /api/coupon/createCoupon Method : POST
- Header
Token | Authentication Authority |
---|---|
Bearer | ADMIN |
URL : /api/coupon/payCoupon Method : POST
- Header
Token | Authentication Authority |
---|---|
Bearer | ADMIN,USER |
- Parameter
Value | Type | Required |
---|---|---|
String | Y |
URL : /api/coupon/viewCoupon Method : GET
- Header
Token | Authentication Authority |
---|---|
Bearer | ADMIN,USER |
- Parameter
Value | Type | Required |
---|---|---|
String | Y |
URL : /api/coupon/useCoupon/{couponId}/{utilizationStatus} Method : GET
- Header
Token | Authentication Authority |
---|---|
Bearer | USER |
- Parameter
Value | Type | Required |
---|---|---|
String | Y | |
couponId | Long | Y |
URL : /api/coupon/useCoupon/{couponId}/{utilizationStatus} Method : GET
- Header
Token | Authentication Authority |
---|---|
Bearer | USER |
- Parameter
Value | Type | Required |
---|---|---|
String | Y | |
couponId | Long | Y |
URL : /api/coupon/viewExpirationCoupons Method : GET
- Header
Token | Authentication Authority |
---|---|
Bearer | ADMIN |
- Spring Security
- a token-based api authentication function using jwt
URL : /api/user/signup Method : POST
- Parameter
Value | Type | Required |
---|---|---|
String | Y | |
name | String | Y |
password | String | Y |
URL : /api/user/signin Method : POST
- Parameter
Value | Type | Required |
---|---|---|
String | Y | |
password | String | Y |
* getAllCouponsByExpirationDate() : the scheduler to check coupons 3 days before expiration at 9:30 AM * (confirmMessageStoredStatus()) : To prevent duplicate storage, check whether the data is present in the coupon message table , Save it to the table only if data doesn't exist. * message confirmation column -> default: false * changeCouponMessageCheckStatus() : When the user accesses and checks the message, the message confirmation column changes to true.
- Coupon Code Generation Method
1-1. Random String generation (Example : dmxcdyf8zo0t13t1ahya)
- Coupon Code stored with Hash value can be fast search
- Random code generation mixing 20 digits of English and numbers
- Use java.util.Random class
- nextBoolean() method return true(lower case),false(random numbers)
- nextInt() method convertor returned numbers to 62 digit([0-9][a-z][A-Z])
- Random String generation of a 20 digits arbitrary string connecting all characters created by repeating 20 times with StringBuffer
1-2. HashCode Generation (Example : 1828977362)
-
Get the generated random code, create a Hash Code, and save it together
- Use java.util.zip.CRC32
- Change the random code to byte array
- Create a CRC32 Long-form code using the byte array value update() function
-
Realistic performance issues
- From a small number of data, random code can be inquired and generated.
- However, when searching hundreds of millions of data, it costs a lot to check the code value.
- Inquiry by storing hash code values created when issuing coupon codes (reduced from 40 seconds to 20 seconds when 9,991 pieces are stored at once).