package com.xhkjedu.slive.controller.liveplay;

import com.xhkjedu.slive.model.liveplay.LCourseSectionWs;
import com.xhkjedu.slive.service.liveplay.LCourseSectionWsService;
import com.xhkjedu.utils.N_Utils;
import com.xhkjedu.vo.ResultVo;
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.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author ywx
 * @classname LCourseSectionWsController
 * @description 直播课节ws消息
 * @date 2023/1/4 9:56
 **/
@RestController
@RequestMapping("/csw")
public class LCourseSectionWsController {
    @Resource
    private LCourseSectionWsService lCourseSectionWsService;

    @PostMapping("/add")
    public ResultVo add(@RequestBody LCourseSectionWs ws) {
        N_Utils.validation(new Object[]{ws.getSectionid(), "课节id", 1, ws.getSender(), "消息发送人id"
                , 1, ws.getCinteract(), "互动类型", 1, ws.getMsg(), "消息", 2});
        lCourseSectionWsService.save(ws);
        return new ResultVo(0, "保存成功");
    }

    @PostMapping("/list")
    public ResultVo list(@RequestBody LCourseSectionWs ws) {
        Integer sectionid = ws.getSectionid();
        N_Utils.validation(new Object[]{sectionid, "课节id", 1});
        List<Map> list = lCourseSectionWsService.listAll(ws);
        return new ResultVo(0, "获取列表成功", list);
    }
}
