How do I use parameters for a custom global sql in Mybatis Plus?

< H2 > as in the question, we want to define a global method to get any random data, but we can"t find out how to use parameters in the global method. < / H2 >
official documentation does not indicate how to use it.
// BaseDao.java
/**
 * 
 */
List<T> listByRandom(@Param("num") Integer num);

// CustomSqlInjector.java
/**
 * 
 */
private static final String SQL_LIST_BY_RANDOM = "select %s from %s where id >= ((select max(id) from user_default_avatar) - (select min(id) from user_default_avatar)) * rand() + (select min(id) from user_default_avatar)limit %s";

public void listByRandom(Class<?> mapperClass, Class<?> modelClass, TableInfo table) {
    final String sql = String.format(SQL_LIST_BY_RANDOM, this.sqlSelectColumns(table, false), table.getTableName());
    final SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
    this.addSelectMappedStatement(mapperClass, "listByRandom", sqlSource, modelClass, table);
}

does anyone know? (please tell me) *: please tell

Oct.31,2021

has been resolved. Use-sharp {param} directly. For more information, please see
https://blog.rxliuli.com/p/5b.

.
Menu