package com.tcm.training.admin.live.controller;
|
|
import com.tcm.training.admin.common.ApiResponse;
|
import com.tcm.training.admin.common.PageResponse;
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
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")
|
@SaCheckPermission("live:project-introduction:view")
|
public ApiResponse<PageResponse<ProjectIntroductionListItemVO>> 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}")
|
@SaCheckPermission("live:project-introduction:view")
|
public ApiResponse<ProjectIntroductionDetailVO> detail(@PathVariable("id") Long id) {
|
return ApiResponse.ok(projectIntroductionAppService.detail(id));
|
}
|
|
@PostMapping("/project-introductions")
|
@SaCheckPermission("live:project-introduction:add")
|
public ApiResponse<ProjectIntroductionDetailVO> create(@Valid @RequestBody ProjectIntroductionSaveRequest req) {
|
return ApiResponse.ok(projectIntroductionAppService.create(req));
|
}
|
|
@PutMapping("/project-introductions/{id}")
|
@SaCheckPermission("live:project-introduction:edit")
|
public ApiResponse<ProjectIntroductionDetailVO> update(@PathVariable("id") Long id,
|
@Valid @RequestBody ProjectIntroductionSaveRequest req) {
|
return ApiResponse.ok(projectIntroductionAppService.update(id, req));
|
}
|
|
@DeleteMapping("/project-introductions/{id}")
|
@SaCheckPermission("live:project-introduction:delete")
|
public ApiResponse<Void> delete(@PathVariable("id") Long id) {
|
projectIntroductionAppService.delete(id);
|
return ApiResponse.ok(null);
|
}
|
}
|