sql多个参数可以接收一个(多个)参数——java

controller

    @AutoLog(value = " 通过年级民族政治面貌处分等统计学生人数")
    @ApiOperation(value=" 通过年级民族政治面貌处分等统计学生人数", notes="通过年级民族政治面貌处分等统计学生人数")
    @GetMapping(value = "/getStatistics")
    /* @RequiresPermissions("stStudent:getAreas")*/
    public Result<?> getStatistics(String keyword,String departs,String nationality ,String fieldTwo,String face,
                                   String punish,String graduation,String single,String difficult,String psychological,String academicWarning,String delayedGraduation) {
        List<StatisticsVo> statisticsVo = stStudentService.getStatistics(keyword,departs,
                nationality!=null?nationality.split(","):null,
                fieldTwo!=null?fieldTwo.split(","):null,
                face!=null?face.split(","):null,
                punish!=null?punish.split(","):null,
                graduation!=null?graduation.split(","):null,
                single!=null?single.split(","):null,
                difficult!=null?difficult.split(","):null,
                psychological!=null?psychological.split(","):null,
                academicWarning!=null?academicWarning.split(","):null,
        delayedGraduation!=null?delayedGraduation.split(","):null);
        Result result=new Result();
        result.setResult(statisticsVo);
        return result;
    }

service

List<StatisticsVo> getStatistics(String keyword,String departs,String[] nationality ,String[] fieldTwo,
                                     String[] face, String[] punish,String[] graduation,String[] single,String[] difficult,String[] psychological,String[] academicWarning,String[] delayedGraduation);

@Override
    public List<StatisticsVo> getStatistics(String keyword,String departs, String[] nationality, String[] fieldTwo,String[] face, String[] punish,String[] graduation,String[] single,String[] difficult,String[] psychological,String[] academicWarning,String[] delayedGraduation) {
        List<StatisticsVo> statisticsVo= stStudentMapper.getStatistics(keyword,departs,nationality,fieldTwo,face,punish,graduation,single,difficult,psychological,academicWarning,delayedGraduation);
        return statisticsVo;
    }

mapper

List<StatisticsVo> getStatistics(@Param("keyword") String keyword,@Param("departs") String departs,@Param("nationality") String[] nationality,@Param("fieldTwo") String[] fieldTwo,
                                     @Param("face") String[] face,@Param("punish") String[] punish,@Param("graduation") String[] graduation,
                                     @Param("single") String[] single,@Param("difficult") String[] difficult,@Param("psychological") String[] psychological,
                                     @Param("academicWarning") String[] academicWarning,@Param("delayedGraduation") String[] delayedGraduation);

<select id="getStatistics" resultType="org.jeecg.modules.demo.st.vo.StatisticsVo">
        SELECT
	        COUNT(*) cou
        FROM
            st_student
        WHERE
        st_student.field_one='0' and st_student.deleted='0'
        <if test="keyword !=null and keyword !=''">
            AND st_student.st_name = #{keyword}
            OR st_student.id = #{keyword}
            OR st_student.student_id = #{keyword}
        </if>
        <if test="departs !=null and departs !=''">
            and st_student.college = #{departs}
        </if>

        <if test="fieldTwo !=null and fieldTwo !=''">
            and field_two IN
            <foreach item = "key" collection = "fieldTwo"  open="(" separator="," close=")">#{key}</foreach>
        </if>

        <if test="nationality !=null and nationality !='' ">
            and nationality IN
            <foreach item = "key" collection = "nationality"  open="(" separator="," close=")">#{key}</foreach>
        </if>
        <if test="face !=null and face !=''">
            and face IN
            <foreach item = "key" collection = "face"  open="(" separator="," close=")">#{key}</foreach>
        </if>
        <if test="punish !=null and punish !='' ">
            and punish IN
            <foreach item = "key" collection = "punish"  open="(" separator="," close=")">#{key}</foreach>
        </if>
        <if test="graduation !=null and graduation !=''  ">
            and graduation IN
            <foreach item = "key" collection = "graduation"  open="(" separator="," close=")">#{key}</foreach>
        </if>
        <if test="single !=null and single !='' ">
            and single IN
            <foreach item = "key" collection = "single"  open="(" separator="," close=")">#{key}</foreach>
        </if>
        <if test="difficult !=null and difficult !='' ">
            and difficult IN
            <foreach item = "key" collection = "difficult"  open="(" separator="," close=")">#{key}</foreach>
        </if>
        <if test="academicWarning !=null and academicWarning !=''">
            and academic_warning IN
            <foreach item = "key" collection = "academicWarning"  open="(" separator="," close=")">#{key}</foreach>
        </if>
        <if test="delayedGraduation !=null and delayedGraduation !='' ">
            and delayed_graduation IN
            <foreach item = "key" collection = "delayedGraduation"  open="(" separator="," close=")">#{key}</foreach>
        </if>
    </select>

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值