hejianhao
2026-09-01 587391ed908f11c8f8f735575bc1425346d05bb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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("content:project-intro: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("content:project-intro:view")
    public ApiResponse<ProjectIntroductionDetailVO> detail(@PathVariable("id") Long id) {
        return ApiResponse.ok(projectIntroductionAppService.detail(id));
    }
 
    @PostMapping("/project-introductions")
    @SaCheckPermission("content:project-intro:add")
    public ApiResponse<ProjectIntroductionDetailVO> create(@Valid @RequestBody ProjectIntroductionSaveRequest req) {
        return ApiResponse.ok(projectIntroductionAppService.create(req));
    }
 
    @PutMapping("/project-introductions/{id}")
    @SaCheckPermission("content:project-intro: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("content:project-intro:delete")
    public ApiResponse<Void> delete(@PathVariable("id") Long id) {
        projectIntroductionAppService.delete(id);
        return ApiResponse.ok(null);
    }
}