复杂sql mybatis查询

 Mapper 增加注解

@SelectProvider(type = xxx.class, method = "xxx")
Page<xxxVO> queryxxxxInfo(Page<xxxxVO> page, xxxxxVO requestVO);
//查询代理人信息 页面展示
public String queryxxxxInfo(@Param("requestVO") xxxxInVO requestVO) {
StringBuffer sb = new StringBuffer();
 sb.append(拼接sql)
if (AgentConstant.AGENT_STATE_IN_WORK_PAGE.equals(requestVO.getAgentState())) {
sb.append("and b.AgentState in ('01','02') ");
} else if (AgentConstant.AGENT_STATE_OUT_WORK_PAGE.equals(requestVO.getAgentState())) {
sb.append("and b.AgentState in ('03')");
}
if (StringUtils.isNotBlank(requestVO.getxxxx())) {
sb.append("and b.ManageCom like concat(#{requestVO.xxxx},'%')");
}


return sb.toString();
}
talk is cheap. show me the code.
原文地址:https://www.cnblogs.com/yushizhang/p/13678049.html