package io.renren.modules.admin.dao;

import io.renren.modules.admin.entity.OrganizationEntity;
import java.util.Map;
import java.util.List;

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

/**
 * VIEW
 * 
 * @author huwhois
 * @email huwhois@gmail.com
 * @date 2020-07-08 09:32:07
 */
@Mapper
public interface OrganizationDao extends BaseMapper<OrganizationEntity> {

    @Select("select `organization`,sum(`num`) as `total` from `organization` where `organization` like '%${key}%' group by `organization` limit #{offset}, #{limit};")
    List<Map<String, Object>> getPageList(String key, int offset, int limit);
    
    @Select("select count(*) from (select count(*) from `organization` where `organization` like '%${key}%' group by `organization`) as o;")
    int getCounts(String key);

    @Select("select `truename`,`phone`,`sex`,`position`,`email`,group_concat(`meeting`.`name`) as `previous` from `attendersview` join `meeting` on `attendersview`.`meeting_id`=`meeting`.`id`  where `organization`=#{organization} group by `truename` limit  #{offset}, #{limit};")
    List<Map<String, Object>> getPageAttendList(String organization, int offset, int limit);

    @Select("select count(*) from (select count(*) from `attendersview` join `meeting` on `attendersview`.`meeting_id`=`meeting`.`id`  where `organization`=#{organization} group by `truename`) as a;")
	int getAttendCounts(String organization);
}
