package com.usky.meeting.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.common.log.annotation.Log;
import com.usky.common.log.enums.BusinessType;
import com.usky.meeting.domain.MeetingFloor;
import com.usky.meeting.service.MeetingFloorService;
import com.usky.meeting.service.vo.MeetingFloorRequestVO;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 楼层表 前端控制器
 * </p>
 *
 * @author zyj
 * @since 2024-03-08
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/meetingFloor")
public class MeetingFloorController {
    @Autowired
    private MeetingFloorService meetingFloorService;

    /**
     * 楼层列表
     * @param requestVO
     * @return
     */
    @PostMapping("meetingFloorList")
    public ApiResult<CommonPage<MeetingFloor>> meetingFloorList(@RequestBody MeetingFloorRequestVO requestVO){
        return ApiResult.success(meetingFloorService.meetingFloorList(requestVO));
    }

    /**
     * 新增
     * @param meetingFloor
     * @return
     */
    @Log(title = "新增-会议楼层", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult<Void> add(@RequestBody MeetingFloor meetingFloor){
        meetingFloorService.add(meetingFloor);
        return ApiResult.success();
    }

    /**
     * 修改
     * @param meetingFloor
     * @return
     */
    @Log(title = "修改-会议楼层", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult<Void> edit(@RequestBody MeetingFloor meetingFloor){
        meetingFloorService.edit(meetingFloor);
        return  ApiResult.success();
    }

    /**
     * 删除
     * @param floorId
     * @return
     */
    @Log(title = "删除-会议楼层", businessType = BusinessType.DELETE)
    @DeleteMapping
    public ApiResult<Void> remove(@RequestParam(value = "floorId") Long floorId){
        meetingFloorService.remove(floorId);
        return ApiResult.success();
    }

}

