| | |
| | | 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.mes.controller.admin.tm.tool.vo.type.MesTmToolTypeImportExcelVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.type.MesTmToolTypeImportRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.type.MesTmToolTypePageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.type.MesTmToolTypeRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.tm.tool.vo.type.MesTmToolTypeSaveReqVO; |
| | |
| | | import cn.iocoder.yudao.module.mes.service.tm.tool.MesTmToolTypeService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.Parameters; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得工具类型") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:tm-tool-type:query')") |
| | | public CommonResult<MesTmToolTypeRespVO> getToolType(@RequestParam("id") Long id) { |
| | | MesTmToolTypeDO toolType = toolTypeService.getToolType(id); |
| | | return success(BeanUtils.toBean(toolType, MesTmToolTypeRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得工具类型分页") |
| | | @PreAuthorize("@ss.hasPermission('mes:tm-tool-type:query')") |
| | | public CommonResult<PageResult<MesTmToolTypeRespVO>> getToolTypePage(@Valid MesTmToolTypePageReqVO pageReqVO) { |
| | | PageResult<MesTmToolTypeDO> pageResult = toolTypeService.getToolTypePage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, MesTmToolTypeRespVO.class)); |
| | |
| | | BeanUtils.toBean(list, MesTmToolTypeRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得工具类型导入模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MesTmToolTypeImportExcelVO> list = Collections.singletonList( |
| | | MesTmToolTypeImportExcelVO.builder() |
| | | .code("TT-001").name("示例工具类型").codeFlag(false) |
| | | .maintenType(1).maintenPeriod(30).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "工具类型导入模板.xls", "工具类型列表", MesTmToolTypeImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入工具类型") |
| | | @Parameters({ |
| | | @Parameter(name = "file", description = "Excel 文件", required = true), |
| | | @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true") |
| | | }) |
| | | @PreAuthorize("@ss.hasPermission('mes:tm-tool-type:import')") |
| | | public CommonResult<MesTmToolTypeImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, |
| | | defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MesTmToolTypeImportExcelVO> list = ExcelUtils.read(file, MesTmToolTypeImportExcelVO.class); |
| | | return success(toolTypeService.importToolTypeList(list, updateSupport)); |
| | | } |
| | | |
| | | } |