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();
|
}
|
|
}
|