关耳er  

一、ISmbmsUserDao

    //根据姓名模糊查询
    public List<Smbms> getUser();
    //多条件查询
    public List<Smbms> getLikeUser(@Param("userName") String userName , @Param("userCode") String userCode );

二、小配置文件 ISmbmsUserDao.xml

<!--根据姓名模糊查询-->
    <select id="getUser" resultType="com.smbms.entity.Smbms">
        <!--select * from smbms_user where userName like CONCAT('%',#{userName},'%')-->
        select * from smbms_user where userName like '%' #{userName} '%'
    </select>

<!--多条件查询-->
    <select id="getLikeUser" resultType="com.smbms.entity.Smbms">
        <!--select * from smbms_user where userName like CONCAT('%',#{userName},'%')-->
        select * from smbms_user where userName like '%' #{userName} '%' and userCode like '%' #{userCode} '%'
    </select>

三、测试类

//根据姓名模糊查询
        /*List<Smbms> getUser=sqlSession.selectList("getUser","马");
        for (Smbms users:getUser) {
            System.out.println(users.getUserName());
        }*/

        //多条件查询
        ISmbmsUserDao mapper=sqlSession.getMapper(ISmbmsUserDao.class);
        List<Smbms> getUser=mapper.getLikeUser("马","yuan");
        for (Smbms users:getUser) {
            System.out.println(users.getUserName()+"================="+users.getUserpwd());
        }

 

posted on 2019-10-07 17:53  关耳er  阅读(1043)  评论(0编辑  收藏  举报