package com.yuchen.saas.park.service.controller.space;

import com.yuchen.saas.park.api.entity.park.ParkSpaceInfo;
import com.yuchen.saas.park.api.request.SpaceInfoRequest;
import com.yuchen.saas.park.service.service.ParkSpaceInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName ParkSpaceInfoController
 * @Description 园区空间信息控制器
 * @Author 张逸飞
 * @Date 2022/10/26 15:38
 */
@RestController
@AllArgsConstructor
@RequestMapping("/parkSpace")
@Api(value = "园区空间信息控制器", tags = "园区空间信息控制器")
public class ParkSpaceInfoController {

    /**
     * 注入园区空间信息操作接口
     */
    @Resource
    private ParkSpaceInfoService parkSpaceInfoService;

    /**
     * 新增空间信息
     * @param parkSpaceInfo 园区空间信息
     * @return
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增空间信息", notes = "新增空间信息")
    public R save(@RequestBody ParkSpaceInfo parkSpaceInfo){
        return parkSpaceInfoService.saveSpaceInfo(parkSpaceInfo);
    }

    /**
     * 修改空间信息
     * @param parkSpaceInfo 园区空间信息
     * @return
     */
    @PostMapping("/update")
    @ApiOperation(value = "修改空间信息", notes = "修改空间信息")
    public R update(@RequestBody ParkSpaceInfo parkSpaceInfo){
        return R.status(parkSpaceInfoService.updateSpaceInfo(parkSpaceInfo));
    }

    /**
     * 删除空间信息
     * @param parkSpaceInfo
     * @return
     */
    @PostMapping("/remove")
    @ApiOperation(value = "删除空间信息", notes = "删除空间信息")
    public R remove( @RequestBody ParkSpaceInfo parkSpaceInfo) {
        return parkSpaceInfoService.delSpaceInfo(parkSpaceInfo.getId());
    }

    /**
     * 获取园区空间树结构
     * @param spaceInfoRequest
     * @return
     */
    @GetMapping("/getTree")
    @ApiOperation(value = "获取园区空间树结构", notes = "获取园区空间树结构")
    public R getTree(SpaceInfoRequest spaceInfoRequest){
        return R.data(parkSpaceInfoService.getTree(spaceInfoRequest));
    }

    /**
     *
     * @param spaceInfoRequest 园区空间信息
     * @return
     */
    @PostMapping("/batchSave")
    @ApiOperation(value = "批量新增空间信息", notes = "批量新增空间信息")
    public R batchSave(@RequestBody SpaceInfoRequest spaceInfoRequest){
        return parkSpaceInfoService.batchSave(spaceInfoRequest);
    }

}
