/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ifish.controller;

import com.ifish.bean.Tbl_Live_Message;
import com.ifish.bean.Tbl_Live_Room;
import com.ifish.enums.ResultEnum;
import com.ifish.helper.LiveRoomHelperI;
import com.ifish.util.IfishUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 *
 * @author Administrator
 */
@RestController
public class LiveRoom {

    @Autowired
    private LiveRoomHelperI liveRoomHelperI;

    /**
     * 新增直播间
     *
     * @param liveRoom
     * @param fileUpload
     * @return
     */
    @RequestMapping(value = "/liveRoom/v3/addLiveRoom.do", method = RequestMethod.POST)
    public Object addLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom) {
        try {
            return liveRoomHelperI.addLiveRoom(fileUpload, liveRoom);
        } catch (Exception e) {
        }
        return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
    }

    /**
     * 直播间点赞
     *
     * @param roomId
     * @param userId
     * @return
     */
    @RequestMapping(value = "/liveRoomZan/{roomId}/{userId}", method = RequestMethod.GET)
    public Object liveRoomsZan(@PathVariable Integer roomId, @PathVariable Integer userId) {
        try {
            return liveRoomHelperI.liveRoomsZan(roomId, userId);
        } catch (Exception e) {
        }
        return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
    }

    /**
     * 修改人气值
     *
     * @param roomId
     * @param userId
     * @return
     */
    @RequestMapping(value = "/liveRoom/v3/popularityValue.do", method = RequestMethod.POST)
    public Object popularityValue(Integer roomId, Integer userId) {
        return liveRoomHelperI.popularityValue(roomId, userId);
    }

    /**
     * 直播间留言
     *
     * @param liveMessage
     * @return
     */
    @RequestMapping(value = "/liveRoom/v3/leaveMessage.do", method = RequestMethod.POST)
    public Object leaveMessage(Tbl_Live_Message liveMessage) {
        try {
            return liveRoomHelperI.leaveMessage(liveMessage);
        } catch (Exception e) {
        }
        return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
    }

    /**
     * 根据直播间ID获取直播间评论列表
     *
     * @param roomId
     * @return
     */
    @RequestMapping(value = "/liveRoom/v3/getleaveMessage.do", method = RequestMethod.GET)
    public Object getleaveMessage(Integer roomId, Integer firstResult, Integer pageSize) {
        try {
            return liveRoomHelperI.getLeaveMessage(firstResult, pageSize, roomId);
        } catch (Exception e) {
        }
        return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
    }

    /**
     * 获取直播间信息
     *
     * @param roomId
     * @return
     */
    @RequestMapping(value = "/liveRoom/v3/getLiveRoomInfo.do", method = RequestMethod.GET)
    public Object getLiveRoomInfo(Integer roomId) {
        try {
            return liveRoomHelperI.getLiveRoomInfo(roomId);
        } catch (Exception e) {
        }
        return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
    }

    /**
     * 获取直播列表
     *
     * @param firstResult
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/liveRoom/v3/getLiveRooms.do", method = RequestMethod.GET)
    public Object getLiveRooms(Integer firstResult, Integer pageSize, String orders) {
        try {
            return liveRoomHelperI.getLiveRooms(firstResult, pageSize, orders);
        } catch (Exception e) {
        }
        return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
    }

    /**
     * 修改直播间
     *
     * @param fileUpload
     * @param liveRoom
     * @return
     */
    @RequestMapping(value = "/liveRoom/v3/updateLiveRoom.do", method = RequestMethod.POST)
    public Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom) {
        try {
            return liveRoomHelperI.updateLiveRoom(fileUpload, liveRoom);
        } catch (Exception e) {
        }
        return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
    }

}
