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.ProjectIntroductionSaveRequest; import com.tcm.training.admin.live.service.ProjectIntroductionAppService; import com.tcm.training.admin.live.vo.ProjectIntroductionDetailVO; import com.tcm.training.admin.live.vo.ProjectIntroductionListItemVO; 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 ProjectIntroductionController { private final ProjectIntroductionAppService projectIntroductionAppService; public ProjectIntroductionController(ProjectIntroductionAppService projectIntroductionAppService) { this.projectIntroductionAppService = projectIntroductionAppService; } @GetMapping("/project-introductions") public ApiResponse> page(@RequestParam(required = false, defaultValue = "1") int page, @RequestParam(required = false, defaultValue = "10") int pageSize, @RequestParam(required = false) String keyword, @RequestParam(required = false) String category, @RequestParam(required = false) Integer contentType, @RequestParam(required = false) Integer status) { return ApiResponse.ok(projectIntroductionAppService.page(page, pageSize, keyword, category, contentType, status)); } @GetMapping("/project-introductions/{id}") public ApiResponse detail(@PathVariable("id") Long id) { return ApiResponse.ok(projectIntroductionAppService.detail(id)); } @PostMapping("/project-introductions") public ApiResponse create(@Valid @RequestBody ProjectIntroductionSaveRequest req) { return ApiResponse.ok(projectIntroductionAppService.create(req)); } @PutMapping("/project-introductions/{id}") public ApiResponse update(@PathVariable("id") Long id, @Valid @RequestBody ProjectIntroductionSaveRequest req) { return ApiResponse.ok(projectIntroductionAppService.update(id, req)); } @DeleteMapping("/project-introductions/{id}") public ApiResponse delete(@PathVariable("id") Long id) { projectIntroductionAppService.delete(id); return ApiResponse.ok(null); } }