接口方法是这样的
XxlJobInfo getInfoByParameters(@Param("param") Map<String, String> param);
xml如下
<select id="getInfoByParameters" resultMap="XxlJobInfo"> SELECT * FROM xxl_job_info WHERE 1=1 <choose> <when test="param.jobId!=null and param.jobId!=''"> AND id = #{param.jobId} </when> <otherwise> AND job_desc = #{param.jobName} AND job_group = #{param.jobGroup} </otherwise> </choose> </select>
总结:
1、注意获取参数时要使用map的对象去获取,比如 param.jobId
2、@Param(“param”) Map param,为参数重命名