package com.usky.iot.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.iot.domain.BaseBuildUnit;
import com.usky.iot.service.BaseBuildUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author han
 * @since 2026-02-03
 */
@RestController
@RequestMapping("/baseBuildUnit")
public class BaseBuildUnitController {
    @Autowired
    private BaseBuildUnitService baseBuildUnitService;

    /**
     * 新增
     * @param baseBuildUnits
     * @return
     */
    @PostMapping
    ApiResult<Void> add(@RequestBody List<BaseBuildUnit> baseBuildUnits){
        baseBuildUnitService.add(baseBuildUnits);
        return ApiResult.success();
    }

    /**
     * 修改
     * @param baseBuildUnits
     * @return
     */
    @PutMapping
    ApiResult<Void> update(@RequestBody List<BaseBuildUnit> baseBuildUnits){
        baseBuildUnitService.update(baseBuildUnits);
        return ApiResult.success();
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    ApiResult<Void> remove(@PathVariable("id") Integer id){
        baseBuildUnitService.remove(id);
        return ApiResult.success();
    }

    /**
     * 列表
     * @param id
     * @param buildId
     * @return
     */
    @GetMapping("baseBuildUnitList")
    ApiResult<List<BaseBuildUnit>> baseBuildUnitList(@RequestParam(value = "id",required = false) Integer id,
                                                     @RequestParam(value = "buildId") Integer buildId){
        return ApiResult.success(baseBuildUnitService.baseBuildUnitList(id,buildId));
    }
}

