提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.controller.admin.dict; |
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.pojo.PageParam; |
|
6 |
import com.iailab.framework.common.pojo.PageResult; |
|
7 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
8 |
import com.iailab.framework.excel.core.util.ExcelUtils; |
|
9 |
import com.iailab.module.system.controller.admin.dict.vo.type.DictTypePageReqVO; |
|
10 |
import com.iailab.module.system.controller.admin.dict.vo.type.DictTypeRespVO; |
|
11 |
import com.iailab.module.system.controller.admin.dict.vo.type.DictTypeSaveReqVO; |
|
12 |
import com.iailab.module.system.controller.admin.dict.vo.type.DictTypeSimpleRespVO; |
|
13 |
import com.iailab.module.system.dal.dataobject.dict.DictTypeDO; |
|
14 |
import com.iailab.module.system.service.dict.DictTypeService; |
|
15 |
import io.swagger.v3.oas.annotations.Operation; |
|
16 |
import io.swagger.v3.oas.annotations.Parameter; |
|
17 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
18 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
19 |
import org.springframework.validation.annotation.Validated; |
|
20 |
import org.springframework.web.bind.annotation.*; |
|
21 |
|
|
22 |
import javax.annotation.Resource; |
|
23 |
import javax.servlet.http.HttpServletResponse; |
|
24 |
import javax.validation.Valid; |
|
25 |
import java.io.IOException; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
|
29 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
30 |
|
|
31 |
@Tag(name = "管理后台 - 字典类型") |
|
32 |
@RestController |
|
33 |
@RequestMapping("/system/dict-type") |
|
34 |
@Validated |
|
35 |
public class DictTypeController { |
|
36 |
|
|
37 |
@Resource |
|
38 |
private DictTypeService dictTypeService; |
|
39 |
|
|
40 |
@PostMapping("/create") |
|
41 |
@Operation(summary = "创建字典类型") |
|
42 |
@PreAuthorize("@ss.hasPermission('system:dict:create')") |
|
43 |
public CommonResult<Long> createDictType(@Valid @RequestBody DictTypeSaveReqVO createReqVO) { |
|
44 |
Long dictTypeId = dictTypeService.createDictType(createReqVO); |
|
45 |
return success(dictTypeId); |
|
46 |
} |
|
47 |
|
|
48 |
@PutMapping("/update") |
|
49 |
@Operation(summary = "修改字典类型") |
|
50 |
@PreAuthorize("@ss.hasPermission('system:dict:update')") |
|
51 |
public CommonResult<Boolean> updateDictType(@Valid @RequestBody DictTypeSaveReqVO updateReqVO) { |
|
52 |
dictTypeService.updateDictType(updateReqVO); |
|
53 |
return success(true); |
|
54 |
} |
|
55 |
|
|
56 |
@DeleteMapping("/delete") |
|
57 |
@Operation(summary = "删除字典类型") |
|
58 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
59 |
@PreAuthorize("@ss.hasPermission('system:dict:delete')") |
|
60 |
public CommonResult<Boolean> deleteDictType(Long id) { |
|
61 |
dictTypeService.deleteDictType(id); |
|
62 |
return success(true); |
|
63 |
} |
|
64 |
|
|
65 |
@GetMapping("/page") |
|
66 |
@Operation(summary = "获得字典类型的分页列表") |
|
67 |
@PreAuthorize("@ss.hasPermission('system:dict:query')") |
|
68 |
public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) { |
|
69 |
PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO); |
|
70 |
return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class)); |
|
71 |
} |
|
72 |
|
|
73 |
@Operation(summary = "/查询字典类型详细") |
|
74 |
@Parameter(name = "id", description = "编号", required = true, example = "1024") |
|
75 |
@GetMapping(value = "/get") |
|
76 |
@PreAuthorize("@ss.hasPermission('system:dict:query')") |
|
77 |
public CommonResult<DictTypeRespVO> getDictType(@RequestParam("id") Long id) { |
|
78 |
DictTypeDO dictType = dictTypeService.getDictType(id); |
|
79 |
return success(BeanUtils.toBean(dictType, DictTypeRespVO.class)); |
|
80 |
} |
|
81 |
|
|
82 |
@GetMapping(value = {"/list-all-simple", "simple-list"}) |
|
83 |
@Operation(summary = "获得全部字典类型列表", description = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项") |
|
84 |
// 无需添加权限认证,因为前端全局都需要 |
|
85 |
public CommonResult<List<DictTypeSimpleRespVO>> getSimpleDictTypeList() { |
|
86 |
List<DictTypeDO> list = dictTypeService.getDictTypeList(); |
|
87 |
return success(BeanUtils.toBean(list, DictTypeSimpleRespVO.class)); |
|
88 |
} |
|
89 |
|
|
90 |
@Operation(summary = "导出数据类型") |
|
91 |
@GetMapping("/export") |
|
92 |
@PreAuthorize("@ss.hasPermission('system:dict:query')") |
|
93 |
@ApiAccessLog(operateType = EXPORT) |
|
94 |
public void export(HttpServletResponse response, @Valid DictTypePageReqVO exportReqVO) throws IOException { |
|
95 |
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
|
96 |
List<DictTypeDO> list = dictTypeService.getDictTypePage(exportReqVO).getList(); |
|
97 |
// 导出 |
|
98 |
ExcelUtils.write(response, "字典类型.xls", "数据", DictTypeRespVO.class, |
|
99 |
BeanUtils.toBean(list, DictTypeRespVO.class)); |
|
100 |
} |
|
101 |
|
|
102 |
} |