首页 > 移动平台 > 详细

MyBatis mapper文件中使用常量

时间:2019-02-18 18:22:58      阅读:262      评论:0      收藏:0      [点我收藏+]

MyBatis mapper文件中使用常量

Java 开发中会经常写一些静态常量和静态方法,但是我们在写sql语句的时候会经常用到判断是否等于

//静态类
public class CommonCode {
    public static String EENTERPRISE_PRODUCE = "waste_produce_enterprise"
    public static String EENTERPRISE_DISPOSAL = "waste_disposal_enterp"
   //内部类
        public static class Enterprise {
        public static String EENTERPRISE_PRODUCE = "waste_produce_enterprise";     
        public static String EENTERPRISE_DISPOSAL = "waste_disposal_enterprise";
    }
   }
   

我们在mapper文件中做判断

  //内部类  注意**$** 符号 
     <if test="(type ==@com.xx.xxxx.xxxxxxxxxxxx.CommonCode$Enterprise@EENTERPRISE_DISPOSAL) ">
                <if test="wasteCategory !=null and wasteCategory !=‘‘">
                    and wd.waste_category in(
                    <foreach collection="wasteCategory.split(‘,‘)" item="item" index="index" separator=",">
                        #{item}
                    </foreach>
                    )
                </if>
            </if>
            //常量
            <if test="(type ==@com.xx.xxxx.xxxxxxxxxxxx.CommonCode@EENTERPRISE_PRODUCE) ">
                <if test="wasteCode !=null and wasteCode !=‘‘">
                    and wp.waste_code in(
                    <foreach collection="wasteCode.split(‘,‘)" item="item" index="index" separator=",">
                        #{item}
                    </foreach>
                    )
                </if>
            </if>

MyBatis mapper文件中使用常量

原文:https://www.cnblogs.com/Edgarlixun/p/10396883.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!