| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.dto.asset.AssetAdMaterialSporadicSettlementDTO; |
| | | import com.ruoyi.system.dto.asset.AssetAdMaterialSporadicSettlementImportDTO; |
| | | import com.ruoyi.system.export.AssetAdMaterialSporadicSettlementImport; |
| | | import com.ruoyi.system.query.AssetAdMaterialSporadicSettlementQuery; |
| | | import com.ruoyi.system.service.AssetAdMaterialSporadicSettlementService; |
| | | import com.ruoyi.system.vo.asset.AssetAdMaterialSporadicSettlementDetailVO; |
| | | import com.ruoyi.system.vo.asset.AssetAdMaterialSporadicSettlementVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RequestPart; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author mitao |
| | | * @since 2025-10-17 |
| | | */ |
| | | @Slf4j |
| | | @Validated |
| | | @Api(tags = {"广告物料零星结算相关接口"}) |
| | | @RestController |
| | | @RequestMapping("/asset-ad-material-sporadic-settlement") |
| | | @RequiredArgsConstructor(onConstructor_ = {@Lazy}) |
| | | public class AssetAdMaterialSporadicSettlementController { |
| | | |
| | | private final AssetAdMaterialSporadicSettlementService assetAdMaterialSporadicSettlementService; |
| | | |
| | | @ApiOperation("下载导入模板") |
| | | @GetMapping("/template") |
| | | public void downloadTemplate(HttpServletResponse response) { |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), AssetAdMaterialSporadicSettlementImport.class, |
| | | Lists.newArrayList(new AssetAdMaterialSporadicSettlementImport())); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("广告物料零星结算导入模板.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setHeader("content-Type", "application/vnd.ms-excel"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | log.error("房屋巡检导入模板下载失败!", e); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("导入零星资产结算数据") |
| | | @PostMapping("/import") |
| | | public R<?> importData(@RequestPart("file") MultipartFile file, @Valid AssetAdMaterialSporadicSettlementImportDTO dto) { |
| | | assetAdMaterialSporadicSettlementService.importData(file, dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("分页列表") |
| | | @PostMapping("/page") |
| | | public R<IPage<AssetAdMaterialSporadicSettlementVO>> getPageList(@RequestBody AssetAdMaterialSporadicSettlementQuery query){ |
| | | return R.ok(assetAdMaterialSporadicSettlementService.getPageList(query)); |
| | | } |
| | | |
| | | @ApiOperation("新增") |
| | | @PostMapping("/add") |
| | | public R<Boolean> add(@Valid @RequestBody AssetAdMaterialSporadicSettlementDTO dto){ |
| | | return R.ok(assetAdMaterialSporadicSettlementService.add(dto)); |
| | | } |
| | | |
| | | @ApiOperation("编辑") |
| | | @PostMapping("/edit") |
| | | public R<?> edit(@Valid @RequestBody AssetAdMaterialSporadicSettlementDTO dto){ |
| | | assetAdMaterialSporadicSettlementService.edit(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("删除") |
| | | @DeleteMapping("/{id}") |
| | | public R<?> deleteById(@ApiParam(name = "id", value = "主键") @PathVariable Integer id) { |
| | | assetAdMaterialSporadicSettlementService.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("详情") |
| | | @GetMapping("/detail/{id}") |
| | | public R<AssetAdMaterialSporadicSettlementDetailVO> getDetail(@ApiParam(name = "id", value = "主键") @PathVariable Integer id) { |
| | | return R.ok(assetAdMaterialSporadicSettlementService.getDetail(id)); |
| | | } |
| | | } |