package com.fs.qw.controller;

import com.fs.common.core.domain.R;
import com.fs.qw.domain.QwRoom;
import com.fs.qw.service.IQwRoomService;
import com.fs.qw.vo.QwContactListVO;
import com.fs.qw.vo.QwRoomListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/qw/room")
public class QwRoomController {

    @Autowired
    private IQwRoomService roomService;

    @GetMapping("/list")
    public R list(Long seq,String deviceId){
        List<QwRoomListVO> list =  roomService.list(seq,deviceId);
        return R.ok().put("data",list);
    }

    @PostMapping("/detail")
    public R detail( String deviceId,Long roomId){
        QwRoomListVO qwRoomListVO = roomService.detail(deviceId,roomId);
        return R.ok().put("data",qwRoomListVO);
    }

    @GetMapping("/roomDetail/{roomId}")
    public R getRoomDetail(@PathVariable("roomId")Long roomId){
        List<QwContactListVO> list = roomService.selectRoomMemberByRoomId(roomId);
        List<Long> adminList = roomService.selectRoomAdminList(roomId);
        QwRoom qwRoom = roomService.selectRoomByRoomId(roomId);
        return R.ok().put("members",list).put("admins",adminList).put("detail",qwRoom);
    }

}
