,1.普通方式
参考文献(357条消息) Mybatis mapper.xml使用全局变量的三种方式_yml文件定义全局变量_lijiabin417的博客-CSDN博客
(357条消息) mybatis/mybatis plus 设置全局参数/全局变量/全局属性/手动设置全局参数_码上致富的博客-CSDN博客_mybatis 全局变量
mybatis-plus.configuration.variables.secretFilterSwitch=0
yml的方式
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.demo
configuration:
variables:
userId: 456132465
userName: 李四
配置完成后在代码中调用
@Override public void add1() { String s1="abc"; String s2="abcc"; dictMapper.add1(s1,s2); }
<select id="add1" resultType="com.atguigu.yygh.cmn.bean.MenuTreeDto">
select * from t_test
<if test="s1==s2">
where 1=1 limit 0
</if>
<if test="${secretFilterSwitch}==1">
where 1=1 limit 0
</if>
</select>