Commit 8034f326 authored by John Lam's avatar John Lam

Add Promotion repository/controller/Service skeleton

parent 4bd427cb
package com.nisum.ascend.promotions.controller;
import com.nisum.ascend.promotions.repository.PromotionRepository;
import com.nisum.ascend.promotions.service.PromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/promos")
public class PromotionsController {
@Autowired
PromotionService promotionService;
}
package com.nisum.ascend.promotions.model;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
@Getter
@Setter
@Document
public class Promotion {
@Id
private String id;
@Indexed(unique=true)
private String promotionId;
private String productSku;
private float discountPercentage;
private int minimumQuantity;
public Promotion(String promotionId, String productSku, float discountPercentage, int minimumQuantity) {
this.promotionId = promotionId;
this.productSku = productSku;
this.discountPercentage = discountPercentage;
this.minimumQuantity = minimumQuantity;
}
}
package com.nisum.ascend.promotions.repository;
import com.nisum.ascend.promotions.model.Promotion;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface PromotionRepository extends ReactiveMongoRepository<Promotion, String> {
}
package com.nisum.ascend.promotions.service;
import com.nisum.ascend.promotions.repository.PromotionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class PromotionService {
@Autowired
PromotionRepository promotionRepository;
}
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