package io.renren.modules.admin.dao;

import io.renren.modules.admin.entity.TypesOfAttendersEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 参会人员类型表
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-02-24 10:37:48
 */
@Mapper
public interface TypesOfAttendersDao extends BaseMapper<TypesOfAttendersEntity> {

    @Select("select * from types_of_attenders where name like '%${name}%' ")
    List<TypesOfAttendersEntity> findAllByType (String name);


    /**
     * 根据meetingId 和 name 进行查询  数据库里是否存在该条数据
     * @param name
     * @param meetingId
     * @return
     */
    @Select("select case when EXISTS (select * from types_of_attenders where name = '${name}' and meeting_id = '${meetingId}' ) then 1 else 0 end as result")
    int selectIsnameAndId(@Param("name") String name, @Param("meetingId") Long meetingId);
}
