提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.infra.controller.admin.demo.demo02; |
H |
2 |
|
|
3 |
import com.iailab.framework.apilog.core.annotation.ApiAccessLog; |
|
4 |
import com.iailab.framework.common.pojo.CommonResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
6 |
import com.iailab.framework.excel.core.util.ExcelUtils; |
|
7 |
import com.iailab.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO; |
|
8 |
import com.iailab.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryRespVO; |
|
9 |
import com.iailab.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO; |
|
10 |
import com.iailab.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO; |
|
11 |
import com.iailab.module.infra.service.demo.demo02.Demo02CategoryService; |
|
12 |
import io.swagger.v3.oas.annotations.Operation; |
|
13 |
import io.swagger.v3.oas.annotations.Parameter; |
|
14 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
15 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
16 |
import org.springframework.validation.annotation.Validated; |
|
17 |
import org.springframework.web.bind.annotation.*; |
|
18 |
|
|
19 |
import javax.annotation.Resource; |
|
20 |
import javax.servlet.http.HttpServletResponse; |
|
21 |
import javax.validation.Valid; |
|
22 |
import java.io.IOException; |
|
23 |
import java.util.List; |
|
24 |
|
|
25 |
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
|
26 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
27 |
|
|
28 |
@Tag(name = "管理后台 - 示例分类") |
|
29 |
@RestController |
|
30 |
@RequestMapping("/infra/demo02-category") |
|
31 |
@Validated |
|
32 |
public class Demo02CategoryController { |
|
33 |
|
|
34 |
@Resource |
|
35 |
private Demo02CategoryService demo02CategoryService; |
|
36 |
|
|
37 |
@PostMapping("/create") |
|
38 |
@Operation(summary = "创建示例分类") |
|
39 |
@PreAuthorize("@ss.hasPermission('infra:demo02-category:create')") |
|
40 |
public CommonResult<Long> createDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO createReqVO) { |
|
41 |
return success(demo02CategoryService.createDemo02Category(createReqVO)); |
|
42 |
} |
|
43 |
|
|
44 |
@PutMapping("/update") |
|
45 |
@Operation(summary = "更新示例分类") |
|
46 |
@PreAuthorize("@ss.hasPermission('infra:demo02-category:update')") |
|
47 |
public CommonResult<Boolean> updateDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO updateReqVO) { |
|
48 |
demo02CategoryService.updateDemo02Category(updateReqVO); |
|
49 |
return success(true); |
|
50 |
} |
|
51 |
|
|
52 |
@DeleteMapping("/delete") |
|
53 |
@Operation(summary = "删除示例分类") |
|
54 |
@Parameter(name = "id", description = "编号", required = true) |
|
55 |
@PreAuthorize("@ss.hasPermission('infra:demo02-category:delete')") |
|
56 |
public CommonResult<Boolean> deleteDemo02Category(@RequestParam("id") Long id) { |
|
57 |
demo02CategoryService.deleteDemo02Category(id); |
|
58 |
return success(true); |
|
59 |
} |
|
60 |
|
|
61 |
@GetMapping("/get") |
|
62 |
@Operation(summary = "获得示例分类") |
|
63 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
64 |
@PreAuthorize("@ss.hasPermission('infra:demo02-category:query')") |
|
65 |
public CommonResult<Demo02CategoryRespVO> getDemo02Category(@RequestParam("id") Long id) { |
|
66 |
Demo02CategoryDO demo02Category = demo02CategoryService.getDemo02Category(id); |
|
67 |
return success(BeanUtils.toBean(demo02Category, Demo02CategoryRespVO.class)); |
|
68 |
} |
|
69 |
|
|
70 |
@GetMapping("/list") |
|
71 |
@Operation(summary = "获得示例分类列表") |
|
72 |
@PreAuthorize("@ss.hasPermission('infra:demo02-category:query')") |
|
73 |
public CommonResult<List<Demo02CategoryRespVO>> getDemo02CategoryList(@Valid Demo02CategoryListReqVO listReqVO) { |
|
74 |
List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO); |
|
75 |
return success(BeanUtils.toBean(list, Demo02CategoryRespVO.class)); |
|
76 |
} |
|
77 |
|
|
78 |
@GetMapping("/export-excel") |
|
79 |
@Operation(summary = "导出示例分类 Excel") |
|
80 |
@PreAuthorize("@ss.hasPermission('infra:demo02-category:export')") |
|
81 |
@ApiAccessLog(operateType = EXPORT) |
|
82 |
public void exportDemo02CategoryExcel(@Valid Demo02CategoryListReqVO listReqVO, |
|
83 |
HttpServletResponse response) throws IOException { |
|
84 |
List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO); |
|
85 |
// 导出 Excel |
|
86 |
ExcelUtils.write(response, "示例分类.xls", "数据", Demo02CategoryRespVO.class, |
|
87 |
BeanUtils.toBean(list, Demo02CategoryRespVO.class)); |
|
88 |
} |
|
89 |
|
|
90 |
} |