package io.renren.modules.app.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.R;
import io.renren.common.utils.PageUtils;
import io.renren.modules.admin.entity.LectureEntity;
import io.renren.modules.admin.service.LectureService;

/**
 * 演讲(报告)表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-02-11 14:36:45
 */
@RestController
@RequestMapping("app/lecture")
public class AppLectureController {
    @Autowired
    private LectureService lectureService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        if (!params.containsKey("meetingId")) {
            return R.error("会议id不可为空");
        }
        PageUtils page = lectureService.myQueryPage(params);

        return R.ok().put("page", page);
    }

    // /**
    //  * 列表
    //  */
    // @GetMapping("/list/{mid}")
    // public R list(@PathVariable("mid") Long mid) {     
    //      List<LectureEntity> lectureList = lectureService.list(
    //          new QueryWrapper<LectureEntity>().eq("meeting_id", mid));

    //     return R.ok().put("lectureList", lectureList);
    // }

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        LectureEntity lecture = lectureService.getById(id);

        return R.ok().put("lecture", lecture);
    }
}
