| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.system.dto.asset.AssetAdMaterialPriceDTO; |
| | | import com.ruoyi.system.query.AssetAdMaterialPriceQuery; |
| | | import com.ruoyi.system.service.AssetAdMaterialPriceService; |
| | | import com.ruoyi.system.utils.FastExcelUtil; |
| | | import com.ruoyi.system.vo.asset.AssetAdMaterialPriceVO; |
| | | 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.springframework.context.annotation.Lazy; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | 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.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author WuGuanFengYue |
| | | * @since 2025-09-15 |
| | | */ |
| | | @Api(tags = {"广告物料单价相关接口"}) |
| | | @Slf4j |
| | | @Validated |
| | | @RestController |
| | | @RequestMapping("/asset-ad-material-price") |
| | | @RequiredArgsConstructor(onConstructor_ = {@Lazy}) |
| | | public class AssetAdMaterialPriceController { |
| | | |
| | | private final AssetAdMaterialPriceService assetAdMaterialPriceService; |
| | | |
| | | @ApiOperation(value = "新增广告物料单价") |
| | | @Log(title = "新增广告物料单价", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public R<?> addAssetAdMaterialPrice(@Valid @RequestBody AssetAdMaterialPriceDTO dto) { |
| | | assetAdMaterialPriceService.addAssetAdMaterialPrice(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "编辑广告物料单价") |
| | | @Log(title = "编辑广告物料单价", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | public R<?> editAssetAdMaterialPrice(@Valid @RequestBody AssetAdMaterialPriceDTO dto) { |
| | | assetAdMaterialPriceService.editAssetAdMaterialPrice(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("获取分页列表") |
| | | @PostMapping("/page") |
| | | public R<IPage<AssetAdMaterialPriceVO>> getPageList(@RequestBody AssetAdMaterialPriceQuery query) { |
| | | return R.ok(assetAdMaterialPriceService.getPageList(query)); |
| | | } |
| | | |
| | | @ApiOperation("详情") |
| | | @GetMapping("/detail/{id}") |
| | | public R<AssetAdMaterialPriceVO> getDetail(@ApiParam(name = "id", value = "广告物料单价ID") @PathVariable Integer id) { |
| | | return R.ok(assetAdMaterialPriceService.getDetail(id)); |
| | | } |
| | | |
| | | @ApiOperation("删除") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @DeleteMapping("/{id}") |
| | | public R<?> delete(@ApiParam(name = "id", value = "广告物料单价ID") @PathVariable Integer id) { |
| | | assetAdMaterialPriceService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("下载导入模板") |
| | | @GetMapping("/template") |
| | | public void getTemplate(HttpServletResponse response){ |
| | | FastExcelUtil.exportData(response, "广告物料单价导入模板", "广告物料单价", AssetAdMaterialPriceDTO.class, Collections.emptyList()); |
| | | } |
| | | |
| | | @ApiOperation("导入") |
| | | @Log(title = "导入广告物料单价", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/import") |
| | | public R<?> importAssetAdMaterialPrice(@RequestPart("file") MultipartFile file){ |
| | | if (file.isEmpty()) { |
| | | return R.fail("请选择一个文件上传!"); |
| | | } |
| | | try { |
| | | List<AssetAdMaterialPriceDTO> list = FastExcelUtil.readMultipartFile(file.getInputStream(), AssetAdMaterialPriceDTO.class); |
| | | assetAdMaterialPriceService.importAssetAdMaterialPrice(list); |
| | | return R.ok(); |
| | | } catch (IOException e) { |
| | | log.error("文件处理失败", e); |
| | | return R.fail("文件处理失败!"); |
| | | } |
| | | } |
| | | } |
| | | |