• mybaits foreach


    <select id="selectQuickConsultDoctorList" resultMap="BaseResultMap" parameterType="java.util.List">
            SELECT
                doc.*
            FROM
                user_doctor doc
            LEFT JOIN bas_professional pro ON pro. NAME = doc.profession_field
            WHERE
                doc.`approved` = 2
            AND (doc.consultprice = 0 or doc.consulttoll = 3)
            <if test="list != null">
                AND doc.doctorID in 
                <foreach collection="list" open="(" close=")" separator="," item="doctorid">
                    #{doctorid,jdbcType=INTEGER}
                </foreach>
            </if>
        </select>
    List<UserDoctor> selectQuickConsultDoctorList(List<Integer> paramList);

    结果:

    SELECT
        doc.*
    FROM
        user_doctor doc
    LEFT JOIN bas_professional pro ON pro. NAME = doc.profession_field
    WHERE
        doc.`approved` = 2
    AND (
        doc.consultprice = 0
        OR doc.consulttoll = 3
    )
    AND doc.doctorID IN (?, ?, ?, ?, ?, ?, ?, ?, ?)

    补充:diseaseIds : "8,19"

        @Override
        public List<Map<String,String>> getMedicinal(String diseaseIds ,Integer userId) {
            UserSession session = usrUserService.getUserSession(userId);
            Map<String,Object> paramMap = new HashMap<String,Object>();
            paramMap.put("diseaseIds", diseaseIds.split(","));
            paramMap.put("hospitalId", String.valueOf(session.getHosId()));
            List<Map<String,String>> list = basMedicinalMapper.getMedicinal(paramMap);
            return list;
        }
        List<Map<String,String>> getMedicinal(Map<String,Object> paramMap);
        WHERE
        mdl.disease_id in 
        <foreach collection="diseaseIds" open="(" close=")" item="item" separator=",">
             #{item,jdbcType=INTEGER}
        </foreach>
    WHERE mdl.disease_id in ( ? , ? )
    Parameters: 8(String), 19(String)
  • 相关阅读:
    loj#6433. 「PKUSC2018」最大前缀和(状压dp)
    PKUWC2019游记
    10. Regular Expression Matching
    9. Palindrome Number
    8. String to Integer (atoi)
    7. Reverse Integer
    6. ZigZag Conversion
    5. Longest Palindromic Substring
    4. Median of Two Sorted Arrays
    3. Longest Substring Without Repeating Characters
  • 原文地址:https://www.cnblogs.com/zno2/p/5036669.html
Copyright © 2020-2023  润新知