package com.yida.data.school.facility.controller;

import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.school.EduDormitoryRoom;
import com.yida.data.school.dto.index.EditPersonNumDTO;
import com.yida.data.school.dto.index.ListDormRoomDTO;
import com.yida.data.school.facility.service.EduDormitoryRoomService;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cc.mrbird.febs.common.redis.service.RedisService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Api(tags = "宿舍-寝室(不鉴权)")
@Slf4j
@RestController
@RequestMapping("/in/facility/dormRoom")
@RequiredArgsConstructor
public class InEduDormitoryRoomController {

    private final EduDormitoryRoomService eduDormitoryRoomService;
    private final RedisService redisService;

    @GetMapping("/getDormRoom")
    ResultBean<EduDormitoryRoom> getDormRoomNoPermission(@RequestParam("id") Long id) {
        return ResultBean.buildSuccess(eduDormitoryRoomService.getDormRoom(id));
    }

    @ApiOperation("寝室入住")
    @PostMapping("/editPersonNum")
    public ResultBean editPersonNumNoPermission(@RequestBody List<EditPersonNumDTO> dtos) {
        eduDormitoryRoomService.editPersonNum(dtos);
        return ResultBean.buildSuccess();
    }

    @ApiOperation("查询寝室列表")
    @PostMapping("/listDormRoom")
    public ResultBean<List<EduDormitoryRoom>> listDormRoom(@RequestBody ListDormRoomDTO dto) {
        return ResultBean.buildSuccess(eduDormitoryRoomService.listDormRoom(dto));
    }
}
