Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1790|回复: 0
打印 上一主题 下一主题

mybatis sql in 查询

[复制链接]

697

主题

1142

帖子

4086

积分

认证用户组

Rank: 5Rank: 5

积分
4086
跳转到指定楼层
楼主
发表于 2017-3-14 18:59:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 java 于 2017-3-14 19:01 编辑


<resultMap id="userMap" type="com.kingsoft.wps.mail.account.core.model.pojo.WPSAccountLoggedInUser">
    <result column="id" property="id" jdbcType="BIGINT"/>
    <result column="wps_user_id" property="wpsUserId" jdbcType="VARCHAR"/>
    <result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP"
            typeHandler="com.kingsoft.wps.mail.mybatis.typehandle.JodaDateTime2TimestampTypeHandler"/>
    <result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP"
            typeHandler="com.kingsoft.wps.mail.mybatis.typehandle.JodaDateTime2TimestampTypeHandler"/>
</resultMap>


<select
id="getLoggedInUsersInfoSql"  parameterType="map" resultMap="userMap">
    select id, wps_user_id, last_login_time, modify_time
    from wps_account_logged_in_user
    where 1=1
        and wps_user_id in
        <foreach item="item" index="index" collection="userIds" open="("
                 separator="," close=")">
            #{item}
        </foreach>
</select>


public List<WPSAccountLoggedInUser> getWpsUsersInfo(List netUserIds)
{
    Map<String, Object> param = new HashMap<>();
    param.put("userIds", netUserIds);
    List<WPSAccountLoggedInUser> users = getSqlSession().selectList(NAME_SPACE +"getLoggedInUsersInfoSql", param);
    return users;
}

List<String> netUserIds = new ArrayList();

netUserIds.add("aaa");
getWpsUsersInfo(netUserIds);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-5-7 18:36 , Processed in 0.055282 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表