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.FireAlarmMeetingUserServiceI;
import com.zcloud.zcGbsServicer.dto.FireAlarmMeetingUserAddCmd;
import com.zcloud.zcGbsServicer.dto.FireAlarmMeetingUserPageQry;
import com.zcloud.zcGbsServicer.dto.FireAlarmMeetingUserUpdateCmd;
import com.zcloud.zcGbsServicer.dto.clientobject.FireAlarmMeetingUserCO;
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}/meetingUser")
public class FireAlarmMeetingUserController {

    private final FireAlarmMeetingUserServiceI fireAlarmMeetingUserService;

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

    @ApiOperation("新增")
    @PostMapping("/save")
    public SingleResponse<FireAlarmMeetingUserCO> save(@Validated @RequestBody FireAlarmMeetingUserAddCmd cmd) {
        return fireAlarmMeetingUserService.add(cmd);
    }

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

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

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