package com.oms.controller; import com.oms.dto.PromotionDTO; import com.oms.entity.Promotion; import com.oms.service.PromotionService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/marketing/promotions") @RequiredArgsConstructor public class PromotionController { private final PromotionService promotionService; @GetMapping public List getPromotions( @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") int size) { return promotionService.getPage(page, size).getRecords(); } @GetMapping("/all") public List getAll() { return promotionService.getAll(); } @GetMapping("/{id}") public PromotionDTO getById(@PathVariable Long id) { return promotionService.getDtoById(id); } @PostMapping public Long create(@RequestBody Promotion promotion) { return promotionService.save(promotion); } @PutMapping("/{id}") public void update(@PathVariable Long id, @RequestBody Promotion promotion) { promotion.setId(id); promotionService.update(promotion); } @DeleteMapping("/{id}") public void delete(@PathVariable Long id) { promotionService.delete(id); } @PostMapping("/{id}/activate") public void activate(@PathVariable Long id) { promotionService.activate(id); } @PostMapping("/{id}/deactivate") public void deactivate(@PathVariable Long id) { promotionService.deactivate(id); } }