mitao
2 天以前 a9f2a7f4fac47c7a5b1302db2e0c363a55459f84
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/AssetTypeController.java
@@ -1,8 +1,25 @@
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>
@@ -12,9 +29,49 @@
 * @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();
    }
}