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


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.manage.system.api.param.CommonIdParam;
import com.yuchen.saas.park.api.entity.security.SaasParkElectronicFenceArea;
import com.yuchen.saas.park.service.service.security.ISaasParkElectronicFenceAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * <p>
 * 电子围栏防区表 前端控制器
 * </p>
 *
 * @author 洪铭铭
 * @since 2024-09-05
 */
@Api(tags = "电子围栏防区管理")
@RestController
@RequestMapping("/saasParkElectronicFenceArea")
public class SaasParkElectronicFenceAreaController {

    @Autowired
    private ISaasParkElectronicFenceAreaService saasParkElectronicFenceAreaService;

    @PostMapping("/save")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增", notes = "电子围栏防区新增")
    public R save(@Valid @RequestBody SaasParkElectronicFenceArea saasParkElectronicFenceArea) {
        return R.status(saasParkElectronicFenceAreaService.save(saasParkElectronicFenceArea));
    }

    @PostMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "列表", notes = "电子围栏防区列表")
    public R<List<SaasParkElectronicFenceArea>> list() {
        return R.data(saasParkElectronicFenceAreaService.getAll());
    }

    @PostMapping("/update")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "修改", notes = "电子围栏防区修改")
    public R update(@Valid @RequestBody SaasParkElectronicFenceArea saasParkElectronicFenceArea) {
        return R.status(saasParkElectronicFenceAreaService.saveOrUpdate(saasParkElectronicFenceArea));
    }

    @PostMapping("/delete")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "删除", notes = "电子围栏防区删除")
    public R delete(@Valid @RequestBody CommonIdParam param) {
        return R.data(saasParkElectronicFenceAreaService.removeById(param.getId()));
    }

    @GetMapping("/detail")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "详情", notes = "电子围栏防区详情")
    public R<SaasParkElectronicFenceArea> detail(@RequestParam("id") Long id) {
        return R.data(saasParkElectronicFenceAreaService.getById(id));
    }

//    @PostMapping("/page")
//    @ApiOperationSupport(order = 6)
//    @ApiOperation(value = "分页列表", notes = "应急预案分页列表")
//    public R<Page<SaasParkElectronicFenceArea>> page(@RequestBody SaasParkElectronicFenceQueryDto saasParkElectronicFenceQueryDto) {
//        return R.data(saasParkElectronicFenceAreaService.page(saasParkElectronicFenceQueryDto));
//    }

}
