package thyyxxk.webserver.dao.his.medicine;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.medicine.YpZdGroupName;

import java.util.List;

@Mapper
public interface YpZdGroupNameDao extends BaseMapper<YpZdGroupName> {

    @Select(" select gn.group_name as name, gn.group_no as code from yp_zd_group_name as gn " +
            " where gn.yf_flag = #{yfFlag} and (gn.group_no like '%${text}%' or gn.group_name like '%${text}%' " +
            " or gn.py_code like ('%' + upper(#{text}) + '%') or gn.d_code like ('%' + upper(#{text}) + '%')) " +
            " order by gn.group_no ")
    List<CodeName> selectYpGroupNameByYfFlag(String text, String yfFlag);

    @Select(" select gn.group_name as name, gn.group_no as code, gn.yf_flag as statusFlag from yp_zd_group_name as gn " +
            " where (gn.group_no like '%${text}%' or gn.group_name like '%${text}%' " +
            " or gn.py_code like ('%' + upper(#{text}) + '%') or gn.d_code like ('%' + upper(#{text}) + '%')) " +
            " order by gn.group_no ")
    List<CodeName> selectYpGroupNameAll(String text);

    @Select(" select group_no," +
            "dept_code," +
            "py_code," +
            "d_code," +
            "group_name," +
            "mz_flag," +
            "yf_flag" +
            " from  yp_zd_group_name ")
    List<YpZdGroupName> selectAll();
}
