MaterialFolderController.java
5.82 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package com.bs.reception.controller.materials;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.reception.entity.materials.MaterialFolder;
import com.bs.reception.model.materials.MaterialFolderNodeVO;
import com.bs.reception.model.materials.MaterialFolderPageQuery;
import com.bs.reception.model.materials.MaterialFolderSortRequest;
import com.bs.reception.service.IMaterialFolderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@RestController
@Tag(name = "素材文件夹管理", description = "素材文件夹接口")
@RequestMapping("/materials/folders")
public class MaterialFolderController {
@Resource
private IMaterialFolderService folderService;
@PostMapping("/list")
@Operation(summary = "文件夹列表")
public AjaxResult list(@RequestBody MaterialFolder body) {
try {
List<MaterialFolder> list = folderService.getFolderList(body);
return AjaxResult.success(list);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/page")
@Operation(summary = "文件夹分页查询")
public AjaxResult page(@RequestBody MaterialFolderPageQuery query) {
try {
TableDataInfo<List<MaterialFolder>> page = folderService.pageFolders(query);
return AjaxResult.success(page);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/create")
@Operation(summary = "创建文件夹")
public AjaxResult create(@RequestBody MaterialFolder body) {
try {
MaterialFolder data = folderService.createFolder(body);
return AjaxResult.success(data);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/update")
@Operation(summary = "更新文件夹")
public AjaxResult update(@RequestBody MaterialFolder body) {
try {
boolean ok = folderService.updateFolder(body);
return AjaxResult.success(ok);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/status")
@Operation(summary = "设置状态")
public AjaxResult setStatus(@RequestBody MaterialFolder body) {
try {
boolean ok = folderService.setFolderStatus(body);
return AjaxResult.success(ok);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/sort")
@Operation(summary = "设置排序")
public AjaxResult setSort(@RequestBody MaterialFolder body) {
try {
boolean ok = folderService.setFolderSort(body);
return AjaxResult.success(ok);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/sort/list")
@Operation(summary = "文件夹列表排序")
public AjaxResult sortList(@RequestBody MaterialFolderSortRequest body) {
try {
if (body.getIds() == null || body.getIds().isEmpty()) {
return AjaxResult.error("ID列表不能为空");
}
if (body.getTypeCode() == null || body.getTypeCode().isBlank()) {
return AjaxResult.error("业务类型编码不能为空");
}
boolean ok = folderService.sort(body.getTypeCode(), body.getIds());
return AjaxResult.success(ok);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/delete")
@Operation(summary = "删除文件夹")
public AjaxResult delete(@RequestBody MaterialFolder body) {
try {
boolean ok = folderService.deleteFolder(body);
return AjaxResult.success(ok);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/detail")
@Operation(summary = "文件夹详情")
public AjaxResult detail(@RequestBody MaterialFolder body) {
try {
MaterialFolder ok = folderService.getFolderDetail(body);
return AjaxResult.success(ok);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
@PostMapping("/tree/list")
@Operation(summary = "文件夹树列表")
public AjaxResult folderTree(@RequestBody MaterialFolder body) {
// 查询文件夹树(扁平列表)
try {
List<MaterialFolderNodeVO> list = folderService.listFolderTree();
return AjaxResult.success(list);
} catch (Exception e) {
log.error("操作失败:{}", e.getMessage(), e);
return AjaxResult.error("操作失败:"+e.getMessage());
}
}
}