package com.tcm.training.admin.live.controller; import com.tcm.training.admin.common.ApiResponse; import com.tcm.training.admin.common.PageResponse; import com.tcm.training.admin.live.dto.LiveCourseCategorySaveRequest; import com.tcm.training.admin.live.service.LiveCourseCategoryAppService; import com.tcm.training.admin.live.vo.LiveCourseCategoryDetailVO; import com.tcm.training.admin.live.vo.LiveCourseCategoryItemVO; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; @Validated @RestController @RequestMapping({"/api/v1", "/api"}) public class LiveCourseCategoryController { private final LiveCourseCategoryAppService liveCourseCategoryAppService; public LiveCourseCategoryController(LiveCourseCategoryAppService liveCourseCategoryAppService) { this.liveCourseCategoryAppService = liveCourseCategoryAppService; } @GetMapping("/live-course-categories") public ApiResponse> page(@RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "10") int pageSize, @RequestParam String type) { return ApiResponse.ok(liveCourseCategoryAppService.page(page, pageSize, type)); } @GetMapping("/live-course-categories/{id}") public ApiResponse detail(@PathVariable("id") Long id) { return ApiResponse.ok(liveCourseCategoryAppService.detail(id)); } @PostMapping("/live-course-categories") public ApiResponse create(@RequestParam String type, @Valid @RequestBody LiveCourseCategorySaveRequest req) { return ApiResponse.ok(liveCourseCategoryAppService.create(type, req)); } @PutMapping("/live-course-categories/{id}") public ApiResponse update(@PathVariable("id") Long id, @Valid @RequestBody LiveCourseCategorySaveRequest req) { return ApiResponse.ok(liveCourseCategoryAppService.update(id, req)); } @DeleteMapping("/live-course-categories/{id}") public ApiResponse delete(@PathVariable("id") Long id) { liveCourseCategoryAppService.delete(id); return ApiResponse.ok(null); } }