zoukankan      html  css  js  c++  java
  • 字符串数组String[]转换成Long类型数组Long[]

    当表中的id为bigint类型,并且要通过id的数组来查询数据时,此时id的数组不能是字符串数组String[]而应该是Long[],此时就需要将字符串数组转换成Long类型数组

    String[] inDetailIdsString = inDetailIdString.split(",");
    //string 转为  long
    List<Long> inDetailIds = Arrays.stream(inDetailIdsString)
                            .map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
    ...
    int count4 = inStoreDetailDao.queryCountByCurCodeAndDetailId(inStoreCodeTab, curcode, inDetailIds);

    dao接口

    int queryCountByCurCodeAndDetailId(@Param("inStoreCodeTab") String inStoreCodeTab, @Param("curcode") String curcode, @Param("inDetailIds") List<Long> inDetailIds);

    mapper.xml

    <select id="queryCountByCurCodeAndDetailId" resultType="int">
            select count(*) from ${inStoreCodeTab}
            <where>
                <if test="curcode!=null and curcode!=''">
                    AND CURCODE = #{curcode}
                </if>
                <if test="inDetailIds!=null and inDetailIds.size()>0">
                    <foreach collection="inDetailIds" open=" and IN_DETAIL_ID in( " close=")" item="id" separator=",">
                        #{id}
                    </foreach>
                </if>
            </where>
        </select>
  • 相关阅读:
    反弹shell
    php-fpm(绕过open_basedir,结合ssrf)
    LNMP和LAMP的搭建
    linux常用命令 awk命令
    git 工作区管理
    linux常用命令 grep命令
    linux常用命令 print格式输出
    linux常用命令 cut字符截取命令
    linux常用命令 wc统计命令
    linux常用命令 sort排序命令
  • 原文地址:https://www.cnblogs.com/zwh0910/p/15303367.html
Copyright © 2011-2022 走看看