init
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.dken.giftCodeService.controller;
|
||||
|
||||
import com.dken.giftCodeService.dto.request.GiftCodeCreateRequest;
|
||||
import com.dken.giftCodeService.dto.request.UserApplyGiftCodeRequest;
|
||||
import com.dken.giftCodeService.dto.response.GiftCodeResponse;
|
||||
import com.dken.giftCodeService.dto.response.UserApplyGiftCodeResponse;
|
||||
import com.dken.giftCodeService.service.GiftCodeService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/gift-codes")
|
||||
public class GiftCodeController {
|
||||
|
||||
@Autowired
|
||||
private GiftCodeService giftCodeService;
|
||||
|
||||
@PostMapping
|
||||
public GiftCodeResponse create(@Valid @RequestBody GiftCodeCreateRequest req) {
|
||||
return giftCodeService.createGiftCode(req);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Page<GiftCodeResponse> getAllGiftCodes(@RequestParam(defaultValue = "0") @Min(0) int page,
|
||||
@RequestParam(defaultValue = "10") @Min(1) @Max(100) int size) {
|
||||
return giftCodeService.getAllGiftCodes(page, size);
|
||||
}
|
||||
|
||||
@GetMapping("/{code}")
|
||||
public GiftCodeResponse getGiftCodeByCode(@PathVariable String code) {
|
||||
return giftCodeService.getGiftCodeByCode(code);
|
||||
}
|
||||
|
||||
@PostMapping("/apply")
|
||||
public UserApplyGiftCodeResponse applyGiftCode(@Valid @RequestBody UserApplyGiftCodeRequest req) {
|
||||
return giftCodeService.applyGiftCode(req.getGiftCode(), req.getUserId());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user