| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeImportExcelVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeImportReqVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeImportRespVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypePageReqVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeRespVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.dict.vo.type.DictTypeSaveReqVO; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得字典类型的分页列表") |
| | | @PreAuthorize("@ss.hasPermission('system:dict:query')") |
| | | public CommonResult<PageResult<DictTypeRespVO>> pageDictTypes(@Valid DictTypePageReqVO pageReqVO) { |
| | | PageResult<DictTypeDO> pageResult = dictTypeService.getDictTypePage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, DictTypeRespVO.class)); |
| | |
| | | @Operation(summary = "/查询字典类型详细") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @GetMapping(value = "/get") |
| | | @PreAuthorize("@ss.hasPermission('system:dict:query')") |
| | | public CommonResult<DictTypeRespVO> getDictType(@RequestParam("id") Long id) { |
| | | DictTypeDO dictType = dictTypeService.getDictType(id); |
| | | return success(BeanUtils.toBean(dictType, DictTypeRespVO.class)); |
| | |
| | | |
| | | @Operation(summary = "导出数据类型") |
| | | @GetMapping("/export-excel") |
| | | @PreAuthorize("@ss.hasPermission('system:dict:query')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void export(HttpServletResponse response, @Valid DictTypePageReqVO exportReqVO) throws IOException { |
| | | exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| | |
| | | BeanUtils.toBean(list, DictTypeRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入字典类型模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<DictTypeImportExcelVO> list = Arrays.asList( |
| | | DictTypeImportExcelVO.builder().name("示例字典").type("demo_dict_type") |
| | | .status(0).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "字典类型导入模板.xls", "字典类型列表", DictTypeImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入字典类型") |
| | | @PreAuthorize("@ss.hasPermission('system:dict:import')") |
| | | public CommonResult<DictTypeImportRespVO> importExcel(@Valid DictTypeImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<DictTypeImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), DictTypeImportExcelVO.class); |
| | | return success(dictTypeService.importDictTypeList(list, importReqVO)); |
| | | } |
| | | |
| | | } |