package com.usky.iot.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.iot.domain.BaseBuild;
import com.usky.iot.domain.BaseBuildFacility;
import com.usky.iot.domain.BaseBuildFacilityType;
import com.usky.iot.domain.BaseGgpFacility;
import com.usky.iot.service.BaseBuildService;
import com.usky.iot.service.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 建筑信息 前端控制器
 * </p>
 *
 * @author han
 * @since 2023-06-07
 */
@RestController
@RequestMapping("/baseBuild")
public class BaseBuildController {
    @Autowired
    private BaseBuildService baseBuildService;

    /**
     * 新增
     * @param baseBuild
     * @return
     */
    @PostMapping
    ApiResult<Void> add(@RequestBody BaseBuild baseBuild){
        baseBuildService.add(baseBuild);
        return ApiResult.success();
    }

    /**
     * 修改
     * @param baseBuild
     * @return
     */
    @PutMapping
    ApiResult<Void> update(@RequestBody BaseBuild baseBuild){
        baseBuildService.update(baseBuild);
        return ApiResult.success();
    }

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

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

    /**
     * 关联设施信息列表
     * @param requestVO
     * @return
     */
    @PostMapping("buildFacilityRelateList")
    ApiResult<CommonPage<BuildFacilityRelateResponeVO>> buildFacilityRelateList(@RequestBody BuildFacilityRelateRequestVO requestVO){
        return ApiResult.success(baseBuildService.buildFacilityRelateList(requestVO));
    }

    /**
     * 建筑设施绑定
     * @param statusVO
     * @return
     */
    @PostMapping("setBuildFacilityStatus")
    ApiResult<Void> setBuildFacilityStatus(@RequestBody BuildFacilityStatusVO statusVO){
        baseBuildService.setBuildFacilityStatus(statusVO);
        return ApiResult.success();
    }

    /**
     * 建筑设施关联查询
     *
     * @param baseBuildFacilityVO
     * @return
     */
    @PostMapping("buildFacilityInfo")
    public ApiResult<List<Object>> buildFacilityInfo(@RequestBody BaseBuildFacilityVO baseBuildFacilityVO) {
        return ApiResult.success(baseBuildService.buildFacilityInfo(baseBuildFacilityVO));
    }

    /**
     * 类型设施关联查询
     *
     * @param baseBuildFacilityVO
     * @return
     */
    @PostMapping("typeFacilityInfo")
    public ApiResult<List<BaseBuildFacility>> typeFacilityInfo(@RequestBody BaseBuildFacilityVO baseBuildFacilityVO) {
        return ApiResult.success(baseBuildService.typeFacilityInfo(baseBuildFacilityVO));
    }

    /**
     * 建筑关联类型查询
     * @param id  主键ID
     * @return
     */
    @GetMapping("buildTypeInfo")
    public ApiResult<List<BaseBuildFacilityType>> buildTypeInfo(@RequestParam(value = "id") Integer id) {
        return ApiResult.success(baseBuildService.buildTypeInfo(id));
    }
}





