无关风月
13 小时以前 053c2264ab5d7596aea3f8fcac18d487e6f9c766
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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;
 
/**
 * <p>
 * 广告无形资产表 前端控制器
 * </p>
 *
 * @author WuGuanFengYue
 * @since 2025-09-15
 */
@Api(tags = {"广告无形资产相关接口"})
@Slf4j
@Validated
@RestController
@RequestMapping("/asset-ad")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class AssetAdController {
 
    private final AssetAdService assetAdService;
    private final AssetAdRentalRecordService assetAdRentalRecordService;
 
    @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")
    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();
    }
}