| | |
| | | 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.AssetAdDTO; |
| | | import com.ruoyi.system.dto.asset.AssetAdRentalRecordDTO; |
| | | import com.ruoyi.system.model.AssetAdRentalRecord; |
| | | import com.ruoyi.system.query.AssetAdQuery; |
| | | import com.ruoyi.system.service.AssetAdRentalRecordService; |
| | | import com.ruoyi.system.service.AssetAdService; |
| | | import com.ruoyi.system.vo.asset.AssetAdDetailVO; |
| | | import com.ruoyi.system.vo.asset.AssetAdVO; |
| | | 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.validation.Valid; |
| | | |
| | |
| | | public class AssetAdController { |
| | | |
| | | private final AssetAdService assetAdService; |
| | | private final AssetAdRentalRecordService assetAdRentalRecordService; |
| | | |
| | | @PostMapping("/add") |
| | | @ApiOperation(value = "新增广告无形资产") |
| | | @Log(title = "新增广告无形资产", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public R<?> addAssetAd(@Valid @RequestBody AssetAdDTO dto) { |
| | | assetAdService.addAssetAd(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation(value = "编辑广告无形资产") |
| | | @Log(title = "编辑广告无形资产", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | @ApiOperation(value = "新增广告无形资产") |
| | | public R<?> editAssetAd(@Valid @RequestBody AssetAdDTO dto) { |
| | | assetAdService.editAssetAd(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("获取分页列表") |
| | | @PostMapping("/page") |
| | | public R<IPage<AssetAdVO>> getPageList(@RequestBody AssetAdQuery query) { |
| | | return R.ok(assetAdService.getPageList(query)); |
| | | } |
| | | |
| | | @ApiOperation("详情") |
| | | @GetMapping("/detail/{id}") |
| | | public R<AssetAdDetailVO> getDetail(@ApiParam(name = "id", value = "广告无形资产ID") @PathVariable Integer id) { |
| | | return R.ok(assetAdService.getDetail(id)); |
| | | } |
| | | @ApiOperation("导入") |
| | | @Log(title = "导入广告无形资产", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/import") |
| | | public R<?> importAssetAd(@RequestPart("file") MultipartFile file){ |
| | | //TODO 待完成 |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation("删除") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @DeleteMapping("/{id}") |
| | | public R<?> delete(@ApiParam(name = "id", value = "广告无形资产ID") @PathVariable Integer id) { |
| | | assetAdService.removeById(id); |
| | | assetAdRentalRecordService.lambdaUpdate().eq(AssetAdRentalRecord::getAssetAdId, id).remove(); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("添加出租记录") |
| | | @PostMapping("/rental/add") |
| | | public R<?> addRentalRecord(@Valid @RequestBody AssetAdRentalRecordDTO dto){ |
| | | assetAdRentalRecordService.addRentalRecord(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("编辑出租记录") |
| | | @PostMapping("/rental/edit") |
| | | public R<?> editRentalRecord(@Valid @RequestBody AssetAdRentalRecordDTO dto){ |
| | | assetAdRentalRecordService.editRentalRecord(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @ApiOperation("删除出租记录") |
| | | @DeleteMapping("/rental/delete/{id}") |
| | | public R<?> deleteRentalRecord(@ApiParam(name = "id", value = "广告无形资产ID") @PathVariable Integer id){ |
| | | assetAdRentalRecordService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |