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

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.entity.park.PmgBatParkManage;
import com.yuchen.saas.park.api.vo.park.PmgBatParkManageVo;
import com.yuchen.saas.park.service.service.PmgBatParkManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.nest.springwrap.core.tool.api.R;
import org.nest.springwrap.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author 刘通
 * @date 2020/12/11 17:32
 */
@RestController
@AllArgsConstructor
@RequestMapping("/parkSpaceTree")
@Api(value = "园区空间管理", tags = "园区空间管理表接口")
public class PmgBatParkManageController {

    @Autowired
    private PmgBatParkManageService pmgBatParkManageService;
    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入园区空间管理信息")
    public R<PmgBatParkManageVo> detail(PmgBatParkManage pmgBatParkManage) {
        PmgBatParkManageVo detail = pmgBatParkManageService.getDetail(pmgBatParkManage);
        return R.data(detail);
    }

    /**
     * list
     */
    @GetMapping("/getManageList")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "tree所有数据", notes = "传入园区空间管理信息")
    public R<List<PmgBatParkManageVo>> getManageList(PmgBatParkManage pmgBatParkManage) {
        List<PmgBatParkManageVo> parkManageList = pmgBatParkManageService.getManageList(pmgBatParkManage);
        return R.data(parkManageList);
    }
    /**
     * 新增 园区空间管理
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "新增", notes = "传入园区空间管理信息")
    public R save(@Valid @RequestBody PmgBatParkManage pmgBatParkManage) {
        return R.status(pmgBatParkManageService.save(pmgBatParkManage));
    }
    /**
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "园区空间管理", notes = "传入园区空间管理信息")
    public R submit(@Valid @RequestBody PmgBatParkManage pmgBatParkManage) {
        return R.status(pmgBatParkManageService.submit(pmgBatParkManage));
    }
    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入园区空间管理信息")
    public R update(@Valid @RequestBody PmgBatParkManage pmgBatParkManage) {
        return R.status(pmgBatParkManageService.updateById(pmgBatParkManage));
    }

    /**
     * 删除 园区空间管理
     */
    @DeleteMapping("/remove")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "逻辑删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(pmgBatParkManageService.remove(Func.toLongList(ids)));
    }


}
