项目地址:https://gitee.com/lwj/flowable.git 分支flowable-base
视频地址:https://www.bilibili.com/video/av79774697/
业务场景:在实际开发中,由于我们需要一些flowable的个性化查询,而且他们提供的api无法满足我的需求的时候,这个时候我们应该考虑flowable有没有那种自定义的sql方式,其实flowable已经给我们预留了这样的接口方便我们随意扩展。
这里我就讲一种注解的方式扩展自定义sql查询
1、首先我们要定义一个mapper接口
public interface CustomCommentMapper {
@Select({ "select t.* from act_hi_comment t where t.PROC_INST_ID_ = #{procInstId}" })
List<Map<String, Object>> selectCommentsByProcInstId(String procInstId);
}
2、配置mapper到config里面
//自定义sql
Set<Class<?>> customMybatisMappers = new HashSet<>();
customMybatisMappers.add(CustomCommentMapper.class);
configure.setCustomMybatisMappers(customMybatisMappers);
3、定义service
@Service
public class CustomCommentService {
@Autowired
private ManagementService managementService;
public List<Map<String, Object>> getCommentsByProcInstId(String procInstId) {
CustomSqlExecution<CustomCommentMapper, List<Map<String, Object>>> customSqlExecution = new AbstractCustomSqlExecution<CustomCommentMapper, List<Map<String, Object>>>(CustomCommentMapper.class) {
@Override
public List<Map<String, Object>> execute(CustomCommentMapper customMapper) {
return customMapper.selectCommentsByProcInstId(procInstId);
}
};
return managementService.executeCustomSql(customSqlExecution);
}
}
4、测试
@Test
public void testXml() {
List<Map<String, Object>> comments = customCommentService.getCommentsByProcInstId("aa798e711a9a11eaa07cdc8b287b3603");
System.out.println(comments);
}