潘志宝
2024-09-30 303715d81f0c1cd8b32cd659b7734c01565369a6
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.iailab.module.model.mpk.controller.admin;
 
import com.iailab.framework.common.page.PageData;
import com.iailab.framework.common.pojo.CommonResult;
import com.iailab.module.model.mpk.dto.MpkFileDTO;
import com.iailab.module.model.mpk.dto.ProjectDTO;
import com.iailab.module.model.mpk.dto.ProjectPackageHistoryModelDTO;
import com.iailab.module.model.mpk.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import static com.iailab.framework.common.pojo.CommonResult.success;
 
 
/**
 * @description:
 * @author: dzd
 * @date: 2024/8/22 14:40
 **/
@RestController
@RequestMapping("/model/mpk/project")
public class ProjectController {
    @Autowired
    private ProjectService projectService;
 
    @PreAuthorize("@ss.hasPermission('mpk:project:query')")
    @GetMapping("page")
    public CommonResult<PageData<ProjectDTO>> page(@RequestParam Map<String, Object> params){
        PageData<ProjectDTO> page = projectService.page(params);
 
        return success(page);
    }
 
    @PreAuthorize("@ss.hasPermission('mpk:project:query')")
    @GetMapping("list")
    public CommonResult<List<ProjectDTO>> list() {
        List<ProjectDTO> list = projectService.list(new HashMap<>());
 
        return success(list);
    }
 
    @PreAuthorize("@ss.hasPermission('mpk:project:query')")
    @GetMapping("{id}")
    public CommonResult<ProjectDTO> get(@PathVariable("id") String id){
        ProjectDTO data = projectService.get(id);
 
        return success(data);
    }
 
    @PreAuthorize("@ss.hasPermission('mpk:project:create')")
    @PostMapping
    public CommonResult<Boolean> save(@RequestBody ProjectDTO dto){
        projectService.save(dto);
 
        return CommonResult.success(true);
    }
 
    @PreAuthorize("@ss.hasPermission('mpk:project:update')")
    @PutMapping
    public CommonResult<Boolean> update(@RequestBody ProjectDTO dto){
        dto.setUpdateTime(new Date());
        projectService.update(dto);
 
        return CommonResult.success(true);
    }
 
    @PreAuthorize("@ss.hasPermission('mpk:project:delete')")
    @DeleteMapping
    public CommonResult<Boolean> delete(String id){
 
        projectService.delete(id);
 
        return CommonResult.success(true);
    }
 
    @GetMapping("getProjectModel")
    public CommonResult<PageData<MpkFileDTO>> getProjectModel(@RequestParam Map<String, Object> params){
        PageData<MpkFileDTO> page = projectService.getProjectModel(params);
 
        return CommonResult.success(page);
    }
 
}