java sql 的in后面是一个参数


    public ResponseEntity<N01_02_01_RelateGolfCourseCodeResponseDto> relateGolfCourseCode(N01_02_01_RelateGolfCourseCodeRequestDto n01_02_01_relateGolfCourseCodeRequestDto) {
        N01_02_01_RelateGolfCourseCodeResponseDto response = new N01_02_01_RelateGolfCourseCodeResponseDto();

        List<ClubPaymentHistory> clubPaymentHistories = relateGolfCourseCodeMapper.selectRelateGolfCourseCode(n01_02_01_relateGolfCourseCodeRequestDto);

        if (clubPaymentHistories.size()==0){
            response.setErrorCode("error.common.2002");
            return new ResponseEntity(response, HttpStatus.BAD_REQUEST);
        }

        List<String> bankAccountNos = clubPaymentHistories.stream()//口座番号List
                .map(item -> item.getBankAccountNo()).collect(Collectors.toList());
        //club
        List<ClubPaymentInfo> clubPaymentInfos  = relateGolfCourseCodeMapper.selectClubPaymentInfo(bankAccountNos);
        //group
        List<ClubGroup> clubGroupInfos  = relateGolfCourseCodeMapper.selectClubGroup(bankAccountNos);

        for (ClubPaymentHistory clubPaymentHistory: clubPaymentHistories) {
            List<ClubGroup> clubBankAccountNoList = clubGroupInfos.stream().filter(item->item.getBankAccountNo().equals(clubPaymentHistory.getBankAccountNo()) &&
                    item.getBankAccountName().equals(clubPaymentHistory.getBankAccountName()) &&
                    item.getBankName().equals(clubPaymentHistory.getBankName()) &&
                    item.getBankBranchName().equals(clubPaymentHistory.getBankBranchName())).collect(Collectors.toList());

            List<ClubPaymentInfo> BankAccountNoList = clubPaymentInfos.stream().filter(item->item.getBankAccountNo().equals(clubPaymentHistory.getBankAccountNo()) &&
                    item.getBankAccountName().equals(clubPaymentHistory.getBankAccountName()) &&
                    item.getBankName().equals(clubPaymentHistory.getBankName()) &&
                    item.getBankBranchName().equals(clubPaymentHistory.getBankBranchName())).collect(Collectors.toList());
            //group
            if(clubBankAccountNoList.size()>0){
                ClubGroup clubPaymentInfo = clubBankAccountNoList.get(0);
                clubPaymentHistory.setClubGroup(clubPaymentInfo.getClubGroupId());
                clubPaymentHistory.setClubGroupName(clubPaymentInfo.getClubGroupName());

            //club
            }else if(BankAccountNoList.size()>0){
                ClubPaymentInfo PaymentInfo = BankAccountNoList.get(0);
                clubPaymentHistory.setClubname(PaymentInfo.getClubname());
                clubPaymentHistory.setClubcode(PaymentInfo.getClubcode());
                List<ClubPaymentHistory> clubPayment = relateGolfCourseCodeMapper.selectClub(n01_02_01_relateGolfCourseCodeRequestDto);
                //判断状态  入金金额

            }
        }




        return new ResponseEntity(HttpStatus.OK);

    }

}


    //全項目
    List <ClubPaymentHistory> selectRelateGolfCourseCode(N01_02_01_RelateGolfCourseCodeRequestDto n01_02_01_relateGolfCourseCodeRequestDto);

    //club_payment_info取得項目
    List<ClubPaymentInfo> selectClubPaymentInfo(@Param("bankAccountNos") List<String> bankAccountNos);

    //club_group取得項目
    List<ClubGroup> selectClubGroup(@Param("bankAccountNos") List<String> bankAccountNos);
    <select id="selectRelateGolfCourseCode" parameterType="com.sunflower.rm.web.domain.model.request.N01_02_01_RelateGolfCourseCodeRequestDto"
            resultType="com.sunflower.rm.web.domain.model.entity.ClubPaymentHistory">
        SELECT *
        FROM club_payment_history
        WHERE payment_input_date = #{paymentInputDate}

    </select>

    <select id="selectClubPaymentInfo" parameterType="List"
            resultType="com.sunflower.rm.web.domain.model.entity.ClubPaymentInfo">
        SELECT *
        FROM club_payment_info
        WHERE
        bank_account_no in
        <foreach item="item" index="index" collection="bankAccountNos" open="(" separator="," close=")">
            #{item}
        </foreach>

    </select>

    <select id="selectClubGroup" parameterType="List"
            resultType="com.sunflower.rm.web.domain.model.entity.ClubGroup">
        SELECT
       *
        FROM
        club_group
        WHERE
        bank_account_no in
        <foreach item="item" index="index" collection="bankAccountNos" open="(" separator="," close=")">
            #{item}
        </foreach>

    </select>

当参数类型是一个map时

https://blog.csdn.net/weixin_43941676/article/details/108570499 

当参数为list时,需要注意一个问题,当list为null时,会出现报错

可以进行非空判断,采用下面方法

https://blog.csdn.net/zlp1992/article/details/103118371

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

谛仙0

本人已实现,编写不易

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值