package com.zcloud.zcGbsServicer.web;

import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.zcloud.zcGbsServicer.api.FireAlarmMeetingRoomServiceI;
import com.zcloud.zcGbsServicer.dto.FireAlarmMeetingRoomAddCmd;
import com.zcloud.zcGbsServicer.dto.FireAlarmMeetingRoomPageQry;
import com.zcloud.zcGbsServicer.dto.FireAlarmMeetingRoomUpdateCmd;
import com.zcloud.zcGbsServicer.dto.clientobject.FireAlarmMeetingRoomCO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "消防报警固定会议室")
@RestController
@AllArgsConstructor
@RequestMapping("/${application.gateway}/meetingRoom")
public class FireAlarmMeetingRoomController {

    private final FireAlarmMeetingRoomServiceI fireAlarmMeetingRoomService;

    @ApiOperation("分页查询")
    @PostMapping("/list")
    public PageResponse<FireAlarmMeetingRoomCO> list(@RequestBody FireAlarmMeetingRoomPageQry qry) {
        return fireAlarmMeetingRoomService.listPage(qry);
    }

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<FireAlarmMeetingRoomCO> save(@Validated @RequestBody FireAlarmMeetingRoomAddCmd cmd) {
        return fireAlarmMeetingRoomService.add(cmd);
    }

    @ApiOperation("编辑")
    @PutMapping("/edit")
    public Response edit(@Validated @RequestBody FireAlarmMeetingRoomUpdateCmd cmd) {
        fireAlarmMeetingRoomService.edit(cmd);
        return Response.buildSuccess();
    }

    @ApiOperation("详情")
    @GetMapping("/{id}")
    public SingleResponse<FireAlarmMeetingRoomCO> get(@PathVariable Long id) {
        return SingleResponse.of(fireAlarmMeetingRoomService.get(id));
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public Response remove(@PathVariable Long id) {
        fireAlarmMeetingRoomService.remove(id);
        return Response.buildSuccess();
    }
}
