27.flowable 自定义sql查询

项目地址: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);
    }
  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小学生05101

flowable

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值