package io.renren.modules.admin.dao;

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

import java.util.List;

/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-02-26 16:13:09
 */
@Mapper
public interface SubjectDao extends BaseMapper<SubjectEntity> {
    /**
     * 根据name 进行模糊查询
     * @param name
     * @return
     */
    @Select("select * from subject where name like '%${name}%'")
    List<SubjectEntity> findAllByName(String name);


    /**
     * 根据name 判断name是否存在
     * @param name
     * @return
     */
    @Select("select case when EXISTS (select * from subject where name = '${name}') then 1 else 0 end as result")
    int selectIsName(String name);
}
