zoukankan      html  css  js  c++  java
  • MyBatis中参数为List

    mapper中写接口,必须加上 @Param("partyOrganId"),否则会出错。
    List<EChartsDO> getMemberByAge(@Param("partyOrganId") List<Long> partyOrganId);

    xml映射中:
    <sql id="WhereClause">
        where isdel='N'
    <if test="partyOrganId!= null">
    AND party_organ_id in
    <foreach collection="partyOrganId" index="index" item="item" open="(" separator="," close=")">
    #{item}
    </foreach>
    </if>
    </sql>
     <select id="getMemberByAge" resultMap="ExtResultMap" parameterType="java.util.List">
    select text,count(id) count,total,ROUND(count(id)/total*100,1) percent from
    (select case when TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 18 AND 29 then '18-29岁'
    when TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 30 AND 39 then '30-39岁'
    when TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 40 AND 49 then '40-49岁'
    when TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 50 AND 59 then '50-59岁'
    when TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 60 AND 69 then '60-69岁'
    when TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 70 AND 79 then '70-79岁'
    when TIMESTAMPDIFF(YEAR, birthday, CURDATE()) > 80 then '80岁以上' end as text,id,
    (select count(id) from common_party_member <include refid="WhereClause" />) total
    from common_party_member <include refid="WhereClause" />
    )t GROUP BY text
    </select>
  • 相关阅读:
    抽丝剥茧设计模式- 责任链模式应用场景
    抽丝剥茧设计模式-工厂和抽象工厂模式
    抽丝剥茧设计模式-你真的懂单例模式吗?
    抽丝剥茧设计模式- 啰嗦几句
    生产环境ng配置
    Linux命令
    内容过滤报错
    user 报错
    cxlabel 显示不全的解决方法
    关于SQL事务的一些坑
  • 原文地址:https://www.cnblogs.com/yyjspace/p/11605968.html
Copyright © 2011-2022 走看看