農農  

一、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-08 15:23  Baekhyunne  阅读(1122)  评论(0编辑  收藏  举报