package io.renren.modules.admin.dao;

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

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;
import org.apache.ibatis.annotations.Update;

/**
 * 
 * @author huwhois
 * @email huwhois@163.com
 * @date 2020-12-09 14:33:56
 */
@Mapper
public interface MemberDao extends BaseMapper<MemberEntity> {
	@Update("update member set remark=#{remark} where id=#{id};")
    int updateRemark(Long id, String remark);

    @Update("update member set flag=#{flag} where id=#{id};")
	int updateFlag(Long id, Integer flag);

    @Select("select `member`.`id` AS `id`,`member`.`truename` AS `truename`,`member`.`organization` AS `organization`,`member`.`position` AS `position`,`member`.`phone` AS `phone`,`member`.`remark` AS `remark`,if(isnull(`attenders`.`id`),0,1) AS `receipt`,`attenders`.`id` AS `aid`,#{meetingId} AS `meeting_id`,`member`.`symbol` AS `symbol` from (`member` left join `attenders` on((`attenders`.`member_id` = `member`.`id`) and (`attenders`.`meeting_id` = #{meetingId}))) where truename like '%${key1}%' or phone like '%${key2}%' limit #{offest},#{limit}")
	List<Map<String, Object>> getInvitationPageList(Long meetingId, String key1, String key2, int offest, int limit);

    @Select("select count(*) from (`member` left join `attenders` on((`attenders`.`member_id` = `member`.`id`) and (`attenders`.`meeting_id` = #{meetingId}))) where truename like '%${key1}%' or phone like '%${key2}%'")
	Integer getInvitationCounts(Long meetingId, String key1, String key2);
}
