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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuchen.saas.park.api.request.FireFacilityAddRequest;
import com.yuchen.saas.park.api.request.FireFacilityDeleteRequest;
import com.yuchen.saas.park.api.request.FireFacilityQueryRequest;
import com.yuchen.saas.park.api.request.FireFacilityUpdateRequest;
import com.yuchen.saas.park.api.response.FireFacilityResponse;
import com.yuchen.saas.park.service.service.FireFacilityService;
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;
import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName FireFacilityController
 * @Description 消防设施控制器类
 * @Author 肖祥
 * @Date 2022/10/18 15:30
 * @Version 1.0。0
 **/
@RestController
@AllArgsConstructor
@RequestMapping("/fire/inspect/facility")
@Api(value = "消防设施控制器接口", tags = "消防设施控制器接口")
public class FireFacilityController {

    @Resource
    private FireFacilityService fireFacilityService;

    /**
     * 消防设施新增
     */
    @ApiOperation(value = "消防设施新增")
    @PostMapping("/add")
    public R<Boolean> add(@Valid @RequestBody FireFacilityAddRequest fireFacilityAddRequest) {
        return fireFacilityService.add(fireFacilityAddRequest);
    }

    /**
     * 消防设施分页
     */
    @GetMapping("/list/page")
    @ApiOperation(value = "消防设施分页", notes = "消防设施分页")
    public R<IPage<FireFacilityResponse>> listPage(FireFacilityQueryRequest fireFacilityQueryRequest) {
        return  fireFacilityService.page(fireFacilityQueryRequest);
    }

    /**
     * 消防设施删除
     */
    @ApiOperation(value = "消防设施删除")
    @PostMapping("/delete")
    public R<Boolean> delete(@Valid @RequestBody FireFacilityDeleteRequest fireFacilityDeleteRequest) {
        return fireFacilityService.delete(fireFacilityDeleteRequest);
    }

    /**
     * 消防设施编辑
     */
    @ApiOperation(value = "消防设施更新")
    @PostMapping("/update")
    public R<Boolean> update(@Valid @RequestBody FireFacilityUpdateRequest fireFacilityUpdateRequest) {
        return fireFacilityService.update(fireFacilityUpdateRequest);
    }

    /**
     * 消防设施详情
     */
    @ApiOperation(value = "消防设施详情")
    @GetMapping("/detail")
    public R<FireFacilityResponse> detail(@RequestParam(name = "id",required = false) Long id) {
        return fireFacilityService.detail(id);
    }

    /**
     * 消防设施不分页
     */
    @GetMapping("/list")
    @ApiOperation(value = "消防设施分页", notes = "消防设施分页")
    public R<List<FireFacilityResponse>> list(FireFacilityQueryRequest fireFacilityQueryRequest) {
        return  fireFacilityService.list(fireFacilityQueryRequest);
    }
}
