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


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.manage.system.api.param.CommonIdParam;
import com.yuchen.saas.park.api.entity.emergency.EmergencyHandleMeasure;
import com.yuchen.saas.park.service.service.emergency.IEmergencyHandleMeasureService;
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-07-30
 */
@RestController
@RequestMapping("/emergencyPlan/emergencyHandleMeasure")
public class EmergencyHandleMeasureController {

    @Autowired
    private IEmergencyHandleMeasureService emergencyHandleMeasureService;

    @PostMapping("/save")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增", notes = "应急处置措施新增")
    public R save(@Valid @RequestBody EmergencyHandleMeasure emergencyHandleMeasure) {
        return R.status(emergencyHandleMeasureService.save(emergencyHandleMeasure));
    }

    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "列表", notes = "应急处置措施列表")
    public R<List<EmergencyHandleMeasure>> list(@RequestParam("sceneDisposePlanId") Long sceneDisposePlanId) {
        return R.data(emergencyHandleMeasureService.list(new LambdaQueryWrapper<EmergencyHandleMeasure>()
                .eq(EmergencyHandleMeasure::getSceneDisposePlanId,
                        sceneDisposePlanId)));
    }

    @PostMapping("/update")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "修改", notes = "应急处置措施修改")
    public R update(@Valid @RequestBody EmergencyHandleMeasure emergencyHandleMeasure) {
        return R.status(emergencyHandleMeasureService.saveOrUpdate(emergencyHandleMeasure));
    }

    @PostMapping("/delete")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "删除", notes = "应急处置措施删除")
    public R delete(@Valid @RequestBody CommonIdParam param) {
        return R.data(emergencyHandleMeasureService.removeById(param.getId()));
    }

    @GetMapping("/detail")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "详情", notes = "应急处置措施详情")
    public R<EmergencyHandleMeasure> detail(@RequestParam("id") Long id) {
        return R.data(emergencyHandleMeasureService.getById(id));
    }

//    @PostMapping("/page")
//    @ApiOperationSupport(order = 6)
//    @ApiOperation(value = "分页列表", notes = "应急处置措施分页列表")
//    public R<Page<EmergencyHandleMeasure>> page(@RequestBody EmergencyPlanQueryDto emergencyPlanQueryDto) {
//        return R.data(emergencyHandleMeasureService.page(emergencyPlanQueryDto));
//    }




}
