firemail

标题: mybatis sql in 查询 [打印本页]

作者: java    时间: 2017-3-14 18:59
标题: mybatis sql in 查询
本帖最后由 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);




欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3