| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelImportUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | import com.ruoyi.system.query.AssetAdQuery; |
| | | import com.ruoyi.system.service.AssetAdRentalRecordService; |
| | | import com.ruoyi.system.service.AssetAdService; |
| | | import com.ruoyi.system.utils.FastExcelUtil; |
| | | import com.ruoyi.system.vo.asset.AssetAdDetailVO; |
| | | import com.ruoyi.system.vo.asset.AssetAdVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.util.Collections; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public R<AssetAdDetailVO> getDetail(@ApiParam(name = "id", value = "广告无形资产ID") @PathVariable Integer id) { |
| | | return R.ok(assetAdService.getDetail(id)); |
| | | } |
| | | |
| | | @ApiOperation("下载导入模板") |
| | | @GetMapping("/template") |
| | | public void getTemplate(HttpServletResponse response){ |
| | | FastExcelUtil.exportData(response, "广告无形资产导入模板", "广告无形资产", AssetAdDTO.class, Collections.emptyList()); |
| | | } |
| | | |
| | | @ApiOperation("导入") |
| | | @Log(title = "导入广告无形资产", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/import") |
| | | public R<?> importAssetAd(@RequestPart("file") MultipartFile file){ |
| | | //TODO 待完成 |
| | | return R.ok(); |
| | | if (file.isEmpty()) { |
| | | return R.fail("请选择一个文件上传!"); |
| | | } |
| | | try { |
| | | //List<AssetAdDTO> list = FastExcelUtil.readMultipartFile(file.getInputStream(), AssetAdDTO.class); |
| | | //assetAdService.importAssetAd(list); |
| | | ExcelImportUtil.importExcel(file.getInputStream(), AssetAdDTO.class, null); |
| | | return R.ok(); |
| | | } catch (IOException e) { |
| | | log.error("文件处理失败", e); |
| | | return R.fail("文件处理失败!"); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("删除") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @DeleteMapping("/{id}") |