无关风月
昨天 2aa0dd9c34c6be86e70b1d2d939d3660552cb514
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
package com.ruoyi.web.controller.api;
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.dto.asset.AssetTypeDTO;
import com.ruoyi.system.service.AssetTypeService;
import com.ruoyi.system.vo.asset.AssetTypeTreeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.validation.Valid;
import java.util.List;
 
/**
 * <p>
 * 资产类型表 前端控制器
 * </p>
 *
 * @author WuGuanFengYue
 * @since 2025-09-15
 */
@Api(tags = {"资产-资产类型管理相关接口"})
@Validated
@RestController
@RequestMapping("/asset-type")
@RequiredArgsConstructor
public class AssetTypeController {
 
    private final AssetTypeService assetTypeService;
 
    @ApiOperation("获取资产类型树形数据")
    @GetMapping("/tree")
    public R<List<AssetTypeTreeVO>> getAssetTypeTree() {
        List<AssetTypeTreeVO> treeData = assetTypeService.getAssetTypeTree();
        return R.ok(treeData);
    }
 
    @ApiOperation("新增资产类型")
    @PostMapping("/add")
    public R<Void> addAssetType(@Valid @RequestBody AssetTypeDTO dto) {
        assetTypeService.addAssetType(dto);
        return R.ok();
    }
 
    @ApiOperation("编辑资产类型")
    @PutMapping("/edit")
    public R<Void> editAssetType(@Valid @RequestBody AssetTypeDTO dto) {
        assetTypeService.editAssetType(dto);
        return R.ok();
    }
 
    @ApiOperation("删除资产类型")
    @DeleteMapping("/{id}")
    public R<Void> deleteAssetType(@ApiParam(name = "id", value = "资产类型ID", required = true) @PathVariable Integer id) {
        assetTypeService.deleteAssetType(id);
        return R.ok();
    }
 
    @ApiOperation("批量删除资产类型")
    @PostMapping("/batch-delete")
    public R<Void> batchDeleteAssetType(@RequestBody List<Integer> ids) {
        assetTypeService.batchDeleteAssetType(ids);
        return R.ok();
    }
    
}