Ignore:
Timestamp:
10/12/24 21:32:15 (5 weeks ago)
Author:
macagaso <gasoskamarija@…>
Branches:
master
Parents:
743de55
Message:

Updated version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/finki/it/terapijamkbackend/spring/controllers/CouponController.java

    r743de55 r43c9090  
    33import finki.it.terapijamkbackend.spring.services.CouponsService;
    44import jakarta.persistence.EntityNotFoundException;
    5 import jakarta.transaction.Transactional;
    65import org.springframework.beans.factory.annotation.Autowired;
    76import org.springframework.http.HttpStatus;
     
    2019    @PutMapping("/createCoupon")
    2120    public ResponseEntity<Coupon> updateCoupon(@RequestBody Coupon couponItem) {
    22         System.out.println(couponItem);
    2321        if (couponItem.getTitle() == null || couponItem.getCode() == null) {
    2422            return ResponseEntity.badRequest().build();
     
    5351        coupon.setCode(newCouponData.getCode());
    5452        coupon.setDescription(newCouponData.getDescription());
    55         couponService.save(coupon); // Save the updated coupon
     53        couponService.save(coupon);
    5654
    5755        return ResponseEntity.ok().build();
    5856    }
     57
     58
     59    @GetMapping("/getCouponNames")
     60    public ResponseEntity<List<String>> getCouponNames() {
     61        List<String> couponNames = couponService.getCouponNames();
     62        return ResponseEntity.ok(couponNames);
     63    }
    5964}
Note: See TracChangeset for help on using the changeset viewer.