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>

sql多个参数可以接收一个(多个)参数——java_第1张图片

你可能感兴趣的:(项目碎片——java)