package io.renren.modules.admin.dao;

import io.renren.modules.admin.entity.LectureEntity;

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

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 演讲(报告)表
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-02-11 14:36:45
 */
@Mapper
public interface LectureDao extends BaseMapper<LectureEntity> {
    @Select("select l.id,a.id a_id,a.meeting_id,l.topic,l.branch_id,l.speech_time,m.truename,m.position,m.job_title,m.organization from attenders a join lecture l on a.id=l.attenders_id join member m on m.id=a.member_id where a.meeting_id=#{meetingId} and a.is_del=0 and l.is_del=0 and (l.topic like '%${key1}' or m.truename like '%${key2}%') limit #{startLimt},#{endLimt};")
    List<Map<String, Object>> getPageList(Long meetingId, String key1, String key2, int startLimt, int endLimt);

    @Select("select count(*) from attenders a join lecture l on a.id=l.attenders_id join member m on m.id=a.member_id where a.meeting_id=#{meetingId} and a.is_del=0 and l.is_del=0 and (l.topic like '%${key1}%' or m.truename like '%${key2}%'); ")
    int getCounts(Long meetingId, String key1, String key2);

    @Select("select l.id,a.id a_id,a.meeting_id,l.topic,l.branch_id,l.speech_time,m.truename,m.position,m.job_title,m.organization from attenders a join lecture l on a.id=l.attenders_id join member m on m.id=a.member_id where l.branch_id=#{branchId} and a.is_del=0 and l.is_del=0;")
    List<Map<String, Object>> getBranchList(Long branchId);
}
