提交 | 用户 | 时间
|
8b3ee3
|
1 |
package com.iailab.module.model.mpk.controller.admin; |
潘 |
2 |
|
5e4cb9
|
3 |
import com.iailab.framework.common.dto.TreeLabelDTO; |
8b3ee3
|
4 |
import com.iailab.framework.common.pojo.CommonResult; |
0a2f6f
|
5 |
import com.iailab.framework.common.util.object.ConvertUtils; |
8b3ee3
|
6 |
import com.iailab.module.model.mpk.dto.FileMenuDTO; |
潘 |
7 |
import com.iailab.module.model.mpk.entity.FileMenuEntity; |
|
8 |
import com.iailab.module.model.mpk.service.FileMenuService; |
|
9 |
import io.swagger.v3.oas.annotations.Operation; |
|
10 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
import org.springframework.web.bind.annotation.*; |
|
13 |
|
|
14 |
import javax.validation.Valid; |
5e4cb9
|
15 |
import java.util.ArrayList; |
8b3ee3
|
16 |
import java.util.List; |
潘 |
17 |
|
|
18 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author PanZhibao |
|
22 |
* @Description |
|
23 |
* @createTime 2024年09月22日 |
|
24 |
*/ |
|
25 |
@Tag(name = "模型服务 - 模型文件菜单管理") |
|
26 |
@RestController |
|
27 |
@RequestMapping("/model/mpk/menu") |
|
28 |
public class FileMenuController { |
|
29 |
|
|
30 |
@Autowired |
|
31 |
private FileMenuService fileMenuService; |
|
32 |
|
|
33 |
@GetMapping("/list") |
|
34 |
@Operation(summary = "获得列表") |
|
35 |
public CommonResult<List<FileMenuDTO>> list() { |
|
36 |
List<FileMenuDTO> list = fileMenuService.list(); |
|
37 |
return success(list); |
|
38 |
} |
|
39 |
|
0a2f6f
|
40 |
@GetMapping("/get") |
潘 |
41 |
@Operation(summary = "获取详情") |
|
42 |
public CommonResult<FileMenuDTO> get(@RequestParam("id") String id) { |
|
43 |
FileMenuEntity data = fileMenuService.get(id); |
|
44 |
return success(ConvertUtils.sourceToTarget(data, FileMenuDTO.class)); |
|
45 |
} |
|
46 |
|
5e4cb9
|
47 |
@GetMapping("/tree") |
潘 |
48 |
public CommonResult<List<TreeLabelDTO>> tree() { |
|
49 |
List<TreeLabelDTO> data = new ArrayList<>(); |
|
50 |
List<FileMenuDTO> list = fileMenuService.list(); |
|
51 |
list.forEach(menu -> { |
|
52 |
TreeLabelDTO tree0 = new TreeLabelDTO(); |
d8db4b
|
53 |
tree0.setValue(menu.getName()); |
5e4cb9
|
54 |
tree0.setLabel(menu.getName()); |
潘 |
55 |
List<TreeLabelDTO> groups = new ArrayList<>(); |
|
56 |
menu.getGroups().forEach(group -> { |
|
57 |
TreeLabelDTO tree1 = new TreeLabelDTO(); |
d8db4b
|
58 |
tree1.setValue(group.getName()); |
5e4cb9
|
59 |
tree1.setLabel(group.getName()); |
潘 |
60 |
groups.add(tree1); |
|
61 |
}); |
|
62 |
tree0.setChildren(groups); |
|
63 |
data.add(tree0); |
|
64 |
}); |
|
65 |
return success(ConvertUtils.sourceToTarget(data, TreeLabelDTO.class)); |
|
66 |
} |
|
67 |
|
8b3ee3
|
68 |
@PostMapping("/create") |
潘 |
69 |
public CommonResult<Boolean> create(@Valid @RequestBody FileMenuEntity entity) { |
|
70 |
fileMenuService.create(entity); |
|
71 |
return success(true); |
|
72 |
} |
|
73 |
|
534bf2
|
74 |
@PutMapping("/update") |
8b3ee3
|
75 |
public CommonResult<Boolean> update(@Valid @RequestBody FileMenuEntity entity) { |
潘 |
76 |
fileMenuService.update(entity); |
|
77 |
return success(true); |
|
78 |
} |
|
79 |
|
|
80 |
@DeleteMapping("/delete") |
|
81 |
public CommonResult<Boolean> delete(@RequestParam("id") String id) { |
|
82 |
fileMenuService.deleteById(id); |
|
83 |
return success(true); |
|
84 |
} |
|
85 |
} |