springboot Mybatis 标签中使用 动态组装Tsql 查询

package web.easyfindder.com.dao.db.imappers;

import lombok.Data;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface IMapperBase {

@Select("<script> select ${keyName} from ${tableName} " +
"<trim prefix='where' prefixOverrides='and|or '>" +
" <if test='filters.size()>0'>" +
" <foreach collection='filters' item='item'>" +
" and ${item} " +
" </foreach> " +
" </if>" +
"</trim>" +
"</script>")
public ArrayList<Object> queryTableValue(String tableName, ArrayList<String> filters, String keyName);
@Data
class Tst{
public String key;
public String value;
}
@Select("${t_sql}")
public ArrayList<Tst> queryTableByTsql(@Param("t_sql") String tsql);



public String queryConfigValue(@Param("key") String key);

}
posted @ 2021-08-04 00:40  只猿身在此山中  阅读(20)  评论(0编辑  收藏  举报