//连表查询
select *,job.user_id as createId from complaint as com left join job on job.id = com.job_id where job.city='Beijing' and job.industry like '%p%' and job.type=1 and com.user_id=7 and com.opt_status>=1 order by com.createdAt desc;
对应的myBatis-plus BaseMapper中自定义
@Select("<script>select *,job.user_id as create_id from complaint as com left join job on job.id = com.job_id where 1=1"+"<if test='certifiedJD != 0'>" + " and job.authentication=#{certifiedJD}" + "</if>"+"<if test='optStatus == 0'>" + " and com.opt_status=#{optStatus}" + "</if>"+"<if test='optStatus == 1'>" + " and com.opt_status>=1" + "</if>"+"<if test='segmentation != null'>" + " and job.industry like '%#{segmentation}%'" + "</if>"+"<if test='nature != 0'>" + " and job.type=#{nature}" + "</if>"+"<if test='userid != null'>" + " and com.user_id=#{userid}" + "</if>"+"<if test='location != null'>" + " and job.city=#{location}" + "</if>"+"<if test='sortBy=1'>"+" order by com.createdAt desc"+"</if>"+"</script>")
List<JobInfo> selectCompliantList(@Param("certifiedJD") Integer var1,@Param("segmentation") String var2,@Param("nature") Integer var3,@Param("location") String var4,@Param("sortBy") Integer var5,@Param("userid") Integer var6,@Param("optStatus") Integer var7);