package com.usky.iot.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.iot.domain.BaseBuild;
import com.usky.iot.domain.BaseBuildPlane;
import com.usky.iot.service.BaseBuildPlaneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import retrofit2.http.PUT;

import java.util.List;

/**
 * <p>
 * 建筑楼层平面图 前端控制器
 * </p>
 *
 * @author han
 * @since 2023-08-17
 */
@RestController
@RequestMapping("/baseBuildPlane")
public class BaseBuildPlaneController {
    @Autowired
    private BaseBuildPlaneService baseBuildPlaneService;

    /**
     * 新增
     * @param baseBuildPlane
     * @return
     */
    @PostMapping
    ApiResult<Void> add(@RequestBody BaseBuildPlane baseBuildPlane){
        baseBuildPlaneService.add(baseBuildPlane);
        return ApiResult.success();
    }

    /**
     * 修改
     * @param baseBuildPlane
     * @return
     */
    @PutMapping
    ApiResult<Void> update(@RequestBody BaseBuildPlane baseBuildPlane){
        baseBuildPlaneService.update(baseBuildPlane);
        return ApiResult.success();
    }

    /**
     * 列表
     * @param buildId
     * @param floor
     * @return
     */
    @GetMapping("dataList")
    ApiResult<List<BaseBuildPlane>> dataList(@RequestParam(value = "buildId") Integer buildId,
                                             @RequestParam(value = "floor",required = false) String floor){
        return ApiResult.success(baseBuildPlaneService.dataList(buildId,floor));
    }
}

