Fork me on GitHub

sprintboot+mybatis+@Mapper中in的使用方法

错误的使用方法:

 @Select("select goods_sn from ${tableName} where goods_sn in (#{skuStr})")
 public List<String> selectForAlgorithm(@Param("skuStr") String skuStr,@Param("tableName") String tableName);

正确的使用方法:

 @SelectProvider(type = DWebsiteProvider.class,method="selectForAlgorithm")
 public List<String> selectForAlgorithm(@Param("skuStr") String skuStr,@Param("tableName") String tableName);

之后在DWebsiteProvider类中添加如下方法:

  public String selectForAlgorithm(String skuStr,String tableName){
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("select goods_sn from "+tableName+" where goods_sn in ("+skuStr+");");
        return stringBuilder.toString();
    }

 

posted @ 2019-09-02 21:00  猿起缘灭  阅读(2178)  评论(0编辑  收藏  举报